# Towards Freedom

Information, Inspiration, Imagination
truly a site for soaring Is

Emacs

Various topics and aids for emacs

TAGS: WHERNTO: techniq  operate

Emacs Items

## ansi-term

use this to get colors since shell doesn't give it don't use term because it requires C-c C-j to go into line mode

this code runs ansi-term without the zsh prompt

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

## daemon as systemd

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

## fdm

fetch and deliver mail it is MDA which can fetch https://wiki.archlinux.org/title/Fdm simple config for our notmuch purposes

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

## lilypond

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

### xpdf setup (works with mupdf too, but not llpp or evince)

issues with compilation pdf view and midi playback in conflict

## 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 &

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

1. files are left on server but not duplicated
2. fdm fetch will remove them from server
3. polls
4. 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!

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.

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:

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.

## packages

### update packages

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

Last, press x to perform the new updates.

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

## tramp

### hanging with ssh

https://www.emacswiki.org/emacs/TrampMode put in the remote .zshrc [[ $TERM == "dumb" && unsetopt zle && PS1='$ ' this seems to be a zsh issue because people have said that when the switch to bash it all works.

### ssh with sudo

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

## variable 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

## zz

### issue with [I ] on first word

we don't really know what the problem is. it occurs with emacs -nw, but not with sudo emacs -nw solution which works is to use emacs -nw -Q

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

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