A series of notes that I learn Emacs hacking. Change variable globally, disabling auto-save and auto-backup; `require` keyword, enabling recent files opening, enabling delete selection mode; code block and example block fast typing; initializing Emacs with full screen; showing matching parenthesis, highlighting current line; package management system configuration; adding a new theme, hundgry delete mode, swiper, smartparens; customize-group; ordered list in org-mode; JavaScript IDE in Emacs; setting schedule in org-mode.
setq vs. setq-default
Cursor type is a buffer-local variable. setq will change a local buffer cursor type.
Use setq-default to change global setting.
Disable auto-save / auto-backup
(setq make-backup-files nil)
Require
There are files in the system, use this function to load them, similarly to include or import.
(require 'org)
Deal with the recent files
(require 'recentf): activate it.
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files): such that we can open recent file by C-x C-r.
Delete the selection words
(delete-selection-mode t): select some block and type sth, it will change. The previous version do this by append.
;; Add the package source(when(>=emacs-major-version24)(require'package)(package-initialize)(add-to-list'package-archives'("melpa"."http://melpa.org/packages/")t))(require'cl);; Add whatever packages you want here(defvarLanternD/packages'(companymonokai-theme)"Default packages")(defunLanternD/packages-installed-p()(loopforpkginLanternD/packageswhen(not(package-installed-ppkg))do(returnnil)finally(returnt)))(unless(LanternD/packages-installed-p)(message"%s""Refreshing package database...")(package-refresh-contents)(dolist(pkgLanternD/packages))(when(not(package-installed-ppkg))(package-installpkg)))
If the above is not working, go to Melpa’s home page to find instruction.
1
2
3
4
5
6
7
8
9
(require'package);; You might already have this line(let*((no-ssl(and(memqsystem-type'(windows-ntms-dos))(not(gnutls-available-p))))(url(concat(ifno-ssl"http""https")"://melpa.org/packages/")))(add-to-list'package-archives(cons"melpa"url)t))(when(<emacs-major-version24);; For important compatibility libraries like cl-lib(add-to-list'package-archives'("gnu"."http://elpa.gnu.org/packages/")))(package-initialize);; You might already have this line
We can now add package from the Package management system.
Add a new theme
Go to Package Management, install “monokai-theme”
M-x load <enter> monokai <enter>, done.
Install hungry-delete-mode
Delete similar stuff all at once!
Package management advanced
M-x package-list-packages <enter>: this is equivalent to open the package management system in the menu.
Press <i>, <d>, <u> to mark “Install”, “Delete” and “Upgrade” to the packages.
After marking a package, press <x> to confirm.
<U>: captical U to execute global upgrade to all installed packages.
If too many packages are installed, be CAUTIOUS to upgrade all packages at once. Something terrible may happen.
M-x package-autoremove: Auto remove packages.
About smex package
An augmented M-x.
after key-binding, press M-x, use C-s to navigate in the command available.
About swiper package
type in the stuff
Use C-n, C-p to navigate
C-x C-f now can navigate like a folder access.
About smartparens package
Help you type in the right parenthensis after you enter the left one.
Remember to add hook to certain major mode.
Customize group
M-x customize-group, then type in the name, then we can enter the configuration for each package.
M-x customize-option: a more detailed option list.
Tips on order list in org-mode
M-<return> can help to reorder the list, so that the numbers are current.
()
ss
r234
553233
443saf
asdjio
Be careful, M-<return> will match the previous format.
About JavaScript IDE
By default, Emacs open js with the JavaScript major mode.
Suppose we already have js2-mode installed, we can switch to that.