Towards Freedom

Information, Inspiration, Imagination
truly a site for soaring Is


Various topics and aids for emacs

WHERNTO: techniq  operate 

image of Emacs

We belong to the church of emacs which we feel is the ultimate editor!



  ;; apropos
  M-x apropos Display all symbols matching a pattern
  C-h a Search only commands (apropos-command)
  C-h d Search docs (apropos-documentation)
  M-x apropos-library Useful for new mode or package
  M-x apropos-value Useful if you know value not variable

  ;; describes
  C-h m Mode major/minor, keybindings (describe-mode)
  C-h x Commands (describe-command)
  C-h f Functions (describe-function)
  C-h v Variable (describe-variable)
  C-h k Key detail (describe-key)
  C-h c Key brief (describe-key-briefly)

  ;; info
  C-h i Open info manual
  C-h i d m <item> RET i <topic> RET Indices search
  C-h i d m <item> RET s <topic> RET Regexp search
  C-h r m <topic> Direct way to emacs info
  M-x info-apropos searches for item in all info
  M-x info-display-manual get manual by name (or tab for list)
  M-x info-finder uses list of keywords to find things

  ;; various
  C-h p Packages list
  C-h e Messages buffer
  C-h o Symbol docs at point or type it
  C-h s Current syntax table !!!

  M-x manual-entry RET manpage Get a manpage
  <prefix> C-h all prefix possibilities


C-x r m set bookmark
C-x r b jump to bookmark
C-x r l list bookmarks
M-x bookmark-delete


  M-c Word capitalize
  M-u Word ucase
  M-d Word dcase
  C-x C-u Region ucase
  C-x C-l Region lcase
  M-x upcase-initials-region Which is strange for most situations.


  M-; Comment single/double/region/uncomment
  C-x C-; Double comment (lisp)/uncomment
  M-x comment-box

Various variables can be customized as well to suit requirements.


  M-= Words (buffer or region)
  M-x count-lines-region
  M-x count-matches


Only most useful bindings here. (See dired section for more)

;; commands on files
! Any command on a file
! cmd * > newfile will have output of cmd on * (cursor file)

;; compare files
=  goto file, =, enter other file (figure out how diff works !!!)

;; enter a dir
C-x (4|5) d ~/ new window|frame
C-x d ~/*|.*|D* all|hidden|starting with D files

;; markings
m mark
d mark for deletion
t toggle marks
u,U unmark
M-del unmark all
%d regexp for deletion
~|# bkp|auto-save for deletion
%m regexp flag
%g regexp contained in files
*s|/|.|@ mark all|dirs|ext|sym

;; move
j move to file
(M-)C-s (regexp)search
M-{|} up|down to marked
^ move to parent dir
<|> move to prev|next dir

;; specific commands on marked items
C|D|P|R copy|delete|print|rename
G|M|O dired-do-chgrp|chmod|chown
A|Q regexp search|query replace
!|& shell command on files sync|async
%u|l upper|lower
S|Y|H links sym|relsym|hard

;; subdirs
i insert subdir
C-u k remove subdir
$ fold subdir
M-$ fold all dirs
C-M p|n go to prev|next subdir
C-M-d go to first child subdir

;; view directory
C-u s change ls flags
i put cursor dirs into same buffer

;; visit
e|f same window find
o other window find (C-o don't move there)
v read only
^ parent dir
a descend discarding parent  
W guess default application

;; zzmisc
h help
? prompt for choice delete,copy,find ...
B|L byte-compile|load elisp files

k dired-do-kill-lines don't delete !!!


  ;; rg
  C-c s gives menu to do various greps

  ;; helm ag
  M-g s	helm-do-grep-ag (alt to C-s)

  ;; grep
  M-x grep Prompts for item and files
  M-x grep-find Uses find and -exec grep
  M-x lgrep Prompt through each step
  M-x rgrep Recursive search


C-x c (prefix) C-g (exit usually)

  ;; helmed key bindings
  M-x helm-M-x
  M-y helm-show-kill-ring
  M-s o helm-occur
  C-x C-f helm-find-files
  C-x C-b helm-multi-files (use to switch buffers)
  C-spc mark buffers
  M-D delete marked buffers
  C-c g	helm-google-suggest
  M-g f	helm-do-grep-ag (alt to C-s)

  ;; helm prefixed
  / helm-find files recursively from pwd
  @ helm-list-elisp-packages
  f helm-multi-files buffers,recent,bookmarks,pwd (C-x C-b)
  l helm-locate locate through helm
  r helm-regexp build regexp for find in file

  ;; help indices
  h g helm-info-gnus
  h h helm-documentation
  h i helm-info-at-point
  h r helm-info-emacs


  M-q Fill paragraph
  C-u M-q Fill and justify
  C-x f Set fill width
  C-x . Set fill prefix (for each fill line)
  M-x auto-fill-mode (likely best for text production)


  C-x i Insert file
  C-x x i Insert buffer (since all buffers aren't files)


  M-d Word forward from point
  C-<back> Word backward from point
  C-k To end of line
  C-S-k To beg of line
  M-k Rest of paragraph

M-y TAB will show kill ring in buffer for yank.


  F3 record beg
  C-u F3 record beg and append to last
  F4 record end | play last
  C-u F4 play 2nd
  M-<N> F4 play last N times

  C-x C-k n names last
  C-x C-k b binds last to key
  M-x insert-kbd-macro pastes into buffer
  C-x C-k e edits last


  M-@ Word (M-- backward)
  M-h Paragraph (M-- backward)
  C-x h Entire buffer
  C-x C-p Next page

  in ibuffer
  % n - Mark buffers by their name, using a regexp.
  % m - Mark buffers by their major mode, using a regexp.
  % f - Mark buffers by their filename, using a regexp.
  % g - Mark buffers by their content, using a regexp.
  % L - Mark all locked buffers.

Often unnecessary, except copying region or kill/copy weird shaped regions.


  ;; smaller movements
  M-m Line beg (regardless of indent)
  C-a Line beg
  C-e Line end
  M-a Sentence beg
  M-e Sentence End
  M-{ Pargraph next beg
  M-} Paragraph next end

  ;; larger movements
  M-i Use imenu
  M-r Cycle position point bot-mid-top
  C-l Cycle center point to bot-mid-top
  M-g M-g go to line number

  ;; sexp movements!!!
  C-M-d Down into list
  C-M-u Up out of list
  C-M-n Forward to next list
  C-M-p Backward to prev list
  C-M-h Next defun
  C-M-@ Next sexp
  C-M-f Forward by sexp
  C-M-b Backward by sexp
  C-M-a Descend into sexp


  C-s|r Use isearch forward|reverse
  C-M-s|r Use isearch regexp
  M-% Query search options
  C-M-% Query regexp options
  M-s Replace string
  M-r Replace regexp
  !!! c|r|w|_|'|SPC Toggle various modes!!!
  !!! C-w Add word at point to search (??!!!)

Note case folding effect. Regexps are fine for simple search/replace, but for heavy-duty stuff emacs/elisp is likely not the best option. So, we should use perl or clojure from the outside.

text manipulation

  ;; duplicates in region
  M-x delete-duplicate-lines With 3 C-u options

  ;; keep, flush, copy in region by regexp
  M-x flush-lines
  M-x keep-lines
  M-x copy-matching-lines
  M-x kill-matching-lines

  ;; kill
  C-k kill to end of line
  C-; kill to beg of line
  ;; occur
  M-x occur Choose e option to edit

  ;; join and split lines
  C-o Inserts blank line after point with possible split
  C-M-o Splits line at point keeping indent
  C-x C-o Deletes all blank lines after point
  M-^ Joins with line above

  ;; whitespace
  M-SPC Cycle spacing instead of just-one-space
  M-\ Deletes whitespace around point
  M-x delete-trailing-whitespace
  M-x whitespace-report(-region)
  M-x whitespace-cleanup(-region)


  C-t Characters
  M-t Words
  C-x C-t Lines
  C-M-t Sexps
  M-x transpose-paragraphs
  M-x transpose-sentences


  C-/ Undo
  C-? Redo
  C-x u Undo-tree-mode if activated !!!

view interfaces

  ;; buffer view
  C-x M-b View buffers (use ibuffer)

  ;; other buffer use
  C-x 4 C-f Find file
  C-x 4 C-o Open other buffer
  C-x 4 d Dired
  C-x 4 b Choose and activate other buffer
  C-x 4 0 Kills buffer and window
  C-x 4 p Project command !!!

  ;; window use
  C-x 0..3 Delete and split windows
  C-x o Switch active window (mapped to M-o)
  C-x left|right Cycles buffers
  C-c left|right Goes to other configurations with winner-mode

  ;; other frame use !!!
  C-x 5 2 New frame
  C-x 5 0 Delete active frame
  C-x 5 1 Delete other frames
  C-x 5 C-f Find file
  C-x 5 d Dired
  C-x 5 o Buffer in other frame
  C-x 5 p Project in other frame


  C-x C-f visit file
  C-x C-f C-f visit new buffer (no ido)


cl is deprecated, use cl-lib in the autocapitalize.el file

codeium crane

Codeium is a free AI software that offers developers code completion, chat, and search capabilities in over 70 languages across 40+ integrated IDEs. We set up codeium.el for Emacs with corfu.el (a completer frontend), cape.el (which provides useful functions for completion), and eglot (the emacs client for language server protocol). The code is modified from the very helpful jeff-phil setup and much of the annotation is provided by Perplexity AI (though edited).

While there is considerable and grateful plagerization from various sources, some of the code has been re-written for my own purposes.

The init-codeium.el page begins with the following requires, before getting into the actual code:

  (require 'codeium)
  (require 'corfu)
  (require 'cape)
  (require 'eglot)

Idealings with codeium

Code below sets up various configurations and functions for the Codeium package in Emacs. It enables Codeium for code completion globally, configures the mode line display, sets up filters for API calls, and defines functions to retrieve the document text and cursor offset for better performance. The annotations explain the purpose and functionality of each part of the code.

;; The code below sets up various configurations and functions for the
;; Codeium package in Emacs. It enables Codeium for code completion
;; globally, configures the mode line display, sets up filters for API
;; calls, and defines functions to retrieve the document text and
;; cursor offset for better performance. The annotations explain the
;; purpose and functionality of each part of the code.

;; Add Codeium completion function to completion-at-point-functions
(add-to-list 'completion-at-point-functions
;; Adds the Codeium completion function to the list of functions
;; called when trying to complete text at point, making Codeium
;; available for code completion globally.

;; Do not use popup boxes
(setq use-dialog-box nil)
;; Disables the use of popup boxes, as Codeium likely uses other means
;; of displaying information.

;; Configure Codeium mode line
(setq codeium-mode-line-enable
      (lambda (api)
        (not (memq api '(CancelRequest Heartbeat AcceptCompletion)))))
(add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t)
;; Configure Codeium to display its status in the mode line, filtering
;; out certain API calls (CancelRequest, Heartbeat, AcceptCompletion)
;; from being displayed. Doing so can be useful for debugging or
;; monitoring purposes.

;; Filter for enabled Codeium API calls
(setq codeium-api-enabled
      (lambda (api)
        (memq api
              '(GetCompletions Heartbeat CancelRequest
                               GetAuthToken RegisterUser
                               auth-redirect AcceptCompletion))))
;; Sets a lambda function to filter for enabled Codeium API calls,
;; allowing only certain API calls (GetCompletions, Heartbeat,
;; CancelRequest, GetAuthToken, RegisterUser, auth-redirect,
;; AcceptCompletion) to be processed.

;; Set document text for better performance
(setq codeium/document/text
      (lambda ()
         (max (- (point) 3000) (point-min))
         (min (+ (point) 1000) (point-max)))))
;; Sets a function to retrieve the document text for Codeium,
;; retrieving a portion of the buffer text around the current point
;; (up to 3000 characters before and 1000 characters after) to improve
;; performance.

;; Set cursor offset for better performance
(setq codeium/document/cursor_offset
      (lambda ()
          (max (- (point) 3000) (point-min)) (point)))))
;; Sets a function to calculate the cursor offset for Codeium,
;; calculating the byte length of the text from the start of the
;; document text up to the current point, likely used by Codeium to
;; determine the position of the cursor within the document text.

Landing on corfu

The setup here is quite simple since we only enable auto-completion and provide global availability for corfu.

(setq corfu-auto t)                     ;enable auto completion
(global-corfu-mode)                     ;enable corfu-mode globally

Weaving the capestry

The cape package is a completion engine that provides numerous completion commands in various situations and each has its own keybinding. Uncomment any of the items below to enable.

[TODO: We don't know what a lot of these items do since we adapted the code from the cape.el page.]

  ;; Bind dedicated completion commands
  (global-set-key (kbd "C-c p p") 'completion-at-point) ;; capf
  (global-set-key (kbd "C-c p t") 'complete-tag)
  (global-set-key (kbd "C-c p d") 'cape-dabbrev)
  (global-set-key (kbd "C-c p h") 'cape-history)
  (global-set-key (kbd "C-c p f") 'cape-file)
  (global-set-key (kbd "C-c p e") 'cape-elisp-block)
  (global-set-key (kbd "C-c p k") 'cape-keyword)
  ;; (global-set-key (kbd "C-c p a") 'cape-abbrev)
  ;; (global-set-key (kbd "C-c p l") 'cape-line)
  ;; (global-set-key (kbd "C-c p w") 'cape-dict)
  ;; (global-set-key (kbd "C-c p :") 'cape-emoji)
  ;; (global-set-key (kbd "C-c p s") 'cape-elisp-symbol)
  ;; (global-set-key (kbd "C-c p \\") 'cape-tex)
  ;; (global-set-key (kbd "C-c p _") 'cape-tex)
  ;; (global-set-key (kbd "C-c p ^") 'cape-tex)
  ;; (global-set-key (kbd "C-c p &") 'cape-sgml)
  ;; (global-set-key (kbd "C-c p r") 'cape-rfc1345)

  ;; Add to the global default value of `completion-at-point-functions'
  ;; which is used by `completion-at-point'. The order of the functions
  ;; matters, the first function returning a result wins.  Note that the
  ;; list of buffer-local completion functions takes precedence over the
  ;; global list. However, since we don't really know what most of these
  ;; are for, we are just commenting them out.
  (add-hook 'completion-at-point-functions #'cape-dabbrev)
  (add-hook 'completion-at-point-functions #'cape-history)
  (add-hook 'completion-at-point-functions #'cape-file)
  (add-hook 'completion-at-point-functions #'cape-elisp-block)
  (add-hook 'completion-at-point-functions #'cape-keyword)
  ;; (add-hook 'completion-at-point-functions #'cape-tex)
  ;; (add-hook 'completion-at-point-functions #'cape-sgml)
  ;; (add-hook 'completion-at-point-functions #'cape-rfc1345)
  ;; (add-hook 'completion-at-point-functions #'cape-abbrev)
  ;; (add-hook 'completion-at-point-functions #'cape-dict)
  ;; (add-hook 'completion-at-point-functions #'cape-elisp-symbol)
  ;; (add-hook 'completion-at-point-functions #'cape-line)

One capf to joule them all

The my/capf-for-all alias is used for the cape-capf-super function for better clarity. The code sets the cape-capf-properties are set for codeium and dabbrev (though more can be added).

  (defalias 'my/capf-for-all
  ;; Create an alias 'my/capf-for-all' for the following expression
  (cape-capf-super                      ;Combine multiple completion sources using cape-capf-super
   (cape-capf-silent                    ;Suppress the annotation for the following completion sources

    ;; Set properties for the codeium-completion-at-point function
    (cape-capf-properties #'codeium-completion-at-point
                          ;; Define an anonymous function to provide the annotation
                          #'(lambda (_) (propertize "  odeium"
                                                    'face font-lock-comment-face))
                          ;; Set the company-kind property to 'magic'
                          ;; It is a cape property specifying type of completion candidate
                          ;; not really required, but can provide a better visual experience
                          :company-kind (lambda (_) 'magic)))

   ;; Prevent duplicates from the eglot-completion-at-point function
   (cape-capf-buster #'eglot-completion-at-point 'equal)

   ;; Set properties for the cape-dabbrev function
   (cape-capf-properties #'cape-dabbrev
                         ;; Define an anonymous function to provide the annotation
                         #'(lambda (_) (propertize " Dabbrev"
                                                   'face font-lock-comment-face)))

   ;; if line gets too chatty
    ;; Suppress the annotation for the following completion source
    (cape-capf-properties #'cape-line
                          ;; Set properties for the cape-line function
                          ;; Define an anonymous function to provide the annotation
                          #'(lambda (_) (propertize " Line"
                                                    'face font-lock-comment-face))))))

Engaging in eglottony

Completion settings for eglot managed modes are configured here pulling everything together to work with eglot.

  (defun my/eglotted-modes-config ()
    "Configuration of settings for eglot-managed modes"
    (setq-local completion-category-overrides '((file (styles partial-completion)))
                ;; Set completion-category-overrides for file category
                completion-category-defaults nil
                ;; Clear completion-category-defaults
                completion-styles '(orderless partial-completion basic)
                ;; Set completion styles
                completion-at-point-functions (list #'cape-file 'my/capf-for-all)
                ;; Set completion-at-point-functions to include cape-file and my/capf-for-all

  ;; Finally, add the my/eglotted-modes-config function to the
  ;; eglot-managed-mode-hook so it gets called when eglot runs.
  (add-hook 'eglot-managed-mode-hook #'my/eglotted-modes-config)

This setup is mainly to get codeium to work on clojure scripts with eglot as the language server client. When programming elisp though we don't need capfs and eglot. In fact, the codeium.el page provides code to work with elisp (see cl-letf* function towards the bottom).

[TODO: try to get codeium to work with shell better.]


Several have been examined including ido|fido, vertico, ivy, but none offer as much as helm. Though it may have been slow on old computers, speed is not an issue now.


wiki Doing things in helm is different from vanilla emacs:

  • use windows rather than minibuffer
  • use pattern rather than <tab>
  • <tab>|C-i gives available actions
  • C-j|C-z persistent action (helm buffer persists)
  • in a helm buffer, marking is not done with m
  • embedded help in org buffer with C-h m

Certain emacs commands have been helmed.


Though built-in and mostly nice, the ido-switch-buffer doesn't always work. The ido flex matching was excellent for the most part, though it could get confusing in some situations (helm's locate is far better - almost as powerful as recoll file find or fzf fuzzy find.) Though fido is also built-in, we found no real advantage to it.


It is supposed to be an ido|ivy replacement forked from selectrum, but doesn't seem to have any real advantages. Easy to get up and running, but not so easy to figure out how to optimize things. One advantage is it works with existing emacs bindings.


We use to use this as well as icicles many years ago, but switched to ido because things weren't as messy.

daemon as systemd

$ systemctl –user enable –now emacs cp usr/lib/systemd/user/emacs.service .config/systemd/user systemctl enable –user emacs

default editor


Edit directories with emacs which is possibly far more useful than we ever thought. Reference Card pdf.


C-x d from eshell or provide a pattern!

  C-x (4|5) d ~/
  C-x d ~/*
  C-x d ~/.*
  C-x d ~/D*
  C-x d ~/**/*.el ;globstar should work but doesn't
  C-x (4) C-j if done in dired gives parent dir


j <==> C-x C-f
M-s f (M-)C-s searches just for filename (or change dired-isearch-filenames to t)


DEL doesn't work
d,u,x does (on regions too)
m,D is an alternative

multiple flagging

#,~,. probably not going to use
% g flag garbage files .log, .toc, .dvi, .bak ...
% d regexp very nice!!

toggle hidden files

C-u s and -al -> -l or may be this [][Toggle Showing Dot Files]

visiting files

v readonly view

not same as openwith which can be done in various ways, but simplest for now is M-! <app> file.
this isn't as convenient as nnn, but should do for now. dired+ apparently has a way to do this.

visit dir

use a instead of C-m to discard ancestors use C-x C-j to jump to parent (but that will leave trail), so go to .. and use a

dired marks and flags

these offer many possibilities, but are awkward to remember right now.

  m can do region or C-u N as well
  * N number and size of files in marked region
  * * mark exe files
  * @ mark slinks
  * s mark all in dir
  * / mark dirs
  U remove all marks

  mark by regexp
  % m|g
  % d

  some of these may be useful though we can't see why right now:\\
  * t toggle
  M-{} move up/down to next marked file
  C-/ undo dired changes
  * c old new: * c D t  * c SPC D  * c t SPC

operating on files

C new
R new to existing dir (dired-create-destination-dirs)
S new

A regexp very nice!!
Q regexp very nice!!

% u,l upper,lower case filenames

probably not useful at this stage
M modespec
G newgroup
O newowner

transforming filenames

% R,C,H,S computes new name by regexp doing a search-replace not sure how important this is since we can treat the dir as emacs buffer


C-u k


Go to item symlink points to

find and locate

these are done from dired

M-x find-name-dired
M-x locate

view images

C-t d on marked image files
M-x image-dired

rotations possible with jpegtran

delete and tag of image files also possible, so can this replace gthumb!!!

other features

M-x dired-create-empty-file
M-x dired-compare-directories
M-s a C-s isearch on filenames


Elfeed Emacs Web Feed Reader How to Use Emacs for RSS with Elfeed A workflow for reading, managing and discovering ML research papers with Emacs Note taking 3: Notes from elfeed entries !!!

Setup init-elfeed.el with:

  • vars for urls (because they can get very long and look messy)
  • the feeds var elfeed-feeds
  • the update var elfeed-search-update gets the feeds
  • delete feed by removing it on M-x customize elfeed-feeds

index mechanism

trying to figure out how to search the feeds from .elfeed in data/1d/1da2ce0dd6436d802f0e1b35ad60f8b745780a5b in index "" nil) ("" . "") #s(elfeed-entry ("" . "") "Elasticity to position microplates on curved 2D fluids" "" 1617649345.0 #s(elfeed-ref "1da2ce0dd6436d802f0e1b35ad60f8b745780a5b") html nil (unread)

There is likely no benefit to recolling the entire .elfeed dir because

  • we really don't want all the feeds
  • those that we do want probably don't have enough text content
  • the title of the article contains most of the info and that is already searchable

Saving specific articles to zitems may be useful, so an elisp script does the job mostly written by perplexity!

emailing a buffer

C-ret to setup email C-M-p to prger

setup init-elfeed

use variable for feeds remove titles, but set them as tags (setq aiblog <URL>) though we did have (setq aiblog (list <URL> <TITLE)) title now "" and set as a tag

regex group replacement

(car aiblog) -> aiblog (car \(......\)) -> \1


some of these items apply to emacs in general.


occur <regex> displays matching items in history

cd =, cd =foo, cd -N are excellent for moving into directories!

sudo works using eshell/sudo, but as an alias (eshell-prefer-lisp-functions didn't work)

built-in variables:
$+, $-, $$, $? (with ending underscores), may be useful for scripting
also, note specific args handling with $*, $1, $2 …

eshell to have $PATH

;; match zshenv PATH (setenv "PATH" (shell-command-to-string "echo -n $PATH"))

that seems a lot simpler (not sure if it will work either), however, we did it another way by

  • echo $PATH > tmp
  • edit tmp
  • PATH=$(cat tmp)

after the above in zsh, we go to eshell and

  • (setq path <copied from echo $PATH>)
  • (setq exec-path (split-string path ":"))


  (setq var "this is a string with extension.test")
  $'var' disambiguate
  $#var length

  $(sexp) can be used in a string
  ${cmd} output of cmd
  $<cmd> output to tmpfile

  $var[i] ith element of sequence (string split on spc)
  $var[: n0 n1 n2 ...] split on : ;interpolation into larger string !!!
  $var["\\\\" i] ;!!!
  $var["[0-9]+" 10 20] ;!!!
  $var[hello] ;!!!
  $#var[hello] ;!!!

fix the history!! issue

customize eshell-expand-input-functions by INS eshell-expand-history-references t

for loop

  for VAR in TOKENS { command invocation(s) }
  for i in (split-string
            (shell-command-to-string "cat /etc/passwd") "\n")
  {(print (string-join (list i "BOO") " "))}


help on function at point: C-h f


M-p|n works as expected

M-r|s is a bit awkward compared to C-r in regular shell, though there may be a better way

unlike C-r in a regular shell, M-r doesn't keep cycling back … need to figure out how to deal with this

TODO pcomplete

not sure what this is completion concept


mostly same as zsh, but we also have these neat items

  >>> #<buffer-name>
  - > /dev/clip

as well as being able to define virtual targets with ("/dev/name" function mode)


use source from eshell and eshell-source-file from rest of emacs

ssh to remote

C-x C-d /ssh:lentil: M-x eshell and it works perfectly!

sudo issue

which sudo give /usr/bin/sudo - even when lisp functions are prefered !!!!! so we use an alias sudo eshell/sudo $* apparently the documentation is misleading

alias sff find-file /sudo::$1

ess and paredit

these two don't play nicely and you get c () so remove paredit from .R files and things seem to be just fine


The browser is quite impressive doing what it is primarily designed for - browsing simple sites and reading docs. However, some of the keybindings and commands don't seem to work. Not an important matter though since we likely won't use it much.


There is a fly for spelling, flyspell, and 2 for code syntax checking, flymake (builtin to emacs), flycheck (from elpa).


Used for spell checking and allows adding to the dictionary.


Used for checking code syntax and works with LSP servers through clients like lsp-mode and eglot.


Does the same as flymake, but presumably works better and with more languages (eg sh-zsh). The checking seems to be automatic, but with lsp I'm not sure if it is required. Quite possibly flymake is sufficient, but we should test both out. Lsp uses flycheck if it is available automatically, so we don't have to specify that flymake be hooked for a language.


fetch and deliver mail it is MDA which can fetch simple config for our notmuch purposes

following symlinks

C-h v vc-follow-symlinks and change the value this will handle git asks when opening a file !!!



doesn't handle C-c C-a synopsis unless there is a blank line macro fynopsis takes care of this and is bound this way: (add-hook 'fountain-mode-hook ; enters synopsis for screenplain issue (lambda () (local-set-key (kbd "C-c C-a") 'fynopsis)))


These search for occurrences of pattern in the buffer and/or in files.

emacs grep is good and straightforward to use from the menu requiring only a pattern and a directory of files.

helm ag M-g f will give pattern at|before point by default for the directory, so it can do much the same job as rg, but only on the directory you are already in. It is faster to use, if you want to search pwd only and not some other directory, since you have to go there, whereas C-c s with rg let's you setup in whatever directory you want to.

rg C-c s is supposed to be faster with better customization. Though deadgrip was fine (and we like the rip pun), it was awkward to get into the directory we wanted. The rg package offers many more features and is into higher versions.

We find rg to be easier to setup and use too - with a guiding menu after C-c s and the docs are quite thorough as well.

To use ripgrep instead of grep see article. At this point, we see no real advantage to replacing grep with ripgrep. The code to insert in init.el is something like this:

  '("rg -n -H --no-heading -e '' $(git rev-parse --show-toplevel || pwd)" . 27))

Don't need to do this though because (require 'rg) (rg-enable-default-bindings)

is quite sufficient to work with rg and also have grep around.

searchers work only in the buffer and include C-s|r and M-x occur which will make a buffer with links for the pattern, so it gives you the same thing that search does, but in a separate buffer and with every occurrence rather than forward C-s or reverse C-r.


Delete multiple buffers quickly

  • % n|m <> RET
  • D y

junk deposit issue

emacs -nw producing [Ihello] and other junk on first line

this is happening because of the line in init-modes.el

  (sp-pair "[" "]" :wrap "M-[")

other braces {} () don't seem to have any issues

key (un)bind

(global-set-key (kbd "C-M-.") 'eshell)
(global-unset-key (kbd "C-M-."))



open the pdf update in lilypond, then refresh with F5

xpdf -open

this works quite well until it is unable for some reason to create a remote socket. however, the problem can be nullified by: rm /tmp/default which removes the socket process (i guess?) unfortunately, when operating as a server, the textedit:// feature does not work as effectively though you still get the line number of where you want to go to in the .ly file.


Lilypond-midi-player variable set to timidity|fluidsynth 


External links to webpages work fine, but internal links to headings within the same page seem to be an issue when hugo exports them to html.

To setup an internal link within a document:

  • go to link and M-x org-store-link
  • go to place to insert link and M-x org-insert-last-stored-link

Such an arrangement works find inside orgmode, but hugo doesn't manage to export it correctly at present (2023-08-02).


the idea will be to use search/tag rather than folders to get things done


%notmuch setup -> ~/.notmuch-config used to have .emacs.d/notmuch-config.el with mainly the Q binding, but that is now in init-email.el


emacs -e "notmuch" with client it used to be different: emacsclient -e "(elfeed)" -e "(notmuch)" & emacsclient -c ~/aa/ &

various commands

search|show|address|count reply tag dump|restore config


(global-set-key (kbd "<f5>") 'org-mime-edit-mail-in-org-mode) use to open a second window and write in orgmode C-c C-c will update orgified buffer to the original

(global-set-key (kbd "C-<f5>") 'org-mime-htmlize) htmlize the orgified buffer before sending with C-c C-c (as before)


wildcards using '*' operators +|-|AND|NOT|XOR|OR| brackets proximity NEAR ADJ phrases "Debian Project" <=> Debian ADJ/1 Project prefix freeform idea, but uses full item eg from: instead of f: range date:yr-mo-da..yr-mo-da | | yesterday

man notmuch-search-terms

fetch/trash mechanism

use f|c|p|t

f files are left on server but not duplicated

  1. fdm fetch will remove them from server
  2. polls
  3. trash require 'S' on emails then t moves them to ~/.trash

be careful using c) because if you read using spark or whatever on the server and leave the item as read, then using this removes them from the server, but we're not sure where the email actually goes! yes we are now!!

we must be sure that we are running nmp from ~/ otherwise mail/ will be created wherever we are!

autocomplete email addresses

chose to use bbdb and use bbdb-vcard with contacts.vcf exported from google Go to, click the menu "Export…>>vCard format (blah, blah …)". Click "Export" button. Download the contacts.vcf. Make sure bbdb-vcard.el installed. In Emacs run "M-x bbdb-vcard-import-file" and input the full path of contacts.vcf In Emacs run "M-x bbdb-save" Import Gmail contacts into BBDB

gnus-alias to select identity didn't set rules use M-x gnus-alias-select-identity

external handlers for attachments

w - to save the attachment - though the default doesn't always seem to work. . o allows reading the item provided you specify the type

sending email

evolution removals

for some reason, the setup for smtp wasn't being picked up in the init.el file and that is why evolution kept coming up. instead of smtpmail-send-it the setting had changed to mailclient-send-it. this is nice to know in case we should ever require it in the future.

;; smtp (setq smtpmail-default-smtp-server "" send-mail-function 'smtpmail-send-it user-full-name "prad" smtpmail-local-domain "" user-mail-address "") (require 'smtpmail)

otherwise it defaults to evolution because gnome sets it, though we can change it to notmuch through settings.

vivaldi mail issue

however, what is the problem replying to vivaldi? no issues sending to vivaldi or replying to any other place it seems. changing the smtp to "" sent, but still the same problem with replying to vivaldi!

<2021-06-21 Mon> we are sending emails through because shawmail wouldn't send (even though it appeared to do so).

2 items noted:

  1. gnus alias setup is sufficient (no need for msmtp) ("tf" nil ;; Does not refer to any other identity "prad <>" ;; Sender address "" ;; Organization header (("X-Message-SMTP-Method" . "smtp 587")) nil ;; extra body text "~/.signature") ("fm" ;;formal tf nil "prad basu <>" "prad basu" ;; Organization header (("X-Message-SMTP-Method" . "smtp 587")) nil ;; No extra body text "~/") ("vv" nil "prad <>" "prader" ;; Organization header (("X-Message-SMTP-Method" . "smtp 587")) nil ;; No extra body text "~/.signature.vv") )
  2. mail-host-address (setq mail-host-address "localhost") couldn't figure out how to change it via smtp on gnus-alias, but that's probably not important however, we need this to prevent Message ID <87lf72na5y.fsf@schnell.i-did-not-set–mail-host-address–so-tickle-me> doing ("Message-ID" . "") didn't work though it did get the item in there. receiving end produced: Message ID <>

still getting a spf softfail: send from vivaldi -> tf reply from tf -> vivaldi don't know why, but it probably doesn't matter.

also unclear why .authinfo required vivaldi smtp info but nothing for tf



org macros

github link The macros in Org allow you to add text or code to an Org document that will be expanded during export: the text between the 3 pairs of accolades is expanded so that readers can see it in the exported versions of the document.

Some people (such as me) use it to construct complex HTML or LaTeX code.

13.5 Macro Replacement

the .#file issue with org-agenda-files

When that variable is set to ~/aa/*.org various files within the aa directory kept appearing making cycling awkward. We haven't found out why though the problem started around <2023-07-22 Sat> for some reason. Possibly, having the default ~/org directory would have caused those files to end up there (which really isn't the best solution). Setting the default org-directory to aa seems to have worked albeit the idea is pretty counter-intuitive.

org agenda

Cycle the org agenda directory with C-' (which seems to be a default setup). packages

melpa vs melpa-stable

Packages are identified when we look at M-x package-list-packages

update packages

M-x list-packages and it will automatically refresh the archive contents.

Then, press U to mark all upgradable packages to be upgraded.

Last, press x to perform the new updates.

Emacs will then download and install all upgradable packages. It will also ask you whether to delete the old packages: M-x package-autoremove

Doing it this way seems better than package-refresh-contents package-install (if package-reinstall doesn't work)


If ; isn't a separator by default: C-u C-u C-u C-c | ; RET


removing packages

To remove unnecessary or unwanted packages in Emacs, follow these steps:

  1. Open Emacs.
  2. Press `M-x` (Alt + x) to invoke the command prompt.
  3. Type `package-list-packages` and press Enter.
  4. In the Packages buffer, locate the packages you want to remove.
  5. Mark them for deletion by pressing `d` (package-menu-mark-delete).
  6. Execute the deletion by pressing `x` (package-menu-execute).
  7. Confirm the removal when prompted in the mini-buffer.

This process will remove the actual files associated with the packages from the `~/.emacs.d/elpa` directory¹. Happy cleaning! 🧹🚀

Source: Conversation with Copilot, 6/18/2024 (1) How to remove an installed package in Emacs (ver 24+)?. (2) uninstallation - How remove emacs full? - Stack Overflow. (3) Package Menu (GNU Emacs Manual). (4) apt - how to uninstall emacs from command line? - Ask Ubuntu. (5) Uninstalling a package and all of its dependencies - Emacs Stack Exchange.

update packages

Certainly! To update packages in Emacs, follow these steps:

  1. Open Emacs.
  2. Type `M-x list-packages` and press Enter. This command lists all installed packages and automatically refreshes the package archive contents.
  3. In the Packages buffer, press `U` to mark all upgradable packages.
  4. Finally, press `x` to perform the updates. Emacs will download and install the new versions of the packages. It will also prompt you to delete the old packages if necessary¹².

Happy updating! 🚀🔧

Source: Conversation with Copilot, 6/18/2024 (1) elpa - Updating packages in Emacs - Stack Overflow. (2) How to upgrade packages installed by ELPA in Emacs?. (3) Keeping Your Emacs Packages Up to Date - System Crafters. (4) How to update packages installed with use-package. (5) undefined. (6) undefined. (7) undefined. (8) undefined.


Option 2: The profiler

  1. Invoke M-x profiler-start RET RET (the second RET is to confirm cpu);
  2. Do some typing, preferably an entire paragraph or more;
  3. Invoke M-x profiler-report.

That will give you a buffer describing the cpu time taken by each function. Hitting TAB on a line expands it to display the functions inside it. Navigate this buffer until you find out which function is taking so much CPU time.

we tried this to figure out AC mode was slowing things down, but we already knew that. Not sure what to do about it though.

pinky solution

One way of not injuring the left pinky even after making CAPS into CTRL is to use different fingers to push it. That way the usage is distributed and the hands move around more too.

TODO regexp

Likely not worth paying in-depth attention to since it is not pcre. However, some of the uses can be helpful especially for simple things.

search file system

SFS is a collection of inter-operating emacs tools to make accessing and organizing your data faster and more ergonomic. It is largely powered by the Recoll file-indexing tool.

This may be worth pursuing eventually !!!


Pair management haven't been able to deal with ~~ and // in org-mode yet !!!


be sure aspell or whatever is installed. M-$
Check and correct spelling of the word at point (ispell-word). If the region is active, do it for all words in the region instead.

M-x ispell
Check and correct spelling of all words in the buffer. If the region is active, do it for all words in the region instead.

M-x ispell-buffer
Check and correct spelling in the buffer.

M-x ispell-region
Check and correct spelling in the region.


Likely not of much use since we tend to prefer buffers anyway.

C-x t 2 creates a new tab
C-tab next tab
C-S-tab prev tab
C-x t r rename tab
C-x t m move tab to right
C-x t RET select tab by name
M-x tab-list list tabs

tab completion

Setup in init-keybindings.el with (require 'helm) (define-key helm-map (kbd "TAB") 'helm-execute-persistent-action)


The ansi-term gives colors, but term doesn't. C-c C-j linemode to use M-x

Code runs ansi-term without the zsh prompt:

  ;; use ansi-term with zsh
  (defun zterm ()
    "term to use zsh"
    (ansi-term "zsh"))

  (M-)s-a (close) open terminal in second window

  ;; other terms
  s-' ansi-term full window
  s-. eshell
  s-y term with zsh (likely to use very rarely)

There is nothing wrong in allowing ansi-terms to accumulate even if we do not go back to them, though we might if they are involved in specific tasks. In order to name the ansi-terms we need to go into line-mode (C-c C-j) and not character-mode (C-c C-k), so we can use M-x rename-buffer.

In line mode, it reads an entire line and permits various emacs editing operations on it, then sends it to the process all at once when you're done (press Enter). In char mode, each character is sent through as soon as you press the key - dealing with lines, editing, and so on is up to the process running in the terminal, such as your shell.

Why might you want to use one over the other? Line mode allows you to perform Emacs editing operations on what you write, to accumulate multiple lines to send through at once, and to perform tab completion of filenames in Emacs. See the list of commands in shell mode for details. Character mode lets you use all the features of the underlying process, like its own (likely better) tab completion, rather than the Emacs operations, and also to send through inputs that Emacs would have interpreted as referring to its own commands (like Ctrl-X). This is also the mode you'd want if you wanted to run vim inside emacs.

An ordinary terminal operates in the equivalent of character mode. Line-mode vs Character-mode explanation

Clean-up of ansi-terms can be done in the same way as clean-up of sent-mail buffers: % n RET <pattern> marks the buffers by name after which use D to delete them. See ibuffer.

Macros have been created for 'aterm s-a 'aterm-rm M-s-a

For some reason, aterm does not let M-x to work - get execute: showing up in the window. Usually we would M-x to rename-buffer, but a shortcut exists: C-x x r and that will bring up the rename-buffer command.


(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/") M-x customize-themes


We can use ssh|sudo from rootdir with // and once we tramp into another computer the eshell works there (should we want it to).

hanging with ssh put in the remote .zshrc

[[ $TERM == "dumb"]] && unsetopt zle && PS1='$ ' &&

this is a zsh issue because people have said that when the switch to bash it all works.

<2023-09-22 Fri> stopped working for some reason, but a better solution is to use sshx which uses /bin/sh instead of zsh

ssh with sudo

C-x C-f /ssh:psinom|sudo:psinom:<FILE>


shell-mode-map is void

shell-mode-map is a variable that is defined in the file shell.el which is not loaded yet, so the variable is undefined.

(require 'shell) before you try use the variable. post

save and apply

This can be done through the emacs customize menu, but to do alter a variable permanently through the minibuffer, use M-x customize-


A “version control system” is a program that can record multiple versions of a source file, storing information such as the creation time of each version, who made it, and a description of what was changed. Emacs VC supports git and several others and is enabled whenever a file under VC is visited.

Commands reachable with prefix C-x v <tab>

Much more to investigate !!!


agenda cycling extra buffers

Cycling through the agenda dir sometimes produces empty buffers of the same name starting with .# and we think this may be because extra files of the same name somehow get created. Deleting the buffers doesn't get rid of them, because they keep coming back. However, if we M-x reload-dot-emacs after deleting them, the problem goes away.

issue with [I ] on first word

we don't really know what the problem is though it seems to have something to do with the TERM variable. it occurs with emacs -nw, but not with sudo emacs -nw probably because at the time this was written, there was no .emacs in /root as evidenced by a solution which works with emacs -nw -Q.

What does work if using gnome-terminal is TERM=gnome-256color

enter giving Wrong type argument: stringp, nil

inserting the doc with C-x C-i didn't work hopefully copying the items one by one will we will also leave orgmode to its own file

close help window without going to it

(setq help-window-select t) that way when using q, it closes the help window since it is already there.

re-able window

C-z isn't nil (the keybind is commented). It seems to sort of disable the window, but going to another emacsclient window re-activates the cursor. With a standalone emacs, clicking on the menu brings it back.

read-only toggle

C-x C-q

block commenting trick

we don't really need this since emacs is setup with C-M-c and C-M-S-c for comments

: '
This is a
very neat comment
in bash
echo "This is outside the commented block"

Executing the above code would result in: This is outside the commented block


  • coding

    • clj
    • zsh
    • php
    • openscad
    • html
  • email
  • writing

    • stories
    • librettos
    • papers
  • lilypond
  • orgmode