As far as I know you cannot tell Emacs to re-start after terminating, but you can set the exit code so that the process that started Emacs in the first place can detect that you want to re-start.
For example, this shell script re-starts Emacs if it exited with the code 123.
while emacs -nw "$@"; [ $? = 123 ]; do :; done
Next, we define kill-...
Note: I have wrapped the following in a package restart-emacs available here.
Here is an alternate way to achieve what you want using pure elisp (not really since you rely on a shell). The trick is to spawn off another emacs process just before current emacs is killed.
(defun launch-separate-emacs-in-terminal ()
(suspend-emacs "fg ; emacs -nw"))
Emacs predates GNU Emacs and thus predates Emacs Lisp.
In most of the 80s, Emacs was only what we now call terminal-mode (and only one frame), and there was no mouse, menu-bar, tool-bar, fringe, faces, color, or Customize.
The rest looked and acted about the same as now (for terminal mode). Help mode (e.g. C-h f) was essentially the same, but with no Back ...
Use display-graphic-p to determine if Emacs is in a GUI or not.
Assuming solarized is installed and loaded:
See also: Is there a way to detect that emacs is running in a terminal?
You will be more comfortable in an X11 Emacs, which can receive keyboard input and display text without going through encoding and decoding for the terminal. The main reason to use a text mode editor is to run it inside screen or tmux on a remote machine, but thanks to Tramp, it's usually easier to edit the remote file in your local Emacs. That being said, ...
You can use display-graphic-p to determine if you are running in a terminal or a windowing system.
For example, you could do your setup so that you only add those keybindings and theme if you know you're on a window system.
;; Do any keybindings and theme setup here
You can also do the reverse, and turn off your ...
A text terminal transmits only characters (more precisely, bytes), not keys. Keys and keychords (keys with modifiers) are encoded as character sequences. Keys that insert printable characters are sent as themselves; function keys are sent as escape sequences. Most escape sequences consist of the character Escape (?\e in Emacs syntax) followed by two or more ...
This is a setting in Terminal.
In Terminal 2.5.1 the option is set differently than in the above comments:
In the main Terminal menu, choose "Preferences" to open a dialog. Click the "Profiles" icon in the top of the dialog.
In the Profiles section, make sure there is a check in the checkbox called "Use Option as Meta key."
If you can't use a particular key combination because of your terminal, you can often fake it by manually simulating the key modifier. The following combinations work exactly as though you had used the corresponding modifier key:
C-x @ a alt
C-x @ m meta
C-x @ c control
C-x @ h hyper
C-x @ s super (lowercase s)
C-x @ S shift (...
There are a few answers here.
Quitting Emacs without C-x C-c
First, you can quit emacs by running the command that C-x C-c is bound to: M-x save-buffers-kill-terminal.
Alternatives to recursive Emacs
Emacs is able to edit files on remote servers, so you don't even need to ssh into the remote server, and you won't need an Emacs inside a term inside your ...
This project is a good alternative: https://github.com/m2ym/yascroll-el because it works with and without GUI.
Don't forget the cl require in your .emacs
(require 'cl) ;; build-in librairie
Some packages managers provides two different Emacs, emacs and emacs-nox. The core is the same and behave in a very similar way. The nox version (no X means without X11 support) and should be installed on systems that don't provide a X Window System.
These nox versions are compiled without support of X11. The standalone version can be run in the terminal ...
The function display-graphic-p returns nil for non-GUI Emacs. So something like the following should work:
My original answer only works for Emacs run only in a tty. Since you are using both GUI and TTY frames run from the same server, you need to modify individual frame parameters:
If you're intent on using the mouse, you can use a subset of mouse click functionality if your terminal is compatible with xterm. To do so, enable xterm-mouse-mode.
Source: manual page on "Using a Mouse in Text Terminals".
However, as @Ista's answer and @lawlist's comment suggest, you can use the keyboard to access the menu bar. That's probably a better ...
You can use the external utilities xsel or xclip (they have mostly the same features, I'll use xsel in this answer) to copy data from or to the X clipboard. To copy to the clipboard, pass the desired content on standard input. When pasting from the clipboard, the content is written to standard output.
To copy the selection to the X clipboard, use M-| xsel -...
You can't copy-paste between Emacs and a shell without using a system-wide copy-paste facility. Text terminals in general do not provide a copy-paste facility.
It seems that you're running this terminal Emacs in a terminal window in a window environment. Window environments do provide copy-paste; that's what happens when you use the mouse. However, this ...
I believe that the @ symbols in your terminfo example are part of the Texinfo markup, rather than part of the terminfo code. Your terminfo entry should look like:
# Use colon separators.
xterm-24bit|xterm with 24-bit direct color mode,
In emacs, the region is delimited by the point (cursor) and the mark (some previous position of the cursor, which has been "marked").
Thus, to "select a region", you need to place that mark, then move your point around.
The easiest way to place the mark is to press C-SPC. Then just move the cursor around, you'll see the "region" extend as you do.
Use ;; (or more) instead of ; and this won't happen.
What you're seeing is (in conjunction with electric-indent-mode) expected behaviour, as by convention
Comments that start with a single semicolon, ‘;’, should all be aligned to the same column on the right of the source code. Such comments usually explain how the code on that line does its job.
In general, a terminal application like emacs -nw has only very limited information about what colors are available. The shell will have an environment variable called TERM which contains the name of the terminal you're using. The application can then use a library such as terminfo to pick the right escape sequences to use each feature of the terminal. This ...
If mouse reporting is on, then Shift+click is still interpreted by the terminal and not passed to the application. Thus, if a right-click pastes outside Emacs, and a straight right-click is passed through to Emacs, then Shift+right-click should paste in Emacs.
Passthrough of Shift+click can be disabled, check that it's enabled.
This applies to PuTTY and ...
My crystal ball said you should remove
(global-set-key (kbd "M-[") 'previous-multiframe-window)
from your ~/.emacs. You might like to M-x report-emacs-bug and ask for global-set-key to complain when the key sequence conflicts with something in input-decode-map (as is the case here, because the byte sequence ESC [ (which corresponds to the M-[ event) is ...
In addition to offby1's answer (which is what you were asking for) also take note of:
https://www.emacswiki.org/emacs/CategorySql which covers sql-mode and sql-interactive-mode in general.
https://www.emacswiki.org/emacs/SqlQueryBuffer which has some tips on linking a sql-mode buffer to a sql-interactive-mode buffer (which is the super-useful feature it ...
You can use the syntax coloring outside Emacs, two working examples are htmlize for the web and e2ansi for the terminal. For your need, you can use e2ansi-cat provided by e2ansi, here is a screenshot of it:
By the way, if you use Eshell, you can easily get the syntax coloring:
(defun eshell/cat-with-syntax-highlight (filename)
(let ((existing-buffer (get-...
Here's a generic solution to eval some elisp expression after launching emacs
For your example, that will be
emacs -nw --eval="(goto-line 20)" FILE
Also check out the --load option from the below referenced link if you want to load an elisp file instead of writing elisp at command line.
Solution specific for ...