(Emacs)-Emacs Lisp snippets

Don't use ANY of them anyway.
This commit is contained in:
2024-05-10 01:57:42 +05:30
parent d44273c668
commit 41e85002dc
151 changed files with 0 additions and 1131 deletions

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: advise function
# key: adv
# uuid: adv
# --
(defun ${3:adviser-name} (orig-fn &rest args)
${4:}
(apply orig-fn args))
(advice-add #'${1:function-name} ${2::around} #'${3:adviser-name})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: and
# --
(and $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: append
# --
(append $0)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: apply
# key: apply
# uuid: apply
# --
(apply $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: aref
# --
(aref ${1:array} ${0:index})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: aset
# --
(aset ${1:array} ${2:index} ${3:newelt})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: assq
# --
(assq ${0:sym} ${1:list})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: autoload tag
# --
;;;###autoload`(%emacs-lisp-evil-autoload)`$0

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: doom autodef tag
# key: ad
# uuid: ad
# --
;;;###autodef

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: autoload
# --
(autoload '${1:fn} "${2:file}"${3:"${4:doc}" ${5:t} ${6:type}})

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: backward-char
# key: backward-char
# uuid: backward-char
# key: bc
# --
(backward-char $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: beginning-of-line
# key: beginning-of-line
# uuid: beginning-of-line
# key: bol
# --
(beginning-of-line)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: bounds-of-thing-at-point
# key: bounds-of-thing-at-point
# uuid: bounds-of-thing-at-point
# key: botap
# --
(bounds-of-thing-at-point '$0) ; symbol, list, sexp, defun, filename, url, email, word, sentence, whitespace, line, page ...

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: buffer-file-name
# key: bfn
# uuid: bfn
# --
buffer-file-name

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: buffer-modified-p
# key: buffer-modified-p
# uuid: buffer-modified-p
# key: bmp
# --
(buffer-modified-p $0)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: buffer-substring
# key: bs
# uuid: bs
# --
(buffer-substring ${1:start} ${2:end})

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: buffer-substring-no-properties
# key: bsnp
# uuid: bsnp
# --
(buffer-substring-no-properties ${1:start} ${2:end})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: car
# --
(car ${0:})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: cdr
# --
(cdr ${0:})

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: cl-destructuring-bind
# key: cdb
# uuid: cdb
# --
(cl-destructuring-bind (${1:args})
${2:expr}
$0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: concat
# --
(concat $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: condition-case
# key: cc
# uuid: cc
# --
(condition-case ex
$>${0:}
(error $0))

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: cons
# --
(cons ${1:} $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: consp
# key: consp
# uuid: consp
# --
(consp $0 )

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: copy-directory
# key: copy-directory
# uuid: copy-directory
# key: cd
# --
(copy-directory $0 NEWNAME &optional KEEP-TIME PARENTS)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: copy-file
# key: copy-file
# uuid: copy-file
# key: cf
# --
(copy-file FILE$0 NEWNAME &optional OK-IF-ALREADY-EXISTS KEEP-TIME PRESERVE-UID-GID)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: current-buffer
# key: cb
# uuid: cb
# --
(current-buffer)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: custom-autoload
# key: custom-autoload
# uuid: custom-autoload
# key: ca
# --
(custom-autoload$0 SYMBOL LOAD &optional NOSET)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: def-package! ...
# key: dp
# uuid: dp
# --
(def-package! ${1:package}
:${2:config}
$0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: defalias
# key: defalias
# uuid: defalias
# --
(defalias 'SYMBOL$0 'DEFINITION &optional DOCSTRING)

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: defconst
# --
(defconst ${1:var} ${2:`(or % "value")`}
$>"${3:TODO}")

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: defcustom
# --
(defcustom $1 ${2:VALUE} "${3:doc}" $4)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: define-key
# key: dk
# uuid: dk
# --
(define-key ${1:keymap} ${2:key} ${0:fn})

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: defsubst
# key: defsubst
# uuid: defsubst
# --
(defsubst $0 )

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: defvar
# --
(defvar ${1:var} ${2:`(or % "value")`}
$>"${3:TODO}")

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: delete-char
# key: delete-char
# uuid: delete-char
# key: dc
# --
(delete-char $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: delete-directory
# key: delete-directory
# uuid: delete-directory
# key: dd
# --
(delete-directory $0 &optional RECURSIVE)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: delete-file
# key: delete-file
# uuid: delete-file
# key: df
# --
(delete-file $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: delete-region
# key: delete-region
# uuid: delete-region
# key: dr
# --
(delete-region $0 )

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: directory-files
# key: directory-files
# uuid: directory-files
# key: df
# --
(directory-files $0 &optional FULL MATCH NOSORT)

View File

@@ -1,17 +0,0 @@
# -*- mode: snippet -*-
# name: process marked files in dired
# contributor: Xah Lee
# --
;; idiom for processing a list of files in dired's marked files
;; suppose myProcessFile is your function that takes a file path
;; and do some processing on the file
(defun dired-myProcessFile ()
"apply myProcessFile function to marked files in dired."
(interactive)
(require 'dired)
(mapc 'myProcessFile (dired-get-marked-files))
)
;; to use it, type M-x dired-myProcessFile

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: end-of-line
# key: end-of-line
# uuid: end-of-line
# key: eol
# --
(end-of-line)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: eq
# key: eq
# uuid: eq
# --
(eq $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: equal
# key: equal
# uuid: equal
# --
(equal $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: error
# key: error
# uuid: error
# --
(error "$0" &optional ARGS)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: expand-file-name
# --
(expand-file-name $0${1: ${2:default-directory}})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: fboundp
# --
(fboundp '$0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: file-name-directory
# key: file-name-directory
# uuid: file-name-directory
# key: fnd
# --
(file-name-directory $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: file-name-extension
# --
(file-name-extension $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: file-name-nondirectory
# key: file-name-nondirectory
# uuid: file-name-nondirectory
# key: fnn
# --
(file-name-nondirectory $0 )

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: file-name-sans-extension
# key: file-name-sans-extension
# uuid: file-name-sans-extension
# key: fnse
# --
(file-name-sans-extension $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: file-relative-name
# key: file-relative-name
# uuid: file-relative-name
# key: frn
# --
(file-relative-name $0 )

View File

@@ -1,18 +0,0 @@
# -*- mode: snippet -*-
# name: a function that process a file
# contributor: Xah Lee
# --
(defun doThisFile (fpath)
"Process the file at path FPATH ..."
(let ()
;; create temp buffer without undo record or font lock. (more efficient)
;; first space in temp buff name is necessary
(set-buffer (get-buffer-create " myTemp"))
(insert-file-contents fpath nil nil nil t)
;; process it ...
;; (goto-char 0) ; move to begining of file's content (in case it was open)
;; ... do something here
;; (write-file fpath) ;; write back to the file
(kill-buffer " myTemp")))

View File

@@ -1,18 +0,0 @@
# -*- mode: snippet -*-
# name: read lines of a file
# contributor: Xah Lee
# --
(defun read-lines (filePath)
"Return a list of lines in FILEPATH."
(with-temp-buffer
(insert-file-contents filePath)
(split-string
(buffer-string) "\n" t)) )
;; process all lines
(mapc
(lambda (aLine)
(message aLine) ; do your stuff here
)
(read-lines "inputFilePath")
)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: find-file
# key: find-file
# uuid: find-file
# key: ff
# --
(find-file $0 )

View File

@@ -1,18 +0,0 @@
# -*- mode: snippet -*-
# name: find and replace on region
# contributor: Xah Lee
# --
(defun replace-html-chars-region (start end)
"Replace “<” to “&lt;” and other chars in HTML.
This works on the current region."
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (search-forward "&" nil t) (replace-match "&amp;" nil t))
(goto-char (point-min))
(while (search-forward "<" nil t) (replace-match "&lt;" nil t))
(goto-char (point-min))
(while (search-forward ">" nil t) (replace-match "&gt;" nil t))
)
)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: format
# --
(format "$0" $1)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: forward-char
# key: forward-char
# uuid: forward-char
# key: fc
# --
(forward-char $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: forward-line
# key: forward-line
# uuid: forward-line
# key: fl
# --
(forward-line $0 )

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: funcall
# key: funcall
# uuid: funcall
# --
(funcall $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: function
# --
(function $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: get
# key: get
# uuid: get
# --
(get SYMBOL$0 PROPNAME)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: global-set-key
# key: global-set-key
# uuid: global-set-key
# key: gsk
# --
(global-set-key (kbd "C-$0") 'COMMAND)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: goto-char
# --
(goto-char $0)

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: grab buffer substring
# contributor: Xah Lee
# --
(setq $0 (buffer-substring-no-properties myStartPos myEndPos))

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: grab word under cursor
# contributor: Xah Lee
# --
(setq $0 (thing-at-point 'symbol))

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: if-let
# condition: (<= (doom-snippets-count-lines %) 1)
# --
(if-let* (($1)) $0)`(doom-snippets-newline-or-eol)`

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: if-let
# uuid: if-let-2
# key: if-let
# condition: (> (doom-snippets-count-lines %) 1)
# --
(if-let (($1)) $0 `(doom-snippets-format "%n%s")`)`(doom-snippets-newline-or-eol)`

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: insert
# key: insert
# uuid: insert
# key: i
# --
(insert $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: insert-file-contents
# key: insert-file-contents
# uuid: insert-file-contents
# key: ifc
# --
(insert-file-contents $0 &optional VISIT BEG END REPLACE)

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: interactive
# uuid: int
# --
(interactive)$0

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: interactive
# --
(interactive$1)$0

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: kbd
# --
(kbd "${0:}")

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: kill-buffer
# key: kill-buffer
# uuid: kill-buffer
# key: kb
# --
(kill-buffer $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Henrik Lissner (henrik.io)
# name: lambda shortcut
# key: lam
# uuid: lam
# --
(λ! $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: length
# --
(length $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: line-beginning-position
# key: line-beginning-position
# uuid: line-beginning-position
# key: lbp
# --
(line-beginning-position)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: line-end-position
# key: line-end-position
# uuid: line-end-position
# key: lep
# --
(line-end-position)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: list
# --
(list $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: looking-at
# --
(looking-at $0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: make-directory
# key: make-directory
# uuid: make-directory
# key: md
# --
(make-directory $0 &optional PARENTS)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: hash
# key: mht
# uuid: mht
# --
(make-hash-table${1: :test '${2:equal}})

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: make-local-variable
# key: make-local-variable
# uuid: make-local-variable
# key: mlv
# --
(make-local-variable $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: mapc
# --
(mapc ${1:fn} ${0:list})

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: mapcar
# --
(mapcar ${1:fn} ${0:list})

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: match-beginning
# key: match-beginning
# uuid: match-beginning
# key: mb
# --
(match-beginning N$0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: match-end
# key: match-end
# uuid: match-end
# key: me
# --
(match-end N$0)

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: match-string
# key: match-string
# uuid: match-string
# key: ms
# --
(match-string $0 )

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: memq
# --
(memq ${0:sym} ${1:list})

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: message
# key: m
# uuid: m
# --
(message "${1:}"$0)

View File

@@ -1,21 +0,0 @@
# -*- mode: snippet -*-
# name: minor_mode
# key: minor
# uuid: minor
# --
(defvar ${1:mode}-modeline-indicator " ${2:INDICATOR}"
"call ($1-install-mode) again if this is changed")
(defvar $1-mode nil)
(make-variable-buffer-local '$1-mode)
(put '$1-mode 'permanent-local t)
(defun $1-mode (&optional arg)
"$0"
(interactive "P")
(setq $1-mode
(if (null arg) (not $1-mode)
(> (prefix-numeric-value arg) 0)))
(force-mode-line-update))
(provide '$1-mode)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: not
# --
(not $0)

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: nth
# --
(nth ${0:n} ${1:list})

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: &optional ...
# uuid: optional
# --
&optional $0

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: or
# --
(or $0)

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: point
# key: pt
# --
(point)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: point-max
# uuid: point-max
# key: pma
# --
(point-max)

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: point-min
# uuid: point-min
# key: pmi
# --
(point-min)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: princ
# key: princ
# uuid: princ
# --
(princ $0)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# contributor: Xah Lee (XahLee.org)
# name: print
# key: print
# uuid: print
# --
(print $0)

Some files were not shown because too many files have changed in this diff Show More