How to configure/customize emacs? (key bindings, windows nav bar, etc) [closed] - emacs

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
OLD QUESTION: How To Kill Characters Before The Cursor in Emacs?
OLD COMMENTS: According to a reference, it should simply be the delete key, but the delete key as well as the C-d commands kill the character AFTER the cursor
EDITTED
I am running emacs via cli. Which file do I edit and how do I change key bindings for commands?
As for the nav/window bar, I was reading a link and here is a code snippet in it:
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a "
What does the last line mean? How do I even begin to read it? What language is it written in?
I appreciate all responses!

The default configuration file for emacs is the ~/.emacs file. This file will be loaded and executed everytime you start emacs. You can check which file is used by running M-x describe-variable RET user-init-file. If the file does not exist you can simply create it.
To bind commands to keys you can use the global-set-key function. The following will bind control+h to the "backspace" command (put the following in the init file).
(global-set-key (kbd “C-h”) ‘backward-delete-char)
As for you code snippet it is not related to emacs, but seems to have to do with GNU Screen. See http://www.debian-administration.org/articles/560

Backspace? I.e. the key above Return. There's more detailed advice here:
http://www.emacswiki.org/emacs/BackspaceKey

Related

How do I minimize the use of same-hand keyboard fingering? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have been trying to rid myself of the bad habit of key-chording in Emacs using only one hand. That is, for C-x I want to use my right pinky to hit the right-Ctrl and a left-hand finger to hit x. My question is how do I type efficiently in all caps? For example, when I type an environment variable such as RAILS_ENV=test it's very tedious to switch between left and right hands holding Shift every time the key falls on the opposite side of the keyboard. It would seem that this is an ideal case for using CapsLk, but I've long remapped that key to Ctrl because of the scarcity of its use and potential for accidental triggering.
I found this related question but it deals more with enforcing the habit than the question of how to actually type efficiently using the opposite hand to hit modifier keys.
As the question appears to be targeted towards bash command lines, you can use Control-A Meta-U to capitalize the first word of the line, useful for typing
env_var=value some_command ...
prior to converting it to
ENV_VAR=value some_command ...
Instead of making CAPS LOCK an additional CTRL, you could simply swap CAPS LOCK and LEFT CTRL.

Unformatting LaTeX code with Emacs & AUCTeX [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Emacs + AUCTeX provides all sort of commands for formatting text, but I can't find a way to "unformat" a snippet of code (unless undoing the change right after having run a formatting command).
For example, suppose you have the following snippet with LaTeX formatting
foo \whatever{bar} quux
I'd like to remove the \whatever{} wrapper by selecting the relevant text, or by placing the cursor at its beginning/end, and using a key combination to get
foo bar quux

emacs forward and back keys [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Am i unusual or are the emacs forward and back keys the wrong way round?
I constantly hit C-b for forward and C-f for backward because b is forward of f and f is back of b as laid out on the (qwerty) keyboard (at least thats my logic)
C-n and C-p cause no such problems as they are intuitively the right way round, e.g. p is 'up' from n
likewise with C-a and C-e
its nice to have the letter mean something, e.g. f for forward and b for back but my brain prefers actual position over the right initial
does anyone else have this issue?
as an aside how do dvorak users cope?
should i swap the key bindings round or does that way madness lie?
(possibly part of the problem is I have only just started weaning myself of the arrow keys using no-easy-keys.el)
If you are willing to move away from the defaults, you may want to check out Xah Lee's ErgoEmacs bindings.
http://ergoemacs.org/emacs/ergonomic_emacs_keybinding.html
Let me answer quickly before the famed SO content nazis delet your question as too open-ended. Emacs keybinding on standard 104 key PC keyboard is a disaster. I personally never confused C-f and C-b, but I did get strained pinkies from pressing Ctrl all the time until I redefined Caps Lock as Ctrl. Since then, by miracle, Emacs became the most comfortable piece of software on my machine. But back to your original question, I think I never had problems confusing C-b because it's simply hard to reach. Nevertheless, as much as I love Emacs, I must admit that vi rocks for using h, j, k, l keys for, respectively, back, down, up, and forward. I've heard there was a plugin named 'vile' for Emacs, but I never tried it. That might be of help to you.

How to customize emacs auc-tex function Tex-command-list? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to use the latex package `nomencl' which allows one to easily create a Nomenclature section in an article. So far so good.
I'm using emacs with AucTeX and I added the nomenclature compile option to the emacs Tex-Command-list by editing my .emacs file, adding:
;;nomenclature for latex
(eval-after-load "tex"
'(add-to-list 'TeX-command-list
'("Nomenclature" "makeindex %s.nlo -s nomencl.ist -o %s.nls" TeX-run-command nil t :help "Create nomenclature file")))
to it, this works: when I press C-c C-c (the shortcut for TeX-command-list I can use the Nomenclature command and the appropriate file is generated. I am unhappy though, for the following reason:
When I run BibTex (using Tex-Command-list), and then press C-c C-c again, emacs offers to run LaTeX, as appropriate, and if references have changed, it will offer LaTeX again, finally, it will offer View, once the .log doesn't report references have changed.
However When I run Nomenclature, the next command offered by Tex-command-list is View, which is alway inappropriate, since one needs to compile again after recreating the nomenclature file.
How can I tell emacs to give LaTeX as the next TeX-command-list command after running Nomenclature (same behavior as BibTeX)?
The AUCTeX function TeX-command-query is responsible for that. Right now, it simply checks for the existence of .bbl, .pdf, .ps, .dvi files and guesses the next step. If Nomenclature also generates some new files that, when present determine that TeX must be run again, it should be easy to add that feature.
Update: The answer on TeX SE is even better. :-)

What to teach a beginner in Emacs? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
If you had a 10 minute hands-on session to teach someone Emacs, what would you show them?
Start emacs: emacs
...
Quit emacs: C-x C-c
What else would you have them do between starting and quitting Emacs, while you stood behind them?
If I had only 10 minutes, I would not teach them any shortcuts at all. All the common shortcuts are available next to the corresponding commands in the menus; those the users can discover for themselves.
The most important things to teach are those that will enable the users to discover/learn by themselves:
That one can quit Emacs with C-x C-c, or File->Quit. When stuck, one should type C-g, and, if that doesn't work, ESC ESC ESC. [This is probably the single most useful advice to prevent total frustration with Emacs, trust me.]
The tutorial: Help->Emacs Tutorial, or C-h t. [This is not a terribly useful shortcut to remember; given how few times one reads the tutorial over the course of one's life...]
The concept that every keystroke in Emacs is bound to a function, and all that Emacs does is execute functions one after another. That there are more functions than can possibly be bound to keys, and functions without a keystroke can be invoked with M-x function-name.
That one can discover what function a particular key invokes with C-h k [keystroke]. Make the user walk through a few of those (including the amusing fact that typing a letter is not special and just invokes self-insert-command, so if one wanted, one could bind the letter 'z' to send email instead :D)
That one can search for possibly useful functions with C-h a (or M-x apropos-command), e.g. C-h a paragraph shows all the commands to do with paragraphs, including what shortcuts will take one to the end/beginning of a paragraph. And that C-h w command-name will tell you if the command is bound to some keystroke or not. [Make them walk through this to discover what the key for undo is -- usually they'll try C-z and it does something annoying :)]
That you can read detailed documentation about what a function does with M-x describe-function (C-h f). That Emacs has great documentation about most things; and M-x apropos-documentation (C-h d) is a great way of discovering stuff.
That one's settings are stored in .emacs, and that one can glean some things by looking at that file even if one don't understand Emacs Lisp.
That one can usually find all keystrokes that "complete" a particular set of keys by typing C-h after it, e.g. 'C-x C-h' will show all the shortcuts starting with C-x; C-h C-h is particularly useful; C-c C-h is useful for mode-specific commands such as when in java-mode or c++-mode or LaTeX-mode, etc. (Hmm, "modes"...)
That when stuck, one can search on http://www.emacswiki.org/. (Or ask a question in the #emacs IRC channel on Freenode, or post to gnu.emacs.help.)
This should fit in 10 minutes, and it's the most important stuff, I think. I wouldn't overload with too many shortcuts to remember; that's pointless anyway -- if the users know how to discover shortcuts, they'll find out shortcuts for whatever they use most frequently. Do have them write down the names of these commands, though, and also about Emacswiki etc.
The important thing is to show them how powerful Emacs is and how universal its model is (all those jokes about it being an operating system are not just jokes). If you just show a bunch of arcane shortcuts to do things they can already do in other editors, Emacs won't seem worth all the trouble. In the same spirit, I also wholly support Anton Nazarov's answer of showing them what Emacs can do (AucTeX if they use LaTeX, etc.) for their specific purposes. Then they can judge for themselves whether Emacs is worth learning, and learn using all the above.
Show them how to start the tutorial: C-h t
C-x M-c M-butterfly
I'd show the most important for that novice user mode.
For example, when I show Emacs to my friends at the faculty of physics, I show them AucTeX with preview-latex and RefTeX. Also iMaxima is great.
If I have to show Emacs to software developers I show them something like JDEE or Python mode with Ropemacs.
Tetris, tramp and w3m can be used to give the idea that Emacs can do everything :)
Then I'd show how to start the tutorial and give link to EmacsWiki.org
i think you show him how
to open and save files
to kill/switch buffers
to switch/kill/split windows
to select a range.
And tell him about M-x . Tell him he write those steps down somewhere. I think basic navigation can be done using arrow keys. Now this is all he needs.
If he knows about M-x , he can easily find search, replace and other stuff.
When giving emacs examples it's never enough to only give the key binding since that can and does vary. C-x M-c is undefined on my system.
When I start XEmacas, until I press a key it alternates between two screens. One of them has the following:
XEmacs 21.4 (patch 21) "Educational Television" (cygwin, Mule) of Tue Dec 4 2007 on vzell-de
`C-' means the control key,`M-' means the meta key
Information, on-line help:
XEmacs comes with plenty of documentation...
M-? F: read the XEmacs FAQ (a capital F!)
M-? t: read the XEmacs tutorial (also available through the Help menu)
f1: get help on using XEmacs (also available through the Help menu)
M-? i: read the on-line documentation
M-x describe-project: read about the GNU project
M-x about-xemacs: see who's developing XEmacs
I would ask that someone to read it out aloud, make sure they understand what it says and then give them, to use in case of emergency, my cell-phone number and a first-aid kit.
I would show the shortcuts for the most common operations such as:
Save: ctrl-x-s
Save as: ctrl-x-w
Open/find file: Ctrl-f
Undo: ctrl-_
Kill buffer: ctrl-x-k
Switch to buffer: ctrl-b
Fill paragraph: M-q
And copy/cut and paste:
Set marker: ctrl-space
Cut: ctrl-w
Copy: M-w
Cut line: ctrl-k
Paste: ctrl-y
Open a file,
Save a file,
Basic navigation,
Set mark, copy, cut and paste,
Show undo and kill ring,
Show C-g,
Show search and replace,
Split window and move to other window,
Switch to other buffers,
Show Tutorial,
Explain Info,
Show dired to:
open some file,
run a command to compress another file,
open, edit and save the compressed file,
open a directory on a remote host,
open & save some file on the remote host,
copy some file from the remote host.
Open a shell and run some long output command and navigate in the buffer.
Learn to use help C-h C-h
Do the tutorial exercice.
Kill something, and another thing, and a third one, then C-y to yank it, and M-y to cycle the kill ring. Big "Woah" factor, quick and cheap. Then tell them it works in their daily shell.
Navigate in the buffer with the mark ring. C-u C-SPC (space) takes you to where you were before and, repeated, cycles though the 16 last positions, regardless of edit state.
You know when you sheepishly undo things just to get "where you were before" ? There you go.
This is a killer emacs ninja trick. Everybody should know it ASAP.
I think the first thing to ask before trying to teach them something is "what do they want to get out of learning Emacs?" AND, are you trying to sell them on the idea of learning Emacs or are they already committed.
If they are a programmer and are looking for a new development environment, show them ECB, how tags work, etc? If they are looking for a general text editor, show them M-x re-builder. If they are looking to write documents quickly and publish them eventually, show them org-mode with HTML and LaTeX exports.
Besides what had been mentioned already I would also show them M-x global-set-key after having showed M-x in general and M-x apropos.
I would tell them that the point of Emacs is that it is infinitely customizable and that one should personalize it to suit one's preferences. I would tell them to try out the standard key bindings first and the advantages of them showing up in Bash, OS X, etc.
C-g
Copy paste
Split Windows
M-x
Apropos
Describe Key
Describe Command
Open files
Switch Buffers
The language-specific development environment, including the debugger and the REPL.