(defvar sym &optional init “doc”)
(defcustom sym init “doc” &rest args)
(set 'sym val)
(setq var val …)
(setq-default var val …)
(apply fun &rest args)
let
letf
, but dependencies between assigned (init) values in variable bindings are allowed: let*
(progn …)
(lambda …)
(if condition …)
(when condition …)
(when (not condition) …)
is: (unless condition …)
(cond …)
'(a b c d)
(quote a b c d)
(list a b c d)
(append a b '(c d))
(add-to-list 'lst elt)
(nconc &rest lists)
(member elt lst)
(not (null (member elt lst)))
(car lst)
(cdr lst)
(car (cdr lst))
, or (cadr lst)
(nth n lst)
(setcar lst val)
(length lst)
(dolist …)
(mapconcat …)
(mapc fun seq)
(mapcar fun seq)
(assoc key lst)
Alists can be seen as simple lists with special elements (so called cons cells), representing an association between key and val.
(cons key val)
'(key . val)
(assq key alst)
(rassoc val alst)
cl-lib
): (copy-alist alst)
(stringp obj)
(string= str1 str2)
(string-match-p regexp str)
(boundp sym)
(fboundp sym)
(functionp obj)
(funcall fun args..)
(symbol-name sym)
(intern name)
(symbol-function sym)
(fset sym def)
(get sym prop)
(put sym prop val)
cl-lib
): (remprop sym prop)
(shell-command …)
(let ((process-environment ...)) (shell-command ...))
(let ((default-directory "/sudo::")) (shell-command "ls"))
(let ((current-prefix-arg '(4))) ; with C-u take symbol under point (call-interactively #'grep))) ; autoloads `grep'
current-prefix-arg
to interactively called command6)(defun my-interactive-command () (interactive) (call-interactively #'grep))
(eval `(defun rho/ispell-change-dictionary (dict &optional arg) "Do the same as original (advised) function `ispell-change-dictionary', but (in addition) update the Flyspell mode lighter with the current dictionary." ,(interactive-form 'ispell-change-dictionary) ; (interactive ...) : :
sample
mode, derived from c-mode
:;; sample-mode.el -*- coding: utf-8 -*- ;; ;; Sample Mode ;; Copyright (C) 2017 Ralf Hoppe <ralf.hoppe@dfcgen.de> ;; (defvar sample-mode-hook nil) (defconst sample-mode-syntax-table (let ((table (make-syntax-table))) (modify-syntax-entry ?\" "\"" table) ; string delimiter (modify-syntax-entry ?/ "<124" table) (modify-syntax-entry ?* "<23b" table) (modify-syntax-entry ?\n ">b" table) ; \n is comment end for (only) C++ style (modify-syntax-entry ?# "<" table) table)) (defconst sample-font-lock-keywords '(("\\(builtin1\\|builtin2\\)\\>" . font-lock-builtin-face) ("\\<\\(keyword1\\|keyword2\\)\\>" . font-lock-keyword-face) ("\\<\\(type1\\|type2\\)\\>" . font-lock-type-face) ("\\<Sample[0-9a-zA-Z_]*\\>" . font-lock-function-name-face) ("\\<\\(SAMPLE\\|Sample_\\)[0-9a-zA-Z_]*\\>" . font-lock-constant-face) )) (define-derived-mode sample-mode c-mode "Sample" :syntax-table sample-mode-syntax-table (set (make-local-variable 'font-lock-defaults) '(sample-font-lock-keywords)) (set (make-local-variable 'indent-line-function) 'c-indent-line) (setq-local comment-start "// ") (setq-local comment-end "") (font-lock-fontify-buffer) (run-hooks 'sample-mode-hook)) (add-to-list 'auto-mode-alist '("\\.sample\\'" . sample-mode)) (when (featurep 'speedbar) (speedbar-add-supported-extension ".sample")) (provide 'sample-mode)
quote
for that. For details see the article by Artur Malabarba: Get in the habit of using sharp quote.current-prefix-arg
is retained during interactive command processing.