32

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. #!/bin/sh while emacs -nw "$@"; [ $? = 123 ]; do :; done Next, we define kill-...


25

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")) (defun ...


24

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 ...


22

Use display-graphic-p to determine if Emacs is in a GUI or not. Assuming solarized is installed and loaded: (if (display-graphic-p) (enable-theme 'solarized) (enable-theme 'wheatgrass)) See also: Is there a way to detect that emacs is running in a terminal?


21

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, ...


15

Evaluate the following using eval-expression (M-:) or in a scratch buffer: (describe-key (kbd "C-<whatever>"))


13

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. (when (display-graphic-p) ;; Do any keybindings and theme setup here ) You can also do the reverse, and turn off your ...


13

I don't think the mouse really works when running in the terminal, so you cannot actually click. But to open the menus press F10 (or fn-F10 depending on your keyboard settings).


13

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."


13

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 ...


11

Emacs has in-built support for many databases, including Postgres. M-x sql-postgres RET


9

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 (...


9

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 ...


8

The function display-graphic-p returns nil for non-GUI Emacs. So something like the following should work: (unless (display-graphic-p) (menu-bar-mode -1)) EDIT 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: (defun ...


8

Turns out this was a problem with gnome-terminal. I fixed it by opening the profile preferences from the gnome-terminal menu bar, selecting colours, and changing the built-in scheme to Linux console.


7

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 (require 'yascroll) (global-yascroll-bar-mode)


7

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 ...


7

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 ...


6

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 ...


6

I solve the problem with answer of ohruunuruus. Maybe post a snapshot will be more easy to understand.


6

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 -...


6

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, use=xterm-256color, setb24=\E[48:2:%p1%{65536}%/%d:%p1%{256}%/%{255}%&%d:%p1%{255}%&%dm, setf24=\E[38:2:%...


5

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. To "...


5

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. See C-...


5

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 ...


5

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 ...


5

I think daemonp is what you're looking for. From its docstring: Return non-nil if the current emacs process is a daemon. If the daemon was given a name argument, return that name.


5

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 ...


5

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 ...


5

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-...


Only top voted, non community-wiki answers of a minimum length are eligible