Towards Freedom


Information, Inspiration, Imagination
truly a site for soaring Is

Emacs

Various topics and aids for emacs

TAGS:
Tags:
WHERNTO: techniq  operate 

image of Emacs

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

keybindings

assistance

  ;; 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

bookmarks

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

case

  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.

comment

  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.

count

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

dired

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 !!!

greps

  ;; 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

helm

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 s	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

filling

  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)

insert

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

kill

  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.

macro

  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
  C-x C-k e edits last

mark

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

  % n regexp (in ibuffer)

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

move

  ;; 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

search/replace

  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)

transpose

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

undo/redo

  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

visit

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

auto-capitalize-mode

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

completers

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.

helm

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.

ido

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.

vertico

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.

ivy

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

dired

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

enter

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

navigation

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

deletion

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 [https://www.emacswiki.org/emacs/DiredOmitMode][Toggle Showing Dot Files]

visiting files

RET|f
o,C-o
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

D
Z
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

subdirs

i
C-u C-SPC
$
M-$
C-u k

symlinks

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

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 "https://www.sciencedaily.com/rss/top/science.xml" nil) ("www.sciencedaily.com" . "https://www.sciencedaily.com/releases/2021/04/210405150225.htm") #s(elfeed-entry ("www.sciencedaily.com" . "https://www.sciencedaily.com/releases/2021/04/210405150225.htm") "Elasticity to position microplates on curved 2D fluids" "https://www.sciencedaily.com/releases/2021/04/210405150225.htm" 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

eshell

some of these items apply to emacs in general.

builtins

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 ":"))

expansions

  (setq var "this is a string with extension.test")
  $var
  $'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

help on function at point: C-h f

history

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

redirection

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)

scripts

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

eww

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.

flys

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

flyspell

Used for spell checking and allows adding to the dictionary.

flymake

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

flycheck

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.

fdm

fetch and deliver mail it is MDA which can fetch https://wiki.archlinux.org/title/Fdm 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 !!!

fountain-mode

screenplain

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)))

greppers

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 s 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:

(grep-apply-setting
  'grep-find-command
  '("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.

ibuffer

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-."))

lilypond

qpdfview

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.

midi

Lilypond-midi-player variable set to timidity|fluidsynth 

links

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).

notmuch

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

setup

%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

starting

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

various commands

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

html

(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)

searching

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 | -5da..now | yesterday

man notmuch-search-terms

fetch/trash mechanism

use nmprg.sh) 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 nmprg.sh 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 http://contacts.google.com, 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

https://notmuchmail.org/emacstips/#index16h2 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 "shawmail.gv.shawcable.net" send-mail-function 'smtpmail-send-it user-full-name "prad" smtpmail-local-domain "towardsfreedom.com" user-mail-address "prad@towardsfreedom.com") (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 "mail.towardsfreedom.com" sent, but still the same problem with replying to vivaldi!

<2021-06-21 Mon> we are sending pradagio@vivaldi.net emails through smtp.vivaldi.net 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 <prad@towardsfreedom.com>" ;; Sender address "towardsfreedom.com" ;; Organization header (("X-Message-SMTP-Method" . "smtp smtp.towardsfreedom.com 587")) nil ;; extra body text "~/.signature") ("fm" ;;formal tf nil "prad basu <prad@towardsfreedom.com>" "prad basu" ;; Organization header (("X-Message-SMTP-Method" . "smtp smtp.towardsfreedom.com 587")) nil ;; No extra body text "~/.signature.fm") ("vv" nil "prad <pradagio@vivaldi.net>" "prader" ;; Organization header (("X-Message-SMTP-Method" . "smtp smtp.vivaldi.net 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" . "towardsfreedom.com") didn't work though it did get the item in there. receiving end produced: Message ID <60d15486.1c69fb81.90dc4.e612SMTPIN_ADDED_BROKEN@mx.google.com>

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

orgmode

manual

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)

profiler

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. https://emacs.stackexchange.com/questions/5359/how-can-i-troubleshoot-a-very-slow-emacs

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 !!!

smartparens

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

spellcheck

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.

tab-bar

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)

terminals

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"
    (interactive)
    (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.

themes

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

tramp

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

https://www.emacswiki.org/emacs/TrampMode 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>

variables

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-

vc

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 !!!

zz

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 https://stackoverflow.com/questions/947897/block-comments-in-a-shell-script

uses

  • coding

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

    • stories
    • librettos
    • papers
  • lilypond
  • orgmode