I don't know that Emacs is more efficient the way I use it, but maybe that's just me.
If you're a programmer then you should stop thinking of Emacs as a text editor, and start thinking of it as a Lisp interpreter bundled with many useful functions for text processing. It isn't hard to get started:
If your system can't handle it here are some light alternatives you can try:
https://www.gnu.org/software/emacs/emacs.html
Best to run in terminal mode because if your system is struggling that much then a windowing system might also "explode" your memory usage.
+1000. The number of times I respond to MELPA submissions with a link to the elisp coding conventions is just ridiculous.
The site should be improved because it's often the first destination people go to in order to learn more about Vim. The current design can give a bad (definitely out-dated) impression. If the site were more clear and less abrasive, it would likely persuade more people to use Vim than it does currently.
I know that I thought somewhat less of Vim purely based on the site when I first saw it. Look at the beautiful official page for Emacs (I believe it was updated a couple years ago now), by comparison.
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.
Just to mention for people unfamiliar with lisp or scheme, the ;
/;;
/;;;
/;;;;
thing in lisp+scheme is a common convention for different kinds of comment, not some syntax requirement, see e.g. emacs lisp manual.
Emacs has 3 good editors:
Indeed!
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
.
Expanding on the Emacs Downloads page:
Open an msys2-mingw64 bash prompt
pacman -S mingw-w64-x86_64-emacs
Packages with names prefaced with mingw-w64-
are packages that are targeting the mingw/windows environment. The emacs you install this way will recognize windows paths like c:\users\
but will also have access to grep
and other unix utilities you install on msys. Packages without such preface are native packages and will need to use unixy paths like /c/users/
.
One thing I've noticed is Ctrl+Z doesn't background apps properly. I made an alias emacs='emacs & disown'
so that it doesn't consume a terminal window.
There is also an msys2 portable, but I don't think that's necessary. I'm pretty sure msys2 doesn't require admin rights, but it might touch the registry. Proper portable apps should run entirely from external media without leaving a trace.
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.
The Emacs manual (https://www.gnu.org/software/emacs/manual/html_node/eintr/Strange-Names.html#Strange-Names) has this to say about it:
> The origins of the names for car and cdr, on the other hand, are esoteric: car is an acronym from the phrase “Contents of the Address part of the Register”; and cdr (pronounced “could-er”) is an acronym from the phrase “Contents of the Decrement part of the Register”.
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
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
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.
Emacs is most commonly used for pretty much anything that can be represented with text. So that does mean coding.
But it can also mean making TODO lists, or writing Reddit comments, or making ASCII art. You can take notes in Emacs. You can write love letters in Emacs. You can manage files in Emacs. You can write guitar music in Emacs. You can play 2048 in Emacs^(1). You can spellcheck your documents in Emacs. You can do math in Emacs.
So generally, if you're working with text, using Emacs can be a way to get powerful, customizable features for reading, creating, and editing it.
[1] Disclosure: this is my project. There are many like it, but this one is mine.
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.
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!
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.
Define "needs". No one needs 99.999999999% of Emacs features perhaps. So what?
Menus are an excellent aid to discovery.
Especially for Emacs, because of completion. For that, La Carte can really help.
La Carte is all the more powerful if you use a completion framework that allows substring or regexp completion (Icicles is one example of such a framework). You can easily see and explore full menu trees and access their parts directly - no need to drill down one branch incrementally.
But even the built-in <F10>
binding, menu-bar-open
is helpful, letting you use the keyboard instead of a mouse. See the Emacs manual, node Menu Bar.
On the other hand, many of the menu-bar menus in Emacs are lacking. Not enough Emacs library authors care about providing (helpful) menus. That's too bad - all the more so because Emacs, in particular, gives you great ways to use menus. You can't take advantage of this if menus are lacking.
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.)
There's a long tradition dating back to when the government mass-scanning email was more of a joke about paranoia than a plausibility. The emacs M-x spook command has, since the 1980s, been available to append a random collection of scary words to emails in the hopes of confuzzling the NSA.
(When upholding this tradition you might want to omit the threats of violence, though, as the FBI are probably feeling overworked and underpaid these days.)
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:
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.
> When an error is signaled, signal searches for an active handler for the error. A handler is a sequence of Lisp expressions designated to be executed if an error happens in part of the Lisp program. If the error has an applicable handler, the handler is executed, and control resumes following the handler.
I'm not really sure how much better or even different that is.
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.
As you're probably getting from the other responses, there really is no one equivalent. Instead, Emacs has several kinds of "go back" commands, and your choice depends on what you want to do. There's also no universal "go forward" that I know of. I really wish there were.
The closest we've got is the mark ring. Whenever the mark is moved, its old location is pushed onto the mark ring. You can move back to the mark and pop the mark ring by pressing C-u C-SPC
. There are two ways this is helpful:
If you want to remember your spot and come back to it, you can C-SPC C-SPC
(set the mark and activate the region, then deactivate the region), go somewhere else, and C-u C-SPC
to return.
Most big jumpy commands set the mark to where you came from for you. For instance, if you press Home
, you'll jump to the top of the file, and you'll also see "Mark set" in the message area. C-u C-SPC
will then take you back to where you came from. And since it's a ring, you can keep pressing it to go back further.
But this ring is only for marks in the current buffer. There is a separate ring into which mark positions are also pushed from every buffer, the global mark ring. To pop it, use C-x C-SPC
. But remember that it functions independently of each buffer's own mark ring.
As I said, there's no "forward" equivalent that I know of, but because it's a ring, the marks aren't really popped off so much as rotated: the information is still in there. That means that a custom command can implement "go forward". I haven't tried any of these yet myself, but this Stack Overflow question has a few options to try.
The heavily configurable part should lead you to believe that you can have syntax highlighting, and yes it does have it. Also Emacs is updated once a year
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.
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
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)
Well, "CLI" and "terminal" aren't quite the same thing, if we're being strict about it. I'll give answers for the terminal.
I use emacs, and use its org-mode's agenda feature to provide a list of upcoming things to do, which, like the emacs calendar, can be set up to feed off emacs's own diary entries to generate deadlines. I'm sure that I don't use more than a small chunk of its features, but it works well enough for to-do lists and not forgetting about appointments. If you use emacs, I'd strongly recommend looking into this. If you don't, picking up emacs just for that might be a bit overkill...
Someone else also mentioned it, but I used to use remind
, and the ncurses frontend wyrd
. The syntax for remind
is a bit annoying to me -- remind
was really originally intended to "pop up notice at time X", and some of the syntax still derives from that -- but it works.
A friend was also recently looking at this, and taskwarrior
came up numerous times, but I have not used it.
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.https://www.gnu.org/software/emacs/manual/html_node/emacs/Yanking.html
When you kill (cut) a text, the piece of text is inserted into a stack (the kill ring). When you yank (paste), by default it will insert the piece that you last kill, but you can tell it to yank any of the pieces that you recently killed.
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"))
The built in Emacs tutorial is a good place to start. When you start Emacs for the first time the cursor (or 'point') is already on the tutorial so all you have to do is press enter. Another thing you can check out is the Emacs Mini Manual which is pretty nifty.
For learning Elisp An Introduction to Programming in Emacs Lisp (also available in Emacs with C-h i m 'elisp') seems to be a good place to start, although I always found it a bit too slow for people who can already program.
A general tip: I would recommend holding off on customizing Emacs too much. And instead focus more on getting used to how things work in Emacs.
Edit: you also asked about whether to use Emacs or Vim. Too much has already been written about that. Maybe learn the basics of both, and then choose one based on that. I think they're both pretty amazing editors when used by people who know how to use them.
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.
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).
I had to read your comment three times because my brain refused to process that you weren’t referring to Eww the web browser, which also happens to be written in a Lisp dialect. But you already knew that.
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.
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.
> 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.
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:
The OP might find some more detail helpful. :-)
C-h i
will bring up a list of Info manuals; two that you might find useful in this context are "Emacs Lisp Intro" and "Elisp", the latter being the Emacs Lisp Reference Manual.
I am not a python user myself but AFAIK pyls is slower than Anaconda(I do not know how much).
Can you open a PR in lsp-mode and provide the profile data (https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html) and eventually test with lsp-ui mode turned off?
i'm not that familiar with Python decorators, but from what i can tell, their equivalent in Emacs Lisp (which, note, is not the same as Common Lisp) would be advice.
Use(current-local-map)
.
From the manual
> — Command: local-set-key key binding > This function sets the binding of key in the current local keymap to binding. > > (local-set-key key binding) > == > (define-key (current-local-map) key binding)
You can bind it to the ignore
command, which does nothing:
(global-set-key (kbd "<f2>") 'ignore)
That's not what you're really wanting though. Ideally you'd probably tell your window manager to swallow that key completely so that Emacs never saw it in the first place; however Emacs does have a way of almost completely ignoring an event, via the special-event-map
keymap.
(define-key special-event-map (kbd "<f2>") 'ignore)
See https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Events.html
Support for cooperative threads has been implemented in Emacs 26.
https://www.gnu.org/software/emacs/draft/manual/html_node/elisp/Threads.html
Perhaps the recent thread https://www.reddit.com/r/emacs/comments/8e85x7/are_there_any_forks_of_emacs_with_multi_threading/ is also helpful to you.
>(setq initial-buffer-choice (lambda () (switch-to-buffer "*dashboard*")))
I think that correct solution is:
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
i.e. get-buffer should be used instead of switch-to-buffer. As per Emacs docs the function should return a buffer and not switch to it (Emacs does that for you). Quote from the docs: if it is a function, it calls the function with no arguments and selects the buffer that it returns. (https://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html)
Emacs already has a built-in parser framework, and you can write a LALR grammar file. You can look at the architecture overview of Semantic: https://www.gnu.org/software/emacs/manual/html_mono/semantic.html#Introduction and see an example grammar file. From the grammar file, Semantic parses into a grammar structure, and provides APIs for accessing such structure. If you don't like using the built-in grammar, you can even use external parser, parse and generate compatible structures that can be used by Semantic for its various apps. Yet, it is little used because writing a proper parser is tedious, even for writing in a specialized language for language grammars.
Emacs already uses external parsers for various languages in many packages, as you arelady know. Someone already did the heavy work, not leaving you to do it from scratch. Adding syntax highlighting should be easy, but no one bothers because syntax highlighting is usually good enough, and for many people, not that important.
It's actually really simple!
It's as simple as
C-x C-f user@host:/path/to/file (and after a second to connect to the server you will get autocomplete options).
This uses the Tramp package, which is installed by default. It may require some additional setup on Windows.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Moving-by-Defuns.html#Moving-by-Defuns
In M-x c-mode
, these bindings seem to do what you want.
C-M-a
runs the command c-beginning-of-defun
C-M-e
runs the command c-end-of-defun
Your system may have other functions bound to C-M
keys (mine does), so remember that Emacs treats Esc
and C-[
as synonyms for Meta
.
Also worth reading :
https://www.gnu.org/software/emacs/manual/html_node/emacs/Motion-in-C.html#Motion-in-C
foo1
does not take an argument. It always moves forward 2 words, as you can see from the hard-coded 2
.
foo2
takes an argument, n
. It moves forward (* 2 n)
words. If n
is 2, it moves forward 4 words. If n
is -1
, it moves backward 2 words.
The (interactive ...)
form indicates that these functions are commands, i.e. can be invoked with execute-extended-command
(M-x
).
The "p"
is an interactive code for a prefix argument.
See more in the Introduction to Emacs Lisp manual.
Apparently you were downvoted as well, again without explanation. I'm curious as to the reasons, too.
My guess is that it has to do with ideological differences between OpenBSD and, say, the FSF when it comes to how they define "free". It's interesting that LibreBSD wants to shoot for something that could be the first FSF-approved BSD, though whether it's a real step forward is debatable (I'm pretty sure the FSF will come up with some new contrived reason for rejecting a BSD from their approved OS list, and said reason will probably have to do with copyleft v. the lack thereof, but hey, worth a shot, right?). There's an increasingly-long history of contention between the GNU and BSD camps over that exact subject among others, including ideological debates over whether including support for non-free software in a collection of free compilation/install scripts (what pretty much all BSDs do in their ports trees) constitutes "endorsing non-free software" while distributing Windows ports for software (what the FSF does under the GNU banner in some cases, like with Emacs) is for some reason all hunky-dory.
Needless to say, the downvotes are quite possibly a knee-jerk reaction to the idea that OpenBSD needs to conform to the FSF's hypocritical definition of "free" in order to be considered "free". Or perhaps there's something wrong with the project itself (I'm not seeing anything of particular egregiousness at first glance, but perhaps I'm just not observant). Or maybe it's because the official download link seems to be broken (or maybe just really slow), or that it only supports two architectures out of the dozens that upstream OpenBSD supports. Or perhaps people just like pufferfish. Whatever the case, I, too, am interested in the actual reasons so that I don't have to speculate.
Without knowing what language you are talking about (since I don't think you mentioned?), I would recommend helm-semantic-or-imenu
and using semantic for pulling out the info. For example, here's what it looks like in Java for me:
> Nobody uses type hinting for primitives in PHP because it's not a feature of PHP. Nor is it in other dynamic languages, like Ruby, Python, or JavaScript.
Not quite true; LISP.
LISP has some nice features WRT handling types. (Type-predicates, type specifiers, and the exception system)
For diff mode, I'll often revert individual hunks while working on a source-controlled file. Hit C-x v =
on a version-controlled file to get vc-diff output, and then hit C-c C-r
to reverse the patch, and then hit C-c C-a
to interactively apply particular hunks.
I'll use same as a quick index of modifications, with hitting Enter to jump to the change in question.
Both are much more usable than a command-line diff invocation.
Works on a terminal, unlike something like meld. ediff can show what chunks of a line have changed. You can single-key scroll the buffers that you're working on around together, left/right/up-down. When edifffing, you can go and edit the buffers on the fly; it's convenient if you're trying to construct a new file with bits of it and another file and need to make changes as well. I have all the regular emacs editing facilities available.
I guess I don't use much by way of ediff-specific functionality. I don't use it, but you can skip hunks based on regex, and looks like there's a bunch of shortcuts and region-editing commands that I've never picked up.
I recommend running Emacs as a server / Daemon. Basically then you keep emacs initialized and ready to go in the background, so when you call
emacsclient
or something similar, it'll 'start' very fast. The biggest reason emacssen tend to start slow is because they're usually parsing an extensive init.el (as you get further into emacs, it'll just keep growing and growing). Running it as a deamon / server will ensure you're not reinitializing emacs every time, and thus skip that delay.
It also has the advantage of sharing command history between buffers. See here for more information.
Alternatively, and less recommended, you can compile your .el files. This can result in errors and make debugging them more difficult, but it can also speed up your emacs instance.
Drop a .dir-locals.el
into the top-level directory of your work projects to change these variables. You can use M-x add-dir-local-variable
to create such a file. See Per-Directory Local Variables in the Emacs manual.
Programming is a very broad topic with many sub-fields.
I recommend pursuing programming skills that have good synergies with your other skills. I don't know what exactly you are choosing to study/pursue in the fields of English and History, nor what is motivating you to study them. Take my advice below with a grain of salt.
I am assuming that you will probably be interested in natural language processing as a sub-field of programming. It can be useful for analyzing and characterizing a body of language. That body of language might be a historical record, a sample of literature, or a collection of letters between historical persons of interest.
Python also has language processing libraries that might be useful to you.
I recommend learning Emacs before LISP, and Python before its NLP-specific libraries.
Learning Emacs will make you proficient in one of the most powerful development environments ever created. Once you know how to use Emacs, you can use community-made templates, modes, and key-bindings to help get you started with any other programming language.
Note: I personally prefer vim over emacs, but I also prefer stem over the humanities. :)
Are you familiar with Emacs' server mode? If you have a running emacs server, you can create new frames with the emacsclient
command. Indeed, this is how I use emacs.