Skip to content

junjiemars/.emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nore Emacs

Darwin, Linux and Windows

Quick start

It works on Emacs version 22.1.1+ , provides more reasonable styles: more organized code, more consistent, more cleaner and more faster. You can run it on any environment Emacs itself runs on: GUI or Terminal, even you can run multiple Emacs instances with different version on the same machine at the same time.

  • clone Nore Emacs from github
git clone --depth=1 https://github.com/junjiemars/.emacs.d.git ~/.emacs.d
  • open Emacs, after Emacs compile all elisp files, then reopen Emacs
  • want more functionalities see Recipe section

Additionally, it is important to remind you to take care as it is exceptionally fast.

Story

Emacs is the most powerful editor in the world there is no one of. It’s programmable, elegant and self-documenting.

As my daily work increasingly revolves around Emacs, I realize it’s time to integrate Emacs into my very being - not just for opening, navigating, editing, and saving files. Inspired by Euclid’s approach to geometry, I have created Nore Emacs.

Nore Emacs aims to provide a seamless experience with its focus on consistency, speed, stability, and hackability. It ensures consistent behavior across all platforms where Emacs is supported.

Now, let’s begin at Level Two. The key thing to remember is to familiarize yourself with some basic Elisp. You can start by using the Emacs built-in help system (C-h i m Elisp) and navigate to the Elisp documentation.

Principles

  • Adaptive: Nore Emacs is designed to run on any operating system, whether it’s a graphical or terminal interface. It is compatible with both the latest Emacs versions and even older ones. Furthermore, you can use a single Emacs configuration for multiple coexisting Emacs instances on the same machine
  • Consistent: Regardless of the environment or time, Nore Emacs always maintains consistent behavior. You can rely on a seamless experience no matter where or when you use it.
  • Minimalism: Nore Emacs promotes a minimalist approach, both internally and externally. It only loads the necessary components based on your specific needs, ensuring efficiency and avoiding unnecessary clutter.

Requirements

  • Emacs [22.1,29.1]
  • Keyboard+

Where

  • Linux, whatever GUI or TUI
  • Darwin, whatever GUI or TUI
  • Windows, whatever GUI or TUI
  • Raspberry Pi and Docker container, etc.,
  • Network or without Network
  • One machine, multiple Emacs instances

What

  • You are the master of your Emacs, …
  • Navigating, finding, grepping in the same way wherever, …
  • Org Mode that’s your new life, …
  • Amazing programming experiments, C, Lisp, …
  • It’s a no-cost extension and git friendly infrastructure.

Install

Just one thing you need to do, clone it (just <1024KiB) to your HOME directory:

git clone --depth=1 https://github.com/junjiemars/.emacs.d.git ~/.emacs.d

First run Nore Emacs, it should automatically do:

  • byte/native compile elisp source files.
  • install packages, if you allow it.

After first run Nore Emacs, exit and then reopen Emacs.

On Windows, if you’d Git-Bash installed but no Emacs, you are lucky, a one line code will do it all for you and more: fix some Emacs’ issue for you, and you don’t need run src_shell{git clone …},

instead,

HAS_EMACS=1 bash <(curl https://raw.githubusercontent.com/junjiemars/kit/master/win/install-win-kits.sh)

Now, it will works perfectly, but if you want to more control and more features, such as themes, packages, and fonts etc., see next section: recipe

Organization

Signify your Emacs HOME as (emacs-home*).

Your private configuration directory at (emacs-home* "private/"). All things under it you can rename, move, delete.

All Elisp files should be compiled, if you meet some trouble, a magic interactive function (clean-compiled-files) should help, run it and reopen the Emacs.

Directory

(emacs-home*)
├── LICENSE
├── README.org
├── config (comment "all stuff here")
├── elpa (comment "installed packages")
├── init.el (comment "Emacs init file")
├── private (comment "your configuration can put here")
│   ├── self-env-spec.el
│   ├── self-mod-spec.el
│   ├── self-epilogue.el
└── theme (comment "themes directory")

Locate your spec via (*self-paths*).

;; Run order: :env-spec -> :mod-spec -> :epilogue
;; You can point to your Gited Emacs' configuration repo.
;; Default samples `sample-self-*.el' in `(emacs-home* "config/")' directory.
;; :epilogue run in `after-init-hook'

(*self-paths* :put :mod-spec
              (comment (emacs-home* "private/self-mod-spec.el")))
(*self-paths* :put  :epilogue
              (comment (emacs-home* "private/self-epilogue.el")))

Directories with . prefix are for the modules that need store configuration or cached files.

(emacs-home*)
├── .backup
├── .bookmarks
├── .desktop
├── .dired
├── .eshell
├── .exec (comment "exec-path")
├── .ido
├── .mail
├── .save
├── .tags
├── .tramp
└── (comment "more ...")

Naming

Introduce the rules of naming files and functions.

Core Files Naming: single word and simple name.

(emacs-home* "config/")
├── autoloads.el
├── boot.el
├── chez.el
├── dict.el
├── fn.el
├── gambit.el
├── graphic.el
├── gud-cdb.el
├── gud-lldb.el
├── memo.el
├── sodoku.el
└── (comment "more ...")

Extension Naming

  • extension for Emacs builtin packages: <package-name>s.el
(emacs-home* "config/")
├── cc.el
├── guds.el
├── shells.el
├── modules.el
├── sockets.el
├── tags.el
└── (comment "more ...")
  • autoload extension for Emacs builtin packages: <package>.el on-<package-name>-autoload.el
(emacs-home* "config/")
├── on-cc-autoload.el
├── on-compile-autoload.el
├── on-dired-autoload.el
├── on-docview-autoload.el
├── on-edit-autoload.el
├── on-eglot-autoload.el
├── on-trans-autoload.el
├── on-shell-autoload.el
├── on-eww-autoload.el
├── on-font-autoload.el
└── (comment "more ...")
  • extension for non Emacs builtin packages: use-<package-name>.el use-<package-name>-autoload.el
(emacs-home* "config/")
├── use-geiser-autoload.el
├── use-magit-autoload.el
├── use-slime-autoload.el
└── (comment "more ...")

Sample Files Naming: sample-self-*.el

(emacs-home* "config/")
├── sample-self-env-spec.el
├── sample-self-mod-spec.el
└── sample-self-epilogue.el

Functions Naming (χ denotes name)

  • v-χ macro x for processing Versioned directories or files, such as v-home
  • _χ_ macro x only existing at compile-time, such as _mark_thing@_
  • χ​* or χ** is the extension of Emacs’ builtin function or macro x, such as every* and assoc**
  • χ*-y is the extension of function y of feature x, such as vc*-dir
  • χ% macro x will be expanded at compile time, such as if%
  • χ! function or macro x has side-effects, such as v-home!
  • χ@ positional functions, such as mark-word@ and mark-sexp@

Recipe

Theme

Easy to switch themes, or try a new one.

The theme’s spec locate in (*self-env-spec* :get :theme :custom-theme-directory).

(*self-env-spec*
 :put :theme
 (list :name nil                        ; 'tango-dark
       :custom-theme-directory nil      ; (emacs-home* "theme/")
       :compile nil                     ; expert option
       :allowed nil))
  • :name name of theme, does not need -theme.el suffix
  • :custom-theme-directory where custom theme files located
  • :compile t compile theme, compiled theme more smooth and more faster if you had already confirmed the theme is secure.
  • :allowed t enabled, nil disabled

screenshots:

Frame

The frame’s spec locate in (*self-env-spec* :get :frame) and for GUI mode only.

(*self-env-spec*
 :put :frame
 (list :initial `((width . 80)
                  (height . 32)
                  (font . ,(if-platform% 'darwin
                               "Monaco-17"
                             (if-platform% 'windows-nt
                                 "Consolas-13"
                               "Monaco-13"))))
       :default nil                     ; `((fullscreen . fullheight))
       :inhibit-splash-screen nil
       :allowed t))
  • :initial initial-frame-alist
  • :inhibit-splash-screen inhibit-splash-screen
  • :allowed t enabled, nil disabled

Glyph

The glyph’s spec locate in (*self-env-spec* :get :glyph) and for GUI mode only. It determines the appearance of glyph characters such as CJK, etc., the default encoding of glyph is UTF-8.

(*self-env-spec*
 :put :glyph
 `((:name ,(if-platform% 'darwin
               "Hack"
             (if-platform% 'windows-nt
                 "Courier New"
               "DejaVu Sans Mono"))
          :size 17
          :scale nil
          :scripts (greek)
          :allowed t)
   (:name ,(if-platform% 'darwin
               "PingFang"
             (if-platform% 'windows-nt
                 "Microsoft YaHei"
               "Noto Sans"))
          :size 12
          :scale nil
          :scripts (han)
          :allowed nil)))
  • :name string of font name
  • :size integer of font size
  • :scale t scaled, nil disabled
  • :scripts list of script symbol for character
  • :allowed t enabled, nil disabled

screenshots:

Shell

shell

Suppport any SHELL, copying or spinning environment variables into Emacs environment.

The shell spec locate in (*self-env-spec* :get :shell).

(*self-env-spec*
 :put :shell
 (list :copy-vars `("PATH")
       :spin-vars nil                   ; `(("ZZZ" . "123"))
       :options '("-i" "2>/dev/null")   ; '("--login")
       :exec-path t
       :shell-file-name (or (executable-find% "zsh")
                            (executable-find% "bash"))
       :prompt (list :zsh "%n@%m %1~ %# "
                     :bash "\\u@\\h \\W \\$ ")
       :allowed nil))
  • :copy-vars copy environment variables from shell into Emacs environment, that affects eshell, shell and ansi-term
  • :spin-vars spin customized variables, only affects eshell
  • :options a list of shell’s options
  • :exec-path copy PATH environment variable to exec-path
  • :shell-file-name where the shell program located
  • :prompt unify shell prompt in term mode, via C-c C-j then M-x term-unify-shell-prompt
  • :allowed t allowed, nil disabled

eshell

The eshell spec locate in (*self-env-spec* :get :eshell). And shared the copied environment variables :copy-vars with shell.

(*self-env-spec*
 :put :eshell
 (list :visual-commands '("mtr")
       :destroy-buffer-when-process-dies nil
       :visual-subcommands nil          ; '(("git" "log"))
       :visual-options nil
       :allowed t))
  • :visual-commands C-h-v eshell-visual-commands
  • :destroy-buffer-when-process-dies C-h-v eshell-destroy-buffer-when-process-dies
  • :visual-subcommands C-h-v eshell-visual-subcommands
  • :visual-options C-h-v eshell-visual-options
  • :allowed t allowed, nil disabled

Session

The desktop spec locate in (*self-env-spec* :get :desktop).

(*self-env-spec*
 :put :desktop
 (list :files-not-to-save
       "\\.t?gz$\\|\\.zip$\\|\.desktop\\|~$\\|^/sudo:\\|^/ssh[x]?:$"
       :buffers-not-to-save "^TAGS\\|\\.log"
       :modes-not-to-save
       '(dired-mode fundamental-mode eww-mode rmail-mode)
       :allowed t))
  • :files-not-to-save C-h-v desktop-files-not-to-save
  • :buffers-not-to-save C-h-v desktop-buffers-not-to-save
  • :modes-not-to-save C-h-v desktop-modes-not-to-save
  • :allowed t enabled, nil disabled

Network

Socks

Using socks proxy when installing packages or browsing web pages.

The socks spec locate in (*self-env-spec* :get :socks).

(*self-env-spec*
 :put :socks
 (list :port 32000
       :server "127.0.0.1"
       :version 5
       :allowed nil))
  • :port the port of socks proxy server
  • :server the address of socks proxy server
  • :version socks version
  • :allowed t enabled, nil disabled

If :allowed t, url-gateway-method should be switch to socks when Emacs initializing. After Emacs initialization, you can toggle-socks! and no matter :allowed is t or nil.

Network Utils

Emacs comes with a lots of wrappers(net-utils.el) around the common network utilities. Such as M-x ping a host. But net-utils.el has some inconveniences:

  • If you want to ping with options you must set ping-program-options customizable variable.
  • IPv6 supporting: on Unix-like OS there are individual program for IPv6, such as ping6, but on Windows OS just one ping program and with -6 option.

commands around net-utils, and named those commands with * prefix. Using C-u M-x *<command> you can set the options for that <command>.

The following interactive commands had been defined for Emacs22.1+ whatever OS you using:

  • M-x *arp
  • M-x *dig
  • M-x *ifconfig
  • M-x *ping
  • M-x *traceroute

Browser

  • toggle external or internal browser: M-x toggle-browser!
  • lookup web for symbol, word, etc.,: M-s w
  • lookup online dictionaries: M-s d

Package

It’s file-oriented, you can find more simpler and faster way to implement almost functionalities that use-pacakge does and more.

(*self-env-spec*
 :put :module
 (list :remove-unused nil
       :package-check-signature 'allow-unsigned
       :allowed t))
  • :remove-unused whether remove the unused packages that be defined in def-self-package-spec
  • :package-check-signature nil does not check signature when installing packages.
  • :allowed t enabled, nil disabled

The user defined package spec locate in (*self-mod-spec*).

;;; :common-lisp
(*self-mod-spec*
 :put :common-lisp
 (list
  :cond (comment (or (executable-find% "sbcl")
                     (executable-find% "ecl")
                     (executable-find% "acl")))
  :packages '(slime)
  :compile `(,(compile-unit% (emacs-home* "config/use-slime.el") t)
             ,(compile-unit% (emacs-home* "config/use-slime-autoload.el")))))

;;; :doc
(*self-mod-spec*
 :put :doc
 (list
  :cond nil
  :packages (list (when% (executable-find% "gnuplot")
                    'gnuplot-mode)
                  'markdown-mode
                  (when-version% <= 24.3 'yasnippet)
                  'vlf)))

;;; :erlang
(*self-mod-spec*
 :put :erlang
 (list
  :cond (comment (executable-find% "erlc"))
  :packages (list 'erlang)))

;;; :lisp
(*self-mod-spec*
 :put :lisp
 (list
  :cond (comment t)
  :packages '(paredit rainbow-delimiters)
  :compile `(,(compile-unit% (emacs-home* "config/use-lisp.el") t)
             ,(compile-unit% (emacs-home* "config/use-lisp-autoload.el")))))

;;; :lua
(*self-mod-spec*
 :put :lua
 (list
  :cond (comment (executable-find% "lua"))
  :packages '(lua-mode)))

;;; :org
(*self-mod-spec*
 :put :org
 (list
  :cond (comment (executable-find% "latex"))
  :packages (flatten (list 'auctex 'cdlatex
                           (when-version% <= 25 'ox-reveal)))))

;;; :rust
(*self-mod-spec*
 :put :rust
 (list
  :cond (comment (and (executable-find% "rustc")
                      (executable-find% "cargo")))
  :packages '(rust-mode)
  :compile `(,(compile-unit% (emacs-home* "config/use-rust.el") t)
             ,(compile-unit% (emacs-home* "config/use-rust-autoload.el")))))

;;; :scheme
(*self-mod-spec*
 :put :scheme
 (list
  :cond (comment (and (when-version% <= 23.2 t)
                      ;; Nore Emacs has builtin supports for Chez
                      ;; scheme and gambitC scheme, and does not need to
                      ;; install the dumb geiser.
                      (or (executable-find% "racket")
                          (executable-find% "scheme")
                          (executable-find% "chicken")
                          (executable-find% "guile"))))
  :packages  '(geiser)
  :compile `(,(compile-unit% (emacs-home* "config/use-geiser.el") t)
             ,(compile-unit% (emacs-home* "config/use-geiser-autoload.el")))))

;;; :vlang
(*self-mod-spec*
 :put :vlang
 (list
  :cond (comment (executable-find% "v"))
  :packages '(v-mode)))

;;; :vcs
(*self-mod-spec*
 :put :vcs
 (list
  :cond (comment (and (when-version% <= 24.4 t)
                      (executable-find% "git")))
  :packages '(magit)
  :compile `(,(compile-unit% (emacs-home* "config/use-magit.el") t)
             ,(compile-unit% (emacs-home* "config/use-magit-autoload.el")))))

;;; :web
(*self-mod-spec*
 :put :web
 (list
  :cond nil
  :packages (list 'htmlize
                  'js2-mode
                  (when-version% <= 25 'restclient)
                  (when-version% <= 24.3 'skewer-mode)
                  'web-mode
                  'x509-mode)))

;;; :zig
(*self-mod-spec*
 :put :zig
 (list
  :cond (comment (executable-find% "zig"))
  :packages '(zig-mode)))


;; end of sample-self-package-spec.el
  • :cond decide whether to install :packages and compile :compile
  • :packages a list of package names or tar file names
  • :compile when installed packages, a list of files that should be compiled only or be loaded after been compiled

You can use any Elisp functions after the aboved keywords.

  • when-version% macro checking the version of current Emacs at compile time.
  • executable-find% macro checking the exising of the executable at compile time.
  • compile-unit% macro specify the compiling file to compile or compile then load.

Indent

Avoiding a war. If whitespace causes some trouble, you can swith to M-x whitespace-mode to find out.

(*self-env-spec*
 :put :edit
 (list :tab-width 2
       :narrow-to-region nil
       :auto-save-default nil
       :indent '((python-indent-offset . 4))
       :disable-indent-tabs-mode '(c-mode
                                   sh-mode
                                   emacs-lisp-mode)
       :delete-trailing-whitespace '(prog-mode)
       :allowed t))
  • :tab-width default C-h-v tab-width
  • :narrow-to-region t enabled, nil disabled
  • :auto-save-default C-h-v auto-save-default
  • :disable-indent-tabs-mode disble indent-tabs-mode in specified major modes
  • :delete-trailing-whitespace delete trailing whitespace before save
  • :indent indent width does not equal :tab-width
  • :allowed t enabled, nil disabled

File

Using dired as a File Manager is awesome, same experiences on Windows, Darwin and Linux.

ls Program

For Windows, there are no built-in ls program, but you can install GNU’s ls via Git-Bash.

For Darwin, let dired don’t do stupid things.

screenshots:

find Program

On Windows, if GNU’s find has already in your disk, and let Windows stupid find or findstr program go away. Don’t setq find-program on Windows, because dired can not differ the cases between local and remote.

Now, on Windows you can use M-x find-dired or M-x find-name-dired

screenshots:

compress Program

On Windows, there are no builtin zip/unzip program, but Emacs ship with minizip program. Although minizip without recursive functionalities, but do some tricks with minizip, we can zip files and directories with minizip, even export org to odt OpenDocument. And more 7-Zip standalone command version also be supported.

On Windows, there are logical bugs in dired-aux.el, We can not using Z key compress or uncompress file to or from .gz or .7z. The good news: if gunzip or 7za installed we can do it now.

You can using c in dired mode compress to *.gz, *.7z or *.zip. For some ancient Emacs24-, ! zip x.zip ? to zip.

It’s headache when default-file-name-coding-system not equal with locale-coding-system specifically on Windows. Even view archived file in arc-mode, will display wrong encoded file names.

On Windows, there are some encoding issues when default-file-name-coding-system not equal locale-coding-system.

  • display non-unicode encoded directory name or file name;
  • insert non-unicode encoded directory;
  • compress the files with with locale-coding-system filenames;
  • dired-do-shell-command or dired-do-async-shell-command;

The good news is the whole above issues had gone in this kit.

For .rar archive, emacs really sucks.

  • on Emacs 23.3.1, using unrar-free in archive-rar-summarize function, but on Emacs 26.1 using lsar, and those all had been hard coded in arc-mode.el.
  • 7z l output is not compatible with lsar and unrar.

screenshots:

Editing

Scratch

New a scratch buffer or switch to the existing one.

Mark

Provides the abilities to mark symbol, filename and line in current buffer then you can M-w the marked part.

Using mark-sexp@ default mark whole Lisp sexp or C block at point. If prefix N is non nil, then forward or backward to sexps boundary, just like the builtin mark-sexp does.

mark-quoted@ mark whole quoted things at point and do not care whatever the mode is.

mark-word@ default mark the whole word at point. If prefix N is non nil, then forward or backword to word boundary, just like the builtin mark-word does.

mark-defun@ more stable in variant programming modes than `mark-defun’.

Tags

Prefer etags program, because it works well on varied platforms. In (emacs-home* "config/tags.el"), there are some handy functions to create the tags for Elisp or C source code, such as make-emacs-source-tags, cc*-make-tags, mount-tags, and unmount-tags.

Nore Emacs also supports Exuberant Ctags.

Using mount-tags to mount the specified tags file at first order of tags-table-list. Or C-u mount-tags to mount tags file at the tail of tags-table-list. The unmount-tags is the inverse of mount-tags.

  • make-emacs-source-tags: make tags for Emacs’ C and Lisp source code.
  • make-dir-tags: make tags for specified directory.
  • cc*-make-system-tags: make system C tags.

Clipboard

In terminal, Emacs can not copy to or paste from system clipboard when on Darwin or Linux. For such cases, we need external programs to help us do the job. Now, Nore Emacs integrates this functionalities, so we can use natural keys (such as C-w, C-y) to copy to or paste from system clipboard.

iSearch

There are no uniformed isearch functionalites among in isearch-forward, isearch-backward and isearch-forward-symbol-at-point. Now, in Nore Emacs those functionalites unified to two functions: isearch-forward* and isearch-backward*.

In Nore Emacs, by default, isearch-forward* and isearch-backward* same with the built-in ones. Except we can search the text of activated region. C-s and C-r will search forward or backward just like vi’s * does. And more, searching word, quoted string, or filename forward or backword.

Open line

Emulates vi’s o and O command in Emacs, the built-in one open-line or split-line do not indent accordingly the current line. See Open Next Line.

  • C-o open-next-line
  • C-M-o open-previous-line

Comment

comment-line has stupid behaviors, that why toggle-comment had been made.

  • toggle-comment: C-x C-;

Kill

kill-word@ and kill-sexp@ are frequently editing commands when programming.

Keys

Obey the defaults of Emacs’ keymap.

Global keys

Global for all Emacs’ version.

  • M-/ hippie-expand
  • C-c f f find-file-at-point
  • C-x x g revert-buffer or revert-buffer-quick
  • C-x x n echo-buffer-name
  • C-M-o open-previous-line
  • C-o open-next-line
  • C-c m d: mark-symbol@
  • C-c m d: mark-word@
  • C-c m d: mark-sexp@
  • C-c m d: mark-defun@
  • C-c m l: mark-line@
  • C-c m f: mark-filename@
  • C-s: isearch-forward*
  • C-r: isearch-backward*
  • M-s .: isearch-forward-symbol*
  • M-s @: isearch-forward-word*
  • M-s f: isearch-forward-file*
  • M-s _: isearch-forward-quoted*

Compatible keys

Compatibled for ancient Emacs versions, compatible keys may not avaiabled on ancient Emacs.

  • M-, pop-tag-mark
  • M-* tags-loop-continue
  • C-l recenter-top-bottom
  • C-c b l linum-mode
  • M-# xref-find-references

Featured keys

The features provided by non-Emacs’s packages, featured keys may not avaiabled on ancient Emacs.

  • C-x v d magit-status

Programming

Generic editing

Just introduce Nore Emacs’ improvements.

Lisp programming

Lisp programming in Emacs already good enough, if ParEdit installed editing Lisp code more easy.

slime is the best tool for Common Lisp programming.

For Scheme programming, there are builtin minor modes: gambit-mode for Gambit Scheme system, and chez-mode for Chez Scheme system.

REPL

  • *slime-repl*: M-x slime
  • *gambit*: M-x run-gambit
  • *chez*: M-x run-chez

C programming

Now, we are in the cycle of editing, compiling, debugging.

screenshots:

Editing

Change C programming style using C-c .. And there is a new elegant and practical style: cc*-style-nginx.

View C system include

Like vi’s gf command, you can using C-c f i to open C system include file on local or remote in view-mode and via M-, to go back. It supports gcc, clang, and msvc.

On Darwin, you can find correct include path in Man-mode now.

Macro expand

Mark the code that include a macro call then C-c C-e, you should see the expansion of the macro in *Macro Expanded*, whatever you are using gcc, clang and msvc, locally or remotely.

screenshots:

Dump predefined macros

Dump compiler predefined macros, C-c #, you should see the predefined macros in *Macros Predefined*, whatever you are using gcc and clang locally or remotely.

screenshots:

Compiling

Press M-x compile then:

  • Unix-like:
    • raw: cc c.c -oa.out
    • make: make
  • Windows:
    • raw: cc-env.bat && cl c.c -Fea.exe
    • make: cc-env.bat && make

to build.

For msvc there are need tricks to works with Emacs. Nore Emacs will generate a msvc’s host environment cc-env.bat for you that make life easy and if Nore already on your machine, now life is perfect.

screenshots:

Debugging

lldb and cdb had been perfectly integrated.

  • gud-lldb
  • gud-cdb

screenshots:

Troubleshoting

  • I. M-x clean-compiled-files then exit and reopen Emacs.
  • II. Check Emacs configurations:
    • M: system-configuration-options
    • M: system-configuration-features
    • M: features
    • M: load-history

    then do I.

  • III. Check *Compilation-Log* buffer, then do I.
  • IV. Check (*self-paths*), then do I.
  • V. Disable the problematic item in (*self-env-spec*), then do I.
  • VI. Disable the problematic item in (*self-mod-spec*), then do I.

Mnemonic

Emacs Documents

It’s self-documenting and great, keep reading it frequently.

  • Tutorial: C-h-t
  • Emacs manual: C-h r
  • Emacs news: C-h C-n
  • Emacs FAQ: C-h C-f
  • Help for Help: C-h C-h
  • Apropos command: C-h a
  • Mode: C-h-m see all the key bindings and documentation of current buffer
  • Info: C-h i
  • Info file: C-u C-h i <where>
  • Index of topic: C-h r i
  • Function: C-h f display documentation of the given function
  • Variable: C-h v display documentation of the given variable
  • Keybinding: C-h k display documentation of the function invoked by the given keystrokes
  • Keybinding briefly: C-h c, which command for given keystroke
  • Prefix keybindings: press prefix keys such as C-c then C-h to see all key bindings for given prefix keystrokes
  • Message: C-h e see the logging of echo area message
  • Man: M-x man view UNIX manual page
  • Woman: M-x woman view UNIX manual page without man program
  • Coding system: C-h C describe coding system
  • Colors: M-x list-colors-display display names of defined colors and show what they look like
  • Syntax: C-h s describe syntax
  • Where is command: C-h w which keystrokes binding to a given command
  • Keystrokes: C-h l display last 100 input keystrokes

Motion

  • goto line: M-g g
  • goto nth char: M-g c
  • goto next error: C-x `
  • goto previous error: M-g p
  • jump between buffers: C-x C-SPC, jumps to the global mark acrross buffers
  • jump in buffer: C-u C-SPC
  • jump to definition: M-.
  • pop back to where M-,

Interaction

  • *scratch* buffer
  • eval Elisp: M-:
  • execute Shell command: M-!
  • in Dired mode: !, do shell command
  • region as input to Shell command: M-|,
  • insert from shell output: C-u M-!
  • insert from elisp output: C-u M-:
  • find file at point: C-c f f
  • filename of current buffer: C-c b n
  • lookup web at point: M-s w
  • lookup dict at point: M-s d
  • display time: M-x display-time

Editing

  • write file: C-x C-w same as save as
  • kill all spaces at point: M-\
  • kill all spaces except one at point: M-SPC
  • delete indentation to join line to previous line: M-^
  • join next line: C-u 1 M-^
  • kill word: M-d
  • kill whole word: C-x M-d, include the word that current point located.
  • kill whole symbol: C-x M-s, include the symbol that current point located.
  • kill line: C-k
  • kill whole line: C-x M-<backspace>
  • query replace: M-%
  • upcase region: C-x C-u
  • downcase region: C-x C-l
  • transpose characters: C-t
  • transpose words: M-t
  • transpose lines: C-x C-t
  • toggle read-only mode: C-x C-q
  • toggle input method: C-\
  • set input method: C-x RET C-\
  • describe current input method: C-h I
  • insert char: C-x 8 RET GREEK SMALL LETTER LAMBDA
  • what cursor position: C-x =
  • describe char: C-u C-x =
  • quoted insert: C-q, such as page break C-q C-l, use C-x [ to backward or C-x ] to forward, C-q C-I to insert horizontal tab, C-q C-J to insert line feed, C-q C-M to insert carriage return
  • check unmatched parentheses: M-x check-parens
  • tab to space: M-x untabify
  • space to tab: M-x tabify
  • fill paragraph: M q
  • redo: C-x ESC ESC
  • redo after undo: C-g and then C-x u
  • cancel: C-], or M-x top-level
  • open new line before current: C-o
  • remove all but one empty line: C-x C-o
  • delete entire line: C-S-DEL
  • delete to end of sentence: M-k
  • insert char: C-x 8 RET
  • count lines, words or characters of select region: M-=
  • count lines on current page: C-x l
  • toggle comment the current line or region: C-x M-;. toggle-comment more better than sucked comment-line.
  • insert or realign comment on current line: M-;
  • kill comment on current line: C-u M-;
  • indent and continuing comment: C-M-j
  • dynamic abbreviation expand: M-/
  • add inverse global abbreviation: C-x a i g
  • add inverse local abbreviation: C-x a i l
  • list abbreviations: M-x list-abbrevs
  • edit abbreviations: M-x edit-abbrevs
  • write abbreviation file: M-x write-abbrev-file
  • flush lines: M-x flush-lines
  • insert parentheses: M-(, wrap selection in parentheses
  • align region: M-x align-entire

Coding system

  • check current buffer coding system: C-x RET =
  • revert current buffer’s coding system: C-x RET r
  • specify coding system for the current buffer: C-x RET f
  • specify coding system for terminal output: C-x RET t
  • specify coding system for keyboard input: C-x RET k
  • specify coding system for the immediately following command: C-x RET c
  • specify input and output coding systems for subprocess: C-x RET p
  • specify coding system for transferring selections to and from other programs through the window system: C-x RET x
  • specify coding system for transferring one selection to or from the window system: C-x RET X

Basic sexp commands

  • forward-sexp: C-M-f
  • backward-sexp: C-M-b
  • kill-sexp: C-M-k, delete forward one sexp
  • transpose-sexp: C-M-t
  • backward-up-list: C-M-u, move up out of an sexp
  • down-list: C-M-d, move down into a nested sexp
  • backward-list: C-M-p, match parentheses backward
  • pp-eval-last-sexp: pretty print

Frame

  • find file other frame: C-x 5 C-f, or C-x 5 f
  • display buffer other frame: C-x 5 C-o, or C-x 5 b
  • find tag other frame: C-x 5 .
  • delete frame: C-x 5 0
  • delete other frames: C-x 5 1
  • make frame command: C-x 5 2
  • dired to other frame: C-x 5 d
  • other frame: C-x 5 o
  • find file read only other frame: C-x 5 r

Window

  • find file: C-x C-f
  • view file: C-x C-v
  • write file: C-x C-w
  • save current buffer: C-x s
  • save all modified buffers: C-u C-x s
  • save and backup current buffer: C-x C-s
  • kill a buffer: C-x k
  • other window: C-x o
  • dired other window: C-x 4 d
  • find file in other window: C-x 4 C-f, or C-x 4 f
  • display buffer: C-x 4 C-o, display the buffer in another window
  • find tag other window: C-x 4 .
  • kill buffer and window: C-x 4 0, just like C-x 0 except kill the buffer
  • switch to buffer other window: C-x 4 b
  • clone indirect buffer other window: C-x 4 c, clone the buffer in another window
  • recenter the screen at cursor: C-l
  • center the screen at the top: C-u 0 C-l
  • recenter the screen at the bottom: C-u - C-l

Register

  • store window configuration to register: C-x r w <REG>, but the configuration cannot accross sessions.
  • store frame configuration to register: C-x r f <REG>
  • store region into register: C-x r s <REG>
  • store current point in register: C-x r SPC <REG>
  • jump to register: C-x r j <REG>
  • insert from register: C-x r i <REG>
  • view the content of register: M-x view-register <REG>

Bookmark

Unlike registers, bookmarks have long names, and they persist automatically from one Emacs session to the next.

  • set bookmark: C-x r m
  • set named bookmark: C-x r m BOOKMARK
  • jump to bookmark: C-x r b BOOKMARK
  • list all bookmarks: C-x r l
  • save bookmark to file: M-x bookmark-save

Rectangle

  • kill rectangle: C-x r k
  • delete rectangle: C-x r d
  • yank rectangle: C-x r y
  • open rectangle: C-x r o, insert blank space to fill the space of the region-rectangle
  • copy rectangle: C-x r M-w
  • clear rectangle: C-x r c
  • replace rectangle: C-x r t
  • string insert rectangle: C-x r g
  • numbers insert rectangle: C-x r N
  • select entire buffer: C-x h
  • select page: C-x C-p
  • exchange cursor position and mark: C-x C-x

Keyboard Macro

  • start recording macro: C-x (
  • stop recording macro: C-x )
  • playback macro: C-x e
  • apply macro to region: C-x C-k r
  • edit last marcro: C-x C-k RET
  • bind the most recent macro to a key: C-x C-k b [1-9A-Z]

Dired

  • hide details: (
  • change marks: * c
  • toggle readonly: C-x C-q
  • finish edit: C-c C-c
  • abort editing: C-c C-k
  • echo current directory: W
  • hex edit file: @html:<kbd>@@b
  • find regexp recusive: A
  • replace regexp recusive: Q

Regexp

  • regexp builder: M-x regexp-builder

Shell

  • EShell: M-x eshell
  • Shell: M-x shell
  • Ansi-Term: M-x ansi-term
  • interrupt process in eshell: C-c C-c
  • interrupt process in shell: C-c C-c
  • interrupt process in ansi-term: C-x C-c

Remote

It’s the duty of TRAMP.

  • non-sudo: C-x C-f /ssh:user@host:/path/to/file, such as user@host or user in .ssh/config entries.
  • sudo remote: C-x C-f /ssh:user|sudo::/path/to/file
  • sudo localhost: C-x C-f /sudo::/path/to/file
  • eshell remote: cd /ssh:user@host:/path/to/file
  • on Windows use ~/.ssh/config: use /sshx: instead, such as /sshx:user@host:/path/to/file

Sort

  • sort fields: C-c s f by Nth field
  • sort numeric fields: C-c s n by Nth numeric field
  • sort lines: C-c s l
  • sort regexp fields: C-c s x by regexp field
  • reverse region: C-c s r
  • delete duplicated lines: C-c s d

Face

  • describe the face at point: M-x describe-face

Text scale

  • reset face height: C-x C-0
  • increase face height: C-x C-=
  • decrease face height: C-x C--

Log

  • tail -f: M-x auto-revert-tail-mode
  • toggle highlighting of the current line: M-x hl-line-mode
  • highlight all lines matching a regexp: M-s h l, and M-s h u to unhighlight.
  • narrow region: C-x n n
  • widen region: C-x n w

LaTeX

Requirements

On Darwin

On Ubuntu

  • ImageMagick
  • texlive
  • texlive-latex-extra: additional packages.
  • texlive-lang-cjk: supporting a combination of Chinese, Japanese, Korean, including macros, fonts, documentation.
  • texlive-xetex

On Windows

Aspell

Requirements

On Darwin

  • aspell
  • aspell-dict-en

Issues?

If you have issues, just post it.