+1000. The number of times I respond to MELPA submissions with a link to the elisp coding conventions is just ridiculous.
In the GNU Emacs Calculator manual, section 2.1.2 Algebraic-Style Calculations, there is a notice:
>Notice: Calc gives ‘/’ lower precedence than ‘*’, so that ‘a/b*c’ is interpreted as ‘a/(b*c)’; this is not standard across all computer languages. See below for details.
Similar notes are scattered through the manual, but I don't recall ever seeing an actual reasoning for this departure from the norm.
I would (and do) just use the build in dired (directory editor). No installation, just C-x C-f a directory and it opens automatically. Type ? and you should get a quick list of options. There is a cheat sheet at https://www.gnu.org/software/emacs/refcards/pdf/dired-ref.pdf which helps on day one - after that I no longer had to look at it.
Lisp has less syntax and obtuse rules than most programming languages languages you're ever likely to encounter. The core conceit of Lisp is that everything is done by functions. The syntax looks like this:
(print "hello")
Function calls are enclosed in parens. The first item inside is the function name. Here we call the print
function. Successive items are the arguments given to function. Here we give the "hello"
argument. Arguments may also be function calls themselves:
(print (+ 1 2))
Just like before, the first item within a paren pair is the function name. Here the inner paren pair is a call to the +
function giving the arguments 1
and 2
. The result of the inner function call is passed as an argument to the print
function.
Oops. I just taught you Lisp by accident.
Honestly, there are a few other syntax rules that deal with representing data and working with low level things, but when you need them they aren't difficult to remember. The fundamentals are extremely easy to comprehend.
I recommend doing, not just reading, these two things to learn elisp:
Beyond that, it's a matter of learning to use Emacs' help system to find documentation and source code when you need to understand how things are done. And practice. And reading other people's code. I don't do enough of the last two. That's why I suck at elisp.
Hi GDP10. I think that you are a bit of a newcomer in the FLOSS world, where everyone has strong opinions about everything. It is notoriously easy to be offended over text, particularly over things we are passionate about. In this case, if you look at the GNU Emacs download page (https://www.gnu.org/software/emacs/download.html) under nonfree systems, you would see the following text:
>To improve the use of proprietary systems is a misguided goal. Our aim, rather, is to eliminate them. We include support for some proprietary systems in GNU Emacs in the hope that running Emacs on them will give users a taste of freedom and thus lead them to free themselves.
Complaining to the /r/emacs community that the goals of the project are exclusionary is not really productive, and to me seems like someone trying to pick a fight.
On a technical note, if you look at the source for the feature you want to use, you would see that it is implemented in ./lisp/net/tramp-gvfs.el. This feature is NOT integration with google drive, but rather integration with gvfs. Wanting to use this feature without gvfs is clearly misguided. It was added for convenience, since other portions of gvfs were already supported this was low hanging fruit to implement. Expecting full integration with google drive independent of gvfs is to misunderstand the feature and its rationale, either naively or wilfully.
Yes the community is anti proprietary software, and no we won't stop talking about it just because you think it is rude. Free software is for some a moral stance, not just strong opinions.
Use mu4e. I use that in conjunction with offlineimap.
I used to use gnus, but it was too slow and didn't have a good way to search mail. mu4e has a super-quick search and loads quickly.
I haven't really worried about html mail -- I just pull those up in webmail. But if I ever get motivated, I'll figure that out.
Orgzly (http://www.orgzly.com) is a new Android app that is syncing its notebooks in org file format.
Only Dropbox is supported at the moment, with calendar planned as an option too. Repeaters are supported already (+ .+ ++ shifting and keeping the state), but it also doesn't record change (yet).
So it's probably still not going to be useful to you, but it could become in not so distant future.
Disclaimer: I am the author.
multiple cursors is pretty dope, but every time i use it i get this feeling like i'm never quite sure if it's saving me more time than defining and repeating a quick keyboard macro would have.
nearly everybody knows about search forward / backward but i didn't really appreciate using them as cursor movement commands to jump around in the file until i started seeing other folks using search commands as cursor movement.
the thing that saves me a ton of time that i rarely see other people use is text registers. for a long time i was in the bad habit of just using the regular kill ring for these things, but registers is way faster when you're juggling several snippets and you don't want to have to sit there and M-y a bunch of times to get to the thing you wanted to yank back.
You're confusing the potential to make Emacs a smooth text editor with it actually being such a thing. The only way those would be the same was if it were engineered for this goal first and foremost which simply isn't the case (compare the emacs paper to the design decisions of xi to see what I mean).
Yes, Emacs has such capabilities. They may be less than ideal, but they do exist. While executing a piece of elisp using the CPU for more than a moment will fully block the editor, it's able to execute asynchronous process callbacks (currently limited to regular and network processes) and timers when being idle. There are definitely packages not leveraging these, if I do a search in my ~/.emacs.d/elpa/
for url-retrieve
and url-retrieve-synchronously
the results are roughly 50/50, suggesting that the average elisp hacker cannot be arsed to deal with the most basic of concepts for non-blocking UI programming, asynchronous programming using callbacks. Draw your own conclusion on how doomed you are from that most anecdotal data point.
This is awesome news!
Please support highlighting the current line number with a customizable face.
Please support customizing the face of all other line numbers (that are not the current line).
I use the window
overlay property to show line numbering in only the active window, so perhaps consider adding such a feature. https://www.gnu.org/software/emacs/manual/html_node/elisp/Overlay-Properties.html I understand the new feature may not be overlays, but it may be fairly easy to have this user option available. For anyone who would like to see how such a feature works, have a look at the variable highlight-nonselected-windows
.
https://github.com/hlissner/doom-emacs mentions
> A popup management system (powered by shackle) that minimizes the presence and footprint of temporary and/or disposable buffers.
I'm really curious what that looks like, but I can't find a screenshot anywhere. Does anyone know of one off-hand?
The Emacs manual details the commonly used commands and features. I don't understand why, if you are new to Emacs, you would want to start with the Elisp manual instead, which details the features of the programming language Emacs Lisp. That is like skipping the reading of one's car's manual and going straight into learning how to modify/build the engine.
If you are new to Lisp and Emacs, then I think that the free book An Introduction to Programming in Emacs Lisp is a better place to start than the Elisp manual.
This is how I did it:
I have never read the entirety of any of the manuals, because they have descriptions of many things that are not related to what I want to do.
Therefore, I recommend not trying to read all of the manual. It is not a novel, and probably contains more than what you want to know or would need to remember.
Sometimes I want to get info about my IP address (e.g. if VPN is connected or not) or some other IP.
This function uses request
to display infos from ipinfo.io
:
(defun ipinfo (ip) "Return ip info from ipinfo.io for IP." (interactive "sEnter IP to query (blank for own IP): ") (request (concat "https://ipinfo.io/" ip) :headers '(("User-Agent" . "Emacs ipinfo.io Client") ("Accept" . "application/json") ("Content-Type" . "application/json;charset=utf-8")) :parser 'json-read :success (cl-function (lambda (&key data &allow-other-keys) (message (mapconcat (lambda (e) (format "%10s: %s" (capitalize (symbol-name (car e))) (cdr e))) data "\n")))) :error (cl-function (lambda (&rest args &key error-thrown &allow-other-keys) (message "Can't receive ipinfo. Error %S " error-thrown)))))
As I like to keep my own init.el clean with use-package here is the same function packaged.
This looks like a good start: https://www.gnu.org/software/emacs/manual/html_node/elisp/GNU-Emacs-Internals.html
got the link from the CONTRIBUTING file in the repo: http://git.savannah.gnu.org/cgit/emacs.git/tree/CONTRIBUTE
What are you talking about? Emacs does support drag and drop OOB. At least 26.1 does.
I just tested it myself (for the very first time because, believe me or not, when I'm in Emacs, I never use a pointing device) and it's also documented here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Drag-and-Drop.html
Seconding dired. I love that tool.
Also, wdired is truly magical. Makes it super easy to move/rename files, and works over ssh too.
About the only thing dired doesn’t do well by default is displaying an entire file tree on the side as you navigate, like Windows Explorer does. I don’t particularly miss that feature, but there are lots of solutions out there built on top of dired. I found this emacs.se post fairly comprehensive.
Hello and welcome to the world of Emacs!
You can use the built-in VC-mode with subversion. While less sexy than magic it's still a solid integration.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Version-Control.html
Quoting the manual:
> We do not recommend that you move into early-init.el customizations that can be left in the normal init files
So you mean Google wouldn't, for example, be willing to take GPL-licensed code and make a derivative of it a significant part of their business plan?
You should take a look at this part of the manual: https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup.html
It's a bit odd you're seeing backup files when working with git - generally Emacs is smart enough to not make backup files when a file is also under version control.
I tend to leave backups on, but have Emacs put them all in one folder (~/.emacs.d/backups). I've got an article that describes which variable to customize (using the customize interface) and how to customize it: https://artlogic.github.io/.emacs.d/entry/2015/04/17/clean-backups/
Hope this helps!
I don't know how familiar OP is with emacs so to elaborate a little. The deleted text gets added to the kill ring which is a wrap-around list and you can access all the previous items added to the list.
By default:
C-y - yanks the last item added to the kill ring
C-u <number> C-y - yanks the item <number> from the end of the list - so C-u 1 C-y is the same as C-y.
C-y followed by M-y cycles backwards through the kill ring. So
Would a Koenigsegg work as a replacement for a Skoda? :-) In short yes Org Mode has the features you are looking for and a ton more. As to Android then I believe the two most popular options are MobileOrgNG and Orgzly
From the Emacs Lisp Reference Manual, "E.8 Writing Dynamically-Loaded Modules":
>This section describes the Emacs module API and how to use it as part of writing extension modules for Emacs. The module API is defined in the C programming language, therefore the description and the examples in this section assume the module is written in C.
Magic!
Actually most features are coded in Elisp, which is a emacs specific variant of the Lisp programming language family.
This means you can write your own Elisp and make Emacs do strange and wonderful things.
There is a way around this, with a little bit of elisp, unsurprisingly. Eshell knows that you might want a terminal for some commands, and has a couple ways to handle this. The simplest is what eshell calls ‘visual commands’.
https://www.gnu.org/software/emacs/manual/html_node/eshell/Input_002fOutput.html
Basically, this is way to tell eshell that it should launch the indicated commands in a terminal emulator. I think it might use term by default, whereas I recommend ansi-term instead. If this isn’t automatic/easy, let me know and I’ll dig into how to fix it (not in a good place to look right now; sorry).
The next layer involves customizing eshell a bit. I got this from a great emacs blog, (or emacs). In particular:
https://oremacs.com/2019/03/24/shell-apt/
I hope this helps.
Is it strongly recommended to use GUI? I have never heard such a claim! Yes, some features does not exist or are different in TUI from GUI, but that is another topic. :)
I don't know about themes because I don't use them very much, but I think it is possible. For example take a look at spacemacs.
Remember to set your terminal to 256 colors:
export TERM="xterm-256color"
Oh I found the following text:
"In the terminal version of Emacs, color themes will not render correctly as colors are rendered by the terminal and not by emacs. You will probably have to change your terminal color palette. More explanations can be found on emacs-color-theme-solarized webpage."
The two invocations are not equivalent.
Take a look at the section of the manual which goes over the startup process, listed here, Emacs Startup Summary, for details over exactly how they differ. The one that jumps out to me in this instance, given how commonly it's used in init files, is that the after-init-hook is run before the loading of files using -l. i.e. any configuration placed there will not be run in the second case.
Hopefully this help to at least set you off in the right direction.
Most emacs users would just use dired
/wdired
(it's inbuilt) to do what you demonstrated in that screencast, and much more!
Be interested in how you get on. I used MobileOrg a bit several years ago, but since it started to stagnate I had trouble accessing files saved on Dropbox and switched to Orgzly, but I'm keen to see how you get on with forking MobileOrg as your proposals sound interesting. Unfortunately its been too long since I last used MobileOrg to say what I found limiting in it.
What a great news!
I don't have experience with Repl.it. But it seems now we can share Emacs Lisp code snippets, unlike pastebin services such as Gist, the code can actually RUN by the viewer. For example, I just some code to simulate pip progress bar: https://repl.it/repls/ScrawnyTenderCertifications
I have one suggestion: It would be nice if it supports the latest version of Emacs or even multiple versions if that's possible (and user can choose latest or specific version), currently it's using Emacs 25.2.2, and the latest version is Emacs 26.2.
Thanks. Blog contributions are always welcome. They help users better understand, especially with how-to-use info and examples.
Here are some minor comments, FWIW -
First, the positive - good for you:
Presenting remove-hook
along with add-hook
. A common gotcha is to add some hook function and not then know how to quickly remove it (help!).
Covering both major and minor modes.
Covering use in a given buffer. FWIW, I wouldn't call this using "buffer-local hooks", however. A hook is a variable, and the use cases you show don't involve buffer-local variables (which are a thing - "buffer-local" generally refers to variables).
Next, the slightly negative - could be improved:
Mention that it's generally not a great idea to use anonymous functions, and why - including the quick-stop-this! use of remove-hook
: having to provide a lambda form that you used for add-hook
, the two being checked for equality.
With the title "What You Need to Know" I'd kinda expect to find either all that one might need to know or the main things one might need to know. The blog goes into most of the main things, some of them in detail (well done). But it glosses over abnormal hooks (see next).
Abnormal hooks seem to be treated as an afterthought, with a small paragraph. Nothing about run-hook-with-args
, run-hook-with-args-until-success
, or run-hook-with-args-until-failure
. Such hooks cover important use cases, which are different from what you can do with normal hooks. And of course you can't use abnormal hooks in some contexts.
Finally, the manual is pretty good about hooks. You might want to link to it from your blog, to provide more info. (elisp) Hooks
HTH. (If not, please ignore.)
And a little adventure game, and functions for the phases of the moon, and a browser or two, and org-mode, and a cut-down Computer Algebra System.
I really don't think that the philosophy of Emacs is to be "as performance optimal as possible", or anything related to bloat/performance, at all. It's one of the leaner editors around, sure, but only because it's a decades old piece of software in a world where Electron exists, but being a decades old piece of software doesn't help much in the appearance department - gvim isn't much of a looker, either.
Extensibility - at runtime, even - is a much bigger focus, and elisp is not a particularly fast language. I came to Emacs from Sublime, and I didn't find particularly elegant, but - part of using Emacs is learning Emacs, so I eventually configured it to my liking.
My trajectory is probably not uncommon, which could explain why there is not much of a push towards better defaults (besides forty years of inertia re: keybindings & co) - most of us don't deal with the defaults for long.
I use notmuch. It's not exactly a mail client in the same way that the others are, as most of the heavy lifting is done via C and C++ libraries. But the primary user interface is an Emacs mode. It's also under very active development (the mailing list sees maybe 30-40 messages a day on average).
Think of it a bit like Gmail in Emacs: most of the navigation and manipulation of your mail is done through searching and tagging. It uses Xapian, a full-text search engine written in C++ to provide the search functionality, and most of notmuch is a C library that sits on top of Xapian and provides tagging functionality and the application level search API. The Emacs piece is then the UI, and provides convenient access to your tags, searches, etc. If you like the Gmail style of dealing with email, it's worth a look. Also good: it's very fast. It's fast compared to a normal mail client. Compared to Gnus, it's biblically quick.
The downside is making it play well with others. If you normally read mail via a local spool (i.e., you use fetchmail or something like it to pull mail into a local set of maildirs), then it's a really nice fit. If, like me, you use Gmail and want to have the server reflect all the local changes you've made, it's not as good. I use offlineimap to sync with Gmail, and that works well enough for things like marking mail as read. However, there is no built-in support for having your local tagging update things in a way that offlineimap will update Gmail. It seems most people end up writing shell scripts (or there is an officially blessed python API), but it's a bit of a pain in the ass. It's flexible enough to support about anything you want, but once you start trying to figure out all the syncing behavior you want, it does start to feel like you're writing your own mail client on top of a bare API.
Do you have Google Drive installed on the Mac? Would that let you just save to a Google Drive local directory and automatically sync to the online repository? Surely tramp wouldn't even be required for that scenario.
gvfs is the Gnome Desktop virtual filesystem, which seems fairly Linux specific; I imagine tramp only falls back to that for protocols not supported in the standard connection methods (rcp, rsync, scp, ftp, etc..)
Umm.... Hmmm....
First off, my first step in any new operating system install is map CapsLock to Ctrl. I don't even bother swapping it.
Second, I suggest trying Emacs without the ergomacs bindings that you mentioned (I'm not quite sure what it gives you, but I'm pretty sure that you're not using 99% of Emacs w/o Ctrl) and just run through the tutorial
To run a vanilla Emacs session run with no init file:
$ emacs -q
Now use the help system
Ctrl-h t
for the tutorial. It's been a LONG time since I've used it, so the content might be dated... But the rest of the help system is EXTREMELY powerful. Try
Ctrl-h r
Ctrl-h i
Ctrl-h a
See your modes with
Ctrl-h m
You can describe any keybinding with: Ctrl-h k
After that, just hit the keys that you want to check. E.g. Ctrl-h k Ctrl n
will show you that Ctrl n moves to the next line. Better than that, you can jump right to the source of the function that is run by Ctrl-n
Ctrl-h b
will list ALL keybindings. I find this less useful, but it is interesting to inspect, and helpful to learn knew things that I never knew existed.
Learn to navigate with:
Ctrl-n
Ctrl-p
Ctrl-a
Ctrl-e
Ctrl-f
Ctrl-b
Meta-f
Meta-b
Use Ctrl-h k
to inspect those bindings.
There's WAYYYYY more to it.... (Check out macros)
Whenever your cursor gets "stuck" just bang on Ctrl-g a few times.
https://www.gnu.org/software/emacs/tour/
Eventually you'll commit a few hundred or so keybinding command to muscle memory and forget that you ever used a mouse, or even moved your fingers off the home keys much.
Personally, I had a very hard time with writing this reply because I'm on mobile and I don't actually remember most keybindings by "key". I remember them purely by muscle memory, and when I discuss a command I usually need to mime the movements with my fingers to help my brain out.
In any case, Ctrl is at the center of it all.
I personally use use-package
, so configuration for specific package is done right (package-specific code should only be loaded when the package is loaded), and because I use emacs on my desktop and laptop I want packages to be automatically installed.
I also use paradox
instead of the regular package.el
. It doesn't add much functionality, but it makes the menu prettier (compared to list-packages
).
It seems like you're not completely read up on packages in Emacs, so I highly encourage you to read through this chapter in the Emacs manual. (I'd also recommend reading through the whole manual. It straightened out a lot of question marks for me, and revealed features I never knew existed before.)
Hi all, here it is a ReactJS
+ emacs-lsp
tutorial after the CPP one. It is a direct port of VSCode reactjs tutorial. It was really fun to provide that tutorial since all we had to do is string replace VScode
-> Emacs
, replace the screenshots, change the way commands are invoked spend a few weeks chasing bugs. The tutorial ships with ~25 lines "get the job done" config as a demonstration that we are closer(hopefully) to the "just works" category.
Replace ???
in
(setq initial-frame-alist
(append initial-frame-alist
'((left . ???)
(top . ???)
(width . ???)
(height . ???))))
All parameters are optional.
For more info on these frame parameters:
Embedding neovim should be possible by binding libnvim's C API, or maybe by using its MessagePack-RPC.
There are no MessagePack implementations in eLisp, to my knowledge, so going the latter route seems impossible at present.
Even if you got neovim embedded in Emacs, I wonder how integrated the two would be. Would you just wind up with a separate app acessible from Emacs (kind of like libvterm), or could a tighter integration (more like eShell) be possible?
The advantage of evil is that it's all in eLisp, so how it works is completely transparent and Emacs-native, if you will. While with libnvim, one could go as far as the bound C API functions and no further (without diving in to C, anyway).
It would be interesting to see how neovim embedded in Emacs would work in practice, however.
Also, I'm interested in what you miss from vim. For me, the main things are its regex syntax (which is more powerful than Emacs' regexes in some ways), and vim's much better performance on large files. Other than that, I really can't think of anything.
You still have to provide more details, do you want to create a major-mode or a new minor-mode? You could start here:
C-x 4 c
Will create an indirect buffer that you can use to expand an org-mode file without changing he view of the other.
You could pretty easily make a macro to do this for you, in fact I'll reply with one in just a second.
I guess you don't mind nuking it, but I think I would have. The things I build up in my config are customizations that took time to develop just the way I want them.
Personally I would've done some profiling with <code>M-x profile-start</code> to see what may have been causing the issues. In my experience it's usually one specific thing that's slowing things down, and it usually shows up when profiling. Then you could just disable that or figure out how to make it more efficient.
For example recently I was fiddling around with things and set the eldoc-idle-delay
to 0. This had the consequence that if I scrolled through the buffer, eldoc would be computed/run every time the cursor moved over a different function/symbol, which made scrolling ridiculously slow. Profiling pointed this out immediately and made me realize that it was stupid to have set it to 0, so I simply left it at its default value, which means that simply momentarily scrolling the cursor over a function doesn't compute eldoc for it unless it idles there.
Then again it could just be that you just wanted to start from scratch to have a clean slate.
An Introduction to Programming in Emacs Lisp
It is also available in emacs in info: C-h i
More advanced stuff:
GNU Emacs Lisp Reference Manual
Also available in emacs.
http://www.orgzly.com/ is showing some promise.
Org on the desktop, save to dropbox, read on mobiles in orgzly. You can also edit in dropbox with a dumb text editor.
I do wonder if syncing Org and Evernote is feasible. There is an Evernote HTTP API so maybe someone will write one, then we'll get all three!
Tide works for javascript as well as long as there is a jsconfig.json file. Installing @types/{package_name} will result in better autocompletion etc.
Wdired which allows for editing a buffer text-wise is great for batch renaming. Rectangle mark & string-insert-rectangle do a good job of fixing up some issues too when filenames are regular-enough.
Even if it wasn't part of Emacs, I think dired would be worth using. But not having to entirely duplicate work I've already done in Elisp to extend it is nice.
I came over from vim, and while I use evil for particularly intense text munging, I try to keep to "vanilla" emacs most of the time. The first thing that helped was moving Ctrl/Meta to the keys under my thumbs, so I could touch-type as normal while holding them. The second was realizing that while Vim is optimized for plain text editing, Emacs is optimized to create individual semantic editing modes. If you write a lot of C, you should learn about the tools created specifically for C. If you write Scheme, you should learn Paredit & Geiser. Use git, learn Magit. Write markdown, switch to Org. So on and so forth, always worth searching ELPA or googling emacs {task}
I don't think there's really any beating vi for pure textual manipulation. I keep a toggle to load/unload evil bound to C-S-Z for that reason. But you can get pretty decent. Here's a site (emacsrocks, twitter of the same name) with some useful tips. You should also read the whole Info node on pure text manipulation. Also go look at treesitter, an incremental parser that makes it easy to whip up your own custom text objects.
You can save window configurations in registers. Type C-x r w
To save your current frame. You can assigned them numbers e.g. C-x r w 1
. If you've torn down your windows or frame configuration, you can bring it back up with C-x r j 1
. More here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Configuration-Registers.html#Configuration-Registers
Git itself is much faster on *nix than it is on Windows (and Magit makes lots of calls to Git). On OSX process forking via Emacs was slow before Emacs 26, but I gather that Magit performance on OSX should be fine from that point onwards.
You should read https://magit.vc/manual/magit/Performance.html
GNU/Linux is great, though. Go ahead and dive in! Once you've become accustomed to it, you may wonder how you coped in Windows for as long as you did.
To compose commands is really a powerful concept. One thing that annoys me is that you have to input the full key sequence before you get feedback. Editors like Kakoune reverse the order: You first select things and afterwards apply the operation. Another neat idea is Versor where you select one unit and afterwards move by it's units with the same keys for any unit you select. I have implemented something like that but using text objects and temporary modal states:
For example the command beginning-of-defun
automatically "locks in" the defun text object. Now pressing n
moves to the next defun, p
to the previous, k
kills the current one, m
marks it and moves to the next (like you would mark a file in dired). When you have marked multiple objects pressing k
acts on all of them sequentially. You can also switch the locked in object and mark different ones. After applying an operation you are back to normal. You always get into that modal state by pressing a movement command associated with an object, beginning-of-paragraph
"locks in" the paragraph object, backward-sentence
the sentence object and so on. I still have to publish it but I'm a bit struggling to finish it.
Have a look at C-x TAB
[ref].
Also, selecting a region and hitting C-u C-x TAB
will indent that selection to the right by 4 spaces. See indent-rigidly
.
Probably unrelated: I use this to copy the rigidly indented region on hitting Enter (requires use-package/bind-key as copied from my config; but the same would work using define-key
too). It's useful to copy indented copy for Reddit, etc. that require code blocks to be indented by 4 spaces.
(bind-key "RET" #'kill-ring-save indent-rigidly-map)
May be you should pair up with the developer of http://www.orgzly.com/ so that we have an integrated solution that works on both, web and Android app. User can then update/review their notes/todo lists on web/phone or plain-text .org files synced to Dropbox or whatever new sync service that gets added to Orgzly.
Write a unit test with ERT that uses WITH-TEMP-BUFFER
to set up the buffer it should work on & asserts that it does the right thing.
I could just give you the answer, but I will point you at the Calling Functions section of the Emacs manual, and also tell you:
C-h f setenv RET
and read the *Help*
that appears."M-x ielm RET
, which opens an Emacs Lisp REPL, and try some stuff there.As you may know, Guile Emacs aims to replace the elisp engine with an interpreter written in Guile. This will enable concurrency and we will have a faster implementation of elisp, but it also means that we will be able to write extensions in pretty much any language with Scheme as the host language (I bet you can expect cl, Emacs-wizards love their lisp). I know that the wait is painful, but the elisp interpreter is done and the project is looking closer than ever.
Get up-to-date by reading: The future of Emacs, Guile, and Emacs Lisp and read the EmacsWiki piece about the technical details.
> I hate Windows.
How have you installed Emacs?
I had a good time with Chocolatey's Emacs 64 package on a slow, old PC with Windows Vista. Looks like their August build is 25.2.1.
I use Syncthing on my Android phone, my Windows computer and my Linux computer. Everything is centralized on a Raspberry Pi where Syncthing runs as a service, always online. I'm pretty happy so far with that config and I also use it for my Emacs config since I don't need version control :)
There is none ATM.
But I believe u/tecosaur is planning to write one (or maybe already working on it) for inclusion in his monthly org report. I've already said I'd help if he needs it.
You can see this Doom PR I'm working on for some ideas on config.
https://github.com/hlissner/doom-emacs/pull/5212
I can't promise it works ATM though, in part because I don't understand use-package
very well!
The only thing Doom does is to mark all the customize commands as disabled, using the standard Emacs mechanism for disabling commands.
You could even reuse the code Doom uses to do this: https://github.com/hlissner/doom-emacs/blob/develop/core/core-ui.el#L685-L696
I usually just build from source, it's quite easy. Hop over to https://www.gnu.org/software/emacs/download.html#gnu-linux and download the latest version. Then just unpack and from the root directory:
./configure && make && sudo make install
You might need to install dependencies first with sudo apt build-dep emacs
.
I think it would help if the initial screen pointed new users to information about unique and cool features of emacs. Things like web-mode
, org-mode
, eww
, the kill ring, and running compilers and terminals inside the editor, are what new users need to know about. Not being reminded, as the Tour does, that now they have to press C-s
to search forward instead of C-f
like in any other program.
One reason SublimeText is popular is it's powerful features can be discovered easily without doing configuration or learning crazy key chords.
Nice!
One comment: i suggest not binding functionality to `C-c [letter]", as per the Emacs Lisp Reference Manual:
> Don’t define C-c letter as a key in Lisp programs. Sequences consisting of C-c and a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them. > > Changing all the Emacs major modes to respect this convention was a lot of work; abandoning this convention would make that work go to waste, and inconvenience users. Please comply with it.
There are a few keys, called control characters, which are interpreted specially in gui Emacs to stay consistent with terminal Emacs. In the terminal ESC
and C-[
are indistinguishable. I remap C-m
which is usually considered as RET
by using input-decode-map
but I just tried that solution and it does not work for this case.
Looking at this documentation it appears it is specifically recommended not to try and rebind C-[
or M-[
by any means.
I dislike the esoteric sigils.
Also underscores should not be used unless the variables are planned to be unused. Here a reference to that special meaning in the elisp manual: Using Lexical Binding.
Here's the relevant piece from that section:
> (To silence byte-compiler warnings about unused variables, just use a variable name that start with an underscore. The byte-compiler interprets this as an indication that this is a variable known not to be used.)
Example
(defun foo (&rest _unused) (message "hey"))
Well, it has value as a popularity metric and we should look at it as such (and it's also important). Conflating this with any other kind of insight is nonsense.
30% uses notepad++
(setq org-odt-preferred-output-format "doc")
Default Org to export ODT in Word format (.doc). I discovered it tonight right before I get off from work and send it to my manager, very convenient for exporting docs for business colleagues for editing. See manual for more options.
Add a button in Help buffer to remove advice
You can even run the code to try it! (C-x o to change window, tab to move the Remove button, RET to remove the advice). Repl.it is very cool.
I'm not familiar with Neotree, but you can drag files into Dired. See https://www.gnu.org/software/emacs/manual/html_node/emacs/Misc-Dired-Features.html
> On the X Window System, Emacs supports the drag and drop protocol. You can drag a file object from another program, and drop it onto a Dired buffer; this either moves, copies, or creates a link to the file in that directory. Precisely which action is taken is determined by the originating program. Dragging files out of a Dired buffer is currently not supported.
Yay!
... But the maintainer on Arch has packages that have been out of date since April, so I'm not holding my breath...
EDIT: Annnnnddddd it's already in the repos.
This is referring to a feature introduced in Emacs 27 for which the graphical part is still missing in the ns/cocoa port (I don't know about the railwaycat port, though).
Most likely the HTML versions of the info pages as seen on https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Read-Syntax.html.
And indeed, there's no <title>
tag to be seen anywhere. The closest equivalent is <h3 class="section">2.2 Special Read Syntax</h3>
.
IMHO OP should submit a patch to texinfo that includes the <title>
tag into the HTML export output, get it merged and hope that with the next Emacs release the web manuals are regenerated and now include that <title>
tag. This may take months of idle work. Such is contributing to GNU projects. Good luck!
Do you mean using Lisp code or interactively?
Interactively, to reselect (activate) the region, use C-x C-x
(or C-x C-x C-x C-x
if you care which end of the region the cursor is).
With Lisp, set or bind deactivate-mark
to nil
in your command, to prevent the region from being deactivated when the command finishes.
See the Elisp manual, node The Mark:
> Variable: deactivate-mark
>
> If an editor command sets this variable non-‘nil’, then the editor
command loop deactivates the mark after the command returns (if
Transient Mark mode is enabled). All the primitives that change
the buffer set deactivate-mark
, to deactivate the mark when the
command is finished. Setting this variable makes it buffer-local.
>
> To write Lisp code that modifies the buffer without causing
deactivation of the mark at the end of the command, bind
deactivate-mark
to nil
around the code that does the
modification. For example:
>
> (let (deactivate-mark)
> (insert " "))
The responses here surprise me. The documentation is quite well-done I think, in that it takes the opportunity to educated a user reading the manual about other mechanisms that might be relevant to them if they are looking to jump to a line number.
Here's the full answer in the docs (https://www.gnu.org/software/emacs/manual/html_node/efaq/Going-to-a-line-by-number.html)
> Are you sure you indeed need to go to a line by its number? Perhaps all you want is to display a line in your source file for which a compiler printed an error message? If so, compiling from within Emacs using the M-x compile and M-x recompile commands is a much more effective way of doing that. Emacs automatically intercepts the compile error messages, inserts them into a special buffer called compilation, and lets you visit the locus of each message in the source. Type C-x ` to step through the offending lines one by one (starting with Emacs 22, you can also use M-g M-p and M-g M-n to go to the previous and next matches directly). Click mouse-2 or press RET on a message text in the compilation buffer to go to the line whose number is mentioned in that message.
> But if you indeed need to go to a certain text line, type M-g M-g (which is the default binding of the goto-line function starting with Emacs 22). Emacs will prompt you for the number of the line and go to that line.
> You can do this faster by invoking goto-line with a numeric argument that is the line’s number. For example, C-u 286 M-g M-g will jump to line number 286 in the current buffer.
Colon is sort of like the single-quote prefix to a symbol, it tells the interpreter that this is a literal symbol, not a variable to be immediately looked-up and substituted with the associated value in the variable table.
A colon symbol is usually used to label arguments to a macro, it is kind of like writing font_lock(keyword.face, weight='bold', slant='italic')
in a language like Python. The colon is used as a prefix (because in Lisp, all things are prefixed) in the same way that a dictionary literal may be defined in Python with keys separated from values by an infixed colon, e.g. {'a':1, 'b':2}
.
For a list of what is to be put after the colons, check out the Emacs Lisp manual section "Face Attributes".
Also, probably a thorough reading of the Emacs Lisp manual section "Font Lock Mode" is probably worth your time.
> \`
> matches the empty string, but only at the beginning of the buffer or string being matched against.
> \'
> matches the empty string, but only at the end of the buffer or string being matched against.
and if you like dmenu you'll love rofi https://github.com/DaveDavenport/rofi
Might also want to check out Kupfer, which looks rather different from helm/dmenu/rofi but does some very cool stuff, kinda like Quicksilver (which is mac-only) or Launchbar (also mac-only): https://kupferlauncher.github.io/
this doesn't *exactly* answer your question, but this library found solves a more general problem of navigating to previous cursor locations. I use https://libraries.io/emacs/backward-forward:
(add-hook 'prog-mode-hook #'backward-forward-mode)
(global-set-key (kbd "C-<left>") 'backward-forward-previous-location)
(global-set-key (kbd "C-<right>") 'backward-forward-next-location)
But we need to hurry up! I read in a blog that the next version of internet will use WebAssembly[1]. I really do not want to make a second rewrite after the update.
Probably I will help, currently I now two programming languages: HTML5 and CSS3, and I am in the process of learning TypeScript, that is like JavaScript but from Microsoft, and with better types!
This is the best way I've found to do it (it's not a ppa though):
sudo apt install build-essential libncurses-dev wget
sudo apt-get build-dep emacs
cd tmp && wget https://mirror.clarkson.edu/gnu/emacs/emacs-26.1.tar.xz
(or from your mirror of choice at https://www.gnu.org/software/emacs/download.html )tar xvf emacs-26.1.tar.xz && cd emacs-26.1
./configure && make && sudo make install
You'll probably need to create .desktop files manually (though you could adapt them from the 18.10 default Emacs ones).
(I do really wish there were a standardish distro based on the latest Ubuntu which just had the latest stable Emacs in their repos. It would be nice to have something I could direct people to like this.)
Are you using Emacs 26.1? If so, there's some information about using 24-bit color in the FAQ (also accessible from within Emacs via C-h C-f
).
The marks are stored in a mark ring, so you do have multiple marks:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Mark-Ring.html#Mark-Ring
>Each subsequent C-u C-<SPC> jumps to a prior position stored in the mark ring. The positions you move through in this way are not lost; they go to the end of the ring.
Or, you could use bookmarks.
Or, if you happen to use evil-mode
, letter-based (Vim style) marks: ma
to set mark a
, then later 'a
to jump there. Also with evil
many movement operations are considered "jumps" - which are remembered - so you can move and back between them easily with C-i
and C-o
.
You probably don't want to build a "plug in", which implies a loadable executable module. You probably just want to write some lisp code to modify Emacs' behavior.
You want to read this manual.
https://www.gnu.org/software/emacs/manual/elisp.html
(Loadable modules are rare to almost non-existent, though the facility is used by a few people.)
Org agenda has a bulk edit command. Add the files you want to change to the variable "org-agenda-files", then open an Agenda of todo items.
"m" will Mark the entry at point for bulk action
"*" will Mark all visible agenda entries for bulk action.
"B" Bulk action: act on all marked entries in the agenda.
And after you hit "B" for bulk actions you can hit "d"
"d" Set deadline to a specific date.
More info here (thats where i copied all this info from), and Its worth a good read. I use a lot of these commands quite frequently.
> Lack of name spacing in elisp. my-cool-package-function-name gets really old.
It's not exactly a fix, but if you turn on lexical binding for your elisp file you can then use closures. If you wrap your code in a let
and define your functions as part of that, and you can cut down on global namespace pollution a bit. Plus you can create aliases to often-used functions with long names by doing something like this:
(let ((f 'message)) (funcall f "hello"))
Another closure trick is you can make a pseudo-ns
function that takes a partial symbol name (such as 'string
) and returns a function that takes a second symbol and combines them to create the full function name. Like so:
(defun pseudo-ns (ns) (lambda (s &rest args) (apply (intern (concat (symbol-name ns) "-" (symbol-name s))) args)))
(defun s (f &rest args) (apply (pseudo-ns 'string) f args))
(s 'to-list "Hello") ;; => (72 101 108 108 111)
You could also combine the two and make the s
a let binding, but you'd have to do (funcall s 'to-list "Hello")
then, which makes it less interesting unless you're frequently calling functions like really-long-package-name-do-something
Edit: Just realised a day later that I screwed up and used &optional
and funcall
instead of &rest
and apply
. The latter is what I should have done, so I've updated post accordingly.
> Maybe such doc already exists and just need more exposure.
There is, and it took me maybe half a minute to find it on the Emacs website. Sure, it could benefit from more visibility, but the author of the article apparently didn't try very hard.
> I've looked here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html and found no clarification at all.
Because there's no need for clarification. .{progname}
(for a single file) and .{progname}.d
(for a directory if/when configuration goes beyond a single file) are downright ancient UNIX conventions. See also: ~/.ackrc
, ~/.gitconfig
, ~/.profile
, ~/.bashrc
or ~/.zshrc
, ~/.ssh
, etc...
> Furthermore why isn't the configuration stored in .config like other programs?
Why would it? Emacs predates freedesktop by decades and runs on platforms which don't even remotely intend to follow freedesktop conventions. Furthermore if it did follow freedesktop it'd store its configuration in $XDG_CONFIG_HOME
which isn't necessarily ~/.config
.
You can still use Common Lisp features by using cl-lib
(contains Common Lisp functions) or cl-macs
(contains Common Lisp extension in macro forms instead of functions). See Common Lisp extension from the official manual. You can also be able to use CLOS to develop your Emacs package.
Here's a recent article by Wilfred Hughes on how to write a major mode. I would suggest though that you start with understanding emacs lisp first. Apart from the official emacs lisp tutorial there are many other shorter versions available online to help you get started in few minutes.
Thank you, I'm glad you found it helpful!
I write all my blog posts in org and then convert them to HTML using Emacs. These HTML files are then used to build the entire site with Jekyll. I created the theme and layout myself - you can probably tell I'm not artistically talented :)
You want to utilize M-x org-edit-src-code
(Bound by default to context-sensitive bind C-c '
). What this does is that it takes the code in the block and opens it in a new buffer with the block's language major mode on so that all of the regular editing commands work. See https://orgmode.org/manual/Editing-Source-Code.html . This is the intended solution to the problem you're having.
Since HashBox covered some of my points, I'll add a few extra as a reply.
Self-Documenting. Emacs has the Info documentation reader built-in, so you have references for everything under the sun at your finger tips.
Consistency. Because you can run most processes inside of Emacs, the same shortcuts work throughout. So, I can run Ruby, Python or Bash as an inferior process, and navigating and manipulating text works the same way. While I can't speak towards using Vimpulse (I jumped right in the deep end after years of using Vim), I'd assume its shortcuts hold between the modes as well.
I'd also suggest forking the emacs-starter-kit, rather than starting with an empty .emacs.d. It's not absolutely necessary, but by reading through it you'll come across lots of cool features you might not have otherwise realized were there.
I had a patch accepted to Win32 emacs in late 2013 (before the move to git), and I used a git mirror for the whole thing. It didn't seem to be a problem - I used git to make a patch against what was then the git head, mentioned this was the case, and... that was that. Assuming the mirror is no more than a day or two behind, a patch against its head will likely apply cleanly to the head of the main repo.
I was sceptical then - https://news.ycombinator.com/item?id=8603853 ;) - and I remain sceptical now. A move to git may well represent an improvement in workflow for regular maintainers, but I don't believe it will do a thing in terms of encouraging people to contribute.
Encouraging people to contribute is not a version control problem, and turning a random one-off patch into something that can be added to a long-running project is not a version control problem. I'm not sure why people think that changing version control will make a difference here.
(N.B. - one thing I do not dispute is that bzr is unusual - the whole reason I used the git mirror in the first place was because I don't know how to use bzr ;) I kept up with it for a while, but after the 3rd or 4th time of forgetting what the hell I needed to do to keep it up to date (since I rebuild emacs maybe every 2-3 months) I switched to using the git mirror instead. But I am not sure the solution to this is to abandon bzr entirely, when there's the other option, of simply doing a better job of publicising the git mirror!
(Still, it's done, and, as you might guess from the previous paragraph, I have no objection. I'm just not convinced that it will have the effect people think.)
> Seems that C-x is used in half the keybindings - remapping them all ain't possible.
:-) You don't need to rebind each and every key, individually. Just rebind entire 'ctl-x-map' keymap to some other map. Test this in your Emacs, press M-: and then type:
(define-key global-map (kbd "s-x") ctl-x-map)
You can now press S-x (winkey + s) just as if you used C-x. For example S-x C-f will open find-file (C-x C-f).
observer that there are more keymaps that we usually see as C-x ... but there are own keymaps: ctl-x-4-map ctl-x-5-map, etc. If you use completion framework like Helm, you can type: M-: ctl-x- TAB and see all keymaps used for ctrl key.
You might wish to look up on keymaps in manual if you are interested in writing some code to auto-rebind all ctl-x-* maps to something else.
>Where is a good guide/tutorial about customizing emacs and writing elisp? I am working my way through info on emacs and know that this is probably in there somewhere, but is there some other resource?
Here is a Steve Yegge post about organizing your emacs customizations.
Be sure to check out Glickstein's 'Writing GNU Emacs Extensions' . Though the book was published over 15 years ago, it is still applicable and a great way to get your feet wet in customization and elisp!
Yeah, I searched the manual for just " computer algebra system " and didn't find anything so I assumed it wasn't. When I was reading through the manual properly, I found more about what I was looking for, and https://www.gnu.org/software/emacs/manual/html_mono/calc.html#Language-Modes was pretty much what I was looking for.
I always thought Emacs Calc was just a simple rpn calc, I never realized just how crazy powerful it is. Its crazy how this powerful of a calculator is builtin to a text editor of all things
For now I'm messing around and learning `M-x calc`, and I also have maxima.el setup for something I'm a tad bit more comfortable with.
In general, no. Emacs doesn't support concurrency and this has been a recurring source of annoyance for many things. That said, depending on your use-case it might be possible to perform asynchronous actions, such as spawning a shell process:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Asynchronous-Processes.html
Another possibility, but also very limited: