NOTE: reclaimed from the greyhole in 201103, mostly outdated, needs cleaning up.

on macOS

source

 get it from here >
  % tla register-archive http://sourcecontrol.net/~miles/miles@gnu.org--gnu-2004 
  % tla get miles@gnu.org--gnu-2004/emacs--cvs-trunk--0 emacs

elisp programming

info & documentation

packages

scheme interface

bookmarks

  C-x r m  mark
  C-x r b  retrieve
  C-x r l  list
  C-x e    annotate 

eshell

M-x eshell interactive shell like buffer

  • C-up / C-down to scroll thru history
  • watch out for running shells in subproceses [eg ssh→zsh]
  • see .emacs for connecting ls with dired
  • how to →
    • r-searhc in history? → M-r (match previous regexp)
    • M-x eshell-completion-help
    • info → emacs info command compare; man-bgproc-sentinel

redirection

   echo "hello world" > #<buffer *scratch*>
   ps wax > #<buffer *scratch*>
  • shell vars
     $1 -> single arg (eg. for alias)
     $* -> arg list from commands line
     $_ -> 2nd arg of previous command
     $- -> previous directory (pwd) -> 'cd =' or 'cd -'
  • looping
    • for f in *.txt {mv $f (concat (file-name-sans-extension f) “.renamed”)}
    • for f in *.pict {convert $f (concat (file-name-sans-extension f) “.jpeg”)}
    • for f in *.png {convert -format “jpeg” $f (concat “crushed/” (file-name-sans-extension f) “.jpeg”)}
    • for f in * {vorbiscomment -w -t “TITLE=New Title” $f}

search,find, replace

C-s         search forwards
C-r         search backwards
M-%         Replace
  • M-x grep
  • in dired
    • M-x find-grep-dired > places results of a grep into a dired buufer
    • in a dired buffer > 'Q' to query replace marked files
    • M-x dired-do-query-replace on muliptle files, in dired mode
  • in multiple open files
    • M-x ibuffer
    • m mark the files you want to change (or t to mark all)
    • U regexp replace in all marked
    • S save all marked

mulitple file search & replace - http://atomized.org/2009/05/emacs-nerdery-search-replace-across-files/

dired

key macros

 C-x (      also F3, begin recording
 C-x )      also F4, end
 F4         M-x kmacro-call-macro
 C-x C-k e  edit a macro base on previous keystrokes
  • increment number at end of line → F3 F3 down F4 C-5 F4
  • M-x replace-regexp RET ^.*$ RET \&\# RET

changelog

  • C-x 4 a add an entry to a changelog in the current directory

keybindings ref.

Movement

Forward:                    Backward
C-n         1 line          C-p
C-f         1 character     C-b
C-v         1 page          M-v

C-a         line start/end  C-e
M-<         file start end  M->

Editing

C-d         clear letter
M-d         clear word
C-k         cut line
M-k         cut sentence
C-y         paste
C-@         set mark
C-spc       set mark
C-w         cut from mark
M-w         copy from mark
C-x C-x     exchange mark and cursor
C-x C-u     Undo!
C-x C-h     select all
M-2 M-z     zap to next (2nd) character

M-| wc -w   word count (shell command on region: 'wc -w')

File manipulation

C-x C-v     new
C-x C-f     open
C-x C-s     save
C-x C-w     save as
C-x C-c     quit

Tramp

  • C-x C-f (to open file) then something like /ssh:user@machin.ne:/home/user/file.txt

Regexps

  • M-x re-builder

Misc

C-l         redraw screen
C-o         insert line
M-q         reformat current paragraph
C-x o       switch windows
C-x 0       hide current window
C-x 1       maxmize current window
C-x 2       split window horizontally
C-x 3       split window vertically
C-x C-b     list all buffers (files) in memory
C-x C-k     close current buffer (file)
C-g         cancel command
C-h         help (repeat C-h for more detail)

multiuser editing

  • M-x make-frame-on-display

paredit

version control

foiding

  • M-1 C-x $ (aka. M-x set-selective-display) hide body of functions
  • C-x $ bring them back

PGP/GPG

  • using epa & epg
    • M-x epa-encrypt-file
    • M-x epa-encrypt-region

TRAMP

using tramp to connect to remote a host using eshell & sudo

  • /ssh:user@example.com
  • cd /sudo::

Internationales

  • manual sections
    • International
    • Language Environments
    • Specify Coding
    • Defining Fontsets
  • testing
    • C-h h (view-hello-file)
    • C-x <RET> for multibyte characters, coding systems, and input methods
  • C-x RET f - to set coding system for buffer
  • C-x RET c - set coding system for command

remembering and forgetting

random hacks/notes/tips

image

  • enable with M-x iimage-mode)
  • then simply add a url of the image, using the
    file://

    prefix for local imgs (note: wont work via http)

  • see: emacs FAQ nodes 'Modifying pull-down menus' and ' Deleting menus and menu options'

random

fonts / faces / typographica

fonts and language environment

   M-x describe-language-environment
   C-x RET c utf-8 RET 
   M-x describe-fontset
   M-x list-character-sets

test ranodm unicode

describe characters at a point with C-u C-x =

utf-8

C-x RET r utf-8

see the FAQ

  • Undo within a given region C-U C-_
  • Unnarrowing the region M-x widen
  • ediff & ediff-trees.el
  • C-h i m advice RET
  • M-/ Auto-complete words in your buffer based on what already exists
  • M-x align-regexp
  • C-x M-c M-butterfly > http://xkcd.com/378/ (try M-x butterfly in emacs 23)
  • C-u M-! ls *.h
  • M-x align
  • M-x query-replace-regexp-eval
  • M-g g is the same as M-x goto-line
  • M-x auto-revert-tail-mode is great for tailing log files.

writing about emacs

  • emacs_notes.txt
  • Last modified: 2020-04-11 04:33
  • by 127.0.0.1