The command rh/act-inside (bound to M-i) kills the content of the balanced expression that contains the point and put the point inside (think of Vim’s change-inner but not having to type so long to specify the delimiter)
Suppose the current point is denoted by | and we have
(here is a "nice| string" inside)Pressing M-i takes us to
(here is a "|" inside)However, C-M-u M-i would have taken us to
(|)The command rh/act-inside accepts universal argument. For instance, C-u M-i copies the content of the balanced expression instead of killing it.
The command rh/change-inside-forward (bound to M-I) does the same as rh/act-inside but for the next balanced expression. Suppose we have
my fruits |are "apple", "mango" and "guava"Then pressing M-I takes us to
my fruits are "|", "mango" and "guava"To jump several balanced expressions ahead, we supply prefix argument. For instance, typing a fruit (say, banana) and pressing C-2 M-I takes us to
my fruits are "banana", "mango" and "|"To jump back, we supply negative argument. For instance, typing another fruit (say, papaya) and pressing C-u -2 M-I takes us to
my fruits are "|", "mango" and "papaya"In my config, this command is bound to C-M-w (by default, Emacs binds append-next-kill to this key, which I have rebound to C-M-S-w). This commands checks if the point is at the start of a balanced expression. If it is, then the expression is copied. Otherwise, it copies the smallest balanced expression that contains the current point.
Invoking C-M-w, in the following case, copies the whole string.
"My GNU/Linux opera|ting system."Prefix argument is supplied to specify how many balanced expressions to copy. For instance, invoking C-3 C-M-w, in the following case, copies all the three strings.
"G|NU" "Emacs" "thermonuclear editor"Moves the point to the next opening delimiter. Prefix argument signifies how many opening delimiters to move forward.
Moves the point to the previous opening delimiter. Prefix argument signifies how many opening delimiters to move backward.
When there is no active region, this commands marks the whole line. Otherwise, it extends the active region by a whole line at the end opposite to the point. For instance, if the point is at the lower end of the active region, this will extend the region by a whole line above and vice versa.
This is a more sensible join-line based on the built-in join-line. Also takes prefix argument to join multiple lines.
This command starts the next sentence in a new line and moves the point there. Also takes prefix argument to break multiple sentences.
This removes the delimiters of the smallest sexp containing the current point. If you are already at the beginning of the target sexp (balanced expression), use the built-in delete-pair instead. A prefix argument can be used to climb up the parent sexp hierarchy. For instance, suppose we have the following.
mylist = ["Emacs", "Dired", "Esh|ell"]With prefix argument C-2 (or C-u 2), we end up with the following.
mylist = "Emacs", "Dired", "Esh|ell"- To enable Emacs keybindings for all GTK text fields (including Firefox), run in shell:
gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"Emacs loads early-init.el file before init.el. This following marks the start of the early-init.el file.
;;; early-init.el --- Load this before init.el -*- lexical-binding: t; -*-Garbage collection is important but may slow down Emacs startup slightly. The following defers garbage collection to speed up startup.
;; Defer garbage collection
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)It’s important to set default-frame-alist early as this affects the how the Emacs frames start and look like. Here, we set the font to Iosevka, sized 15. We start Emacs in fullscreen, maximized.
(setq default-frame-alist '((font . "Iosevka Term-15") (fullscreen . maximized)))By default, Emacs starts with several GUI elements (menu bar, tool bar, scroll bar). These are unnecessary and look polluting in a minimalist setup.
;; Disable UI elements
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1)
(set-fringe-mode -1)By default, Emacs also pulls in lots of extra baggage at startup. To get a cleaner startup, we inhibit a lot of theses baggage.
- Setting
inhibit-startup-screentotinhibits the defaultWelcome to GNU Emacsstartup screen. Now Emacs will start with the*scratch*buffer. - To not load
default.elfrom the Emacs installation directory, we setinhibit-default-inittot. - Setting
inhibit-x-resourcestotinhibits loading X resources. - Setting
frame-inhibit-implied-resizetotstops Emacs from automatically resizing frame when changing font or UI elements. - Setting
server-client-instructionstonilmakes client sessions cleaner. - Setting
emacs-start-timetocurrent-timerecords the time Emacs started, for profiling startup time later. - Setting
warning-minimum-leveltoerrorinhibits auto pop ups of warning buffer unless it’s an error. The value could beemergency(Emacs warns you only when there is an emergency). - The line
(fset 'display-startup-echo-area-message #'ignore)suppresses the echo area message shown at startup.
;; Inhibit startup annoyances
(setq
inhibit-startup-screen t
inhibit-default-init t
inhibit-startup-message t
inhibit-x-resources t
inhibit-compacting-font-caches t
inhibit-startup-echo-area-message t
frame-inhibit-implied-resize t
server-client-instructions nil
emacs-start-time (current-time)
warning-minimum-level :error)
(fset 'display-startup-echo-area-message #'ignore)In newer versions of Emacs, native compilation is on by default. The following code make some adjustments to how Emacs native compiles the source files.
;; Native compilation tweaks
(setq package-native-compile t
package-install-upgrade-built-in t
native-comp-deferred-compilation t
native-comp-warning-on-missing-source nil
native-comp-async-report-warnings-errors nil
native-comp-speed 3
native-comp-defer t)Then we end the early-init.el file with the following file.
(provide 'early-init)- Set mark and deactivate (
C-SPC C-SPC) at the beginning of the first sexp. - At the beginning of the second sexp, do
C-0 C-M-t. - The same works for words with either
C-M-torM-t.
C-u ARG M-ttakes the word before or around point and drags it forward pastARGother words (backward ifARGnegative).- The same for transposing sexps, but here the point must be between the sexp and not in the middle of a sexp to be transposed.