My little document

Table of Contents

;-- mode: Org; fill-column:120; org-src-fontify-natively:t; buffer-read-only: t;-- or emacs -f view-mode

For beginers: https://systemcrafters.net/emacs-from-scratch/

emacs news: https://emacsredux.com/

https://github.com/emacs-tw/awesome-emacs

programin book in Org https://github.com/chansey97/SICP-Sage https://github.com/ilmotta/sicp-org

example init

keys https://www.math.uh.edu/~bgb/Links/emacs_keys.html

TODO https://steelkiwi.com/blog/emacs-configuration-working-python/ TODO videos https://www.youtube.com/user/emacsrocks/videos TODO https://sites.google.com/site/steveyegge2/effective-emacs

1. terms

  • emacs - a free/libre text editor and elisp interpretor.
  • yeld - paste from kill ring.
    • kill ring - is a list of blocks of text that were previously killed
  • active region - when set-mark-command is called, the region becomes active. And any other command typically set the region status to inactive after it is called.
    • mark - set-mark-command
    • region - The last marked position to the current cursor position.
  • prefix argument - ‘C-u’ to set the prefix argument value to use.(universal-argument) command. may be: nil - no argument, integer, character ("-"). It is a first argument to function with (interactive "P"). https://www.gnu.org/software/emacs/manual/html_node/elisp/Prefix-Command-Arguments.html

2. Emacs source code

Emacs writen in lisp but lisp is writen in C

Code base is large:

  • Emacs is meant to be computing environment
  • Was created in time when there was no such concept as a package managers - a lot of staff was added to a core to make it useful in the box, but this days emacs would use packages if will be rewrited
  • a lot of staff here that doesn't need to be here.
  • too many feature to maintain with stability

forks: Lucid/XEmacs, Guile Emacs, Aquamacs, Mac port, Remacs.

2.1. elisp and common lisp

  • there is emulation for common lisp in emacs
  • it is too hard to maintain universal interpretator for scripting it is better to enhance elisp and add support for other languages

3. Debuging

steps:

  • (global-set-key (kbd "C-h C-f") 'find-function)
  • C-u C-M-x set breakpoint at function entry
  • C-M-x
  • c

3.1. terms

  • instrumenting - inserts additional code into it, to invoke Edebug at the proper places.

3.2. Elisp mode:

cursor at the end of expression:

  • C-x C-e eval-last-sexp Evaluate the expression to the left of cursor.
  • C-M-x eval-defun Evaluate top level expression to left and to right of cursor
  • C-u C-x C-e eval and insert result to buffer
  • C-u C-M-x Instrument and execute current func

other eval

  • M-: (eval-expression) type expression in ()

To remove instrumentation from a definition, simply re-evaluate its definition in a way that does not instrument. (‘M-:’) or edebug-remove-instrumentation

3.3. The Lisp Debugger ( The built-in Emacs Lisp debugger)

3.3.1. enable

  • M-x toggle-debug-on-error
  • M-x debug-on-entry RET triangle-bugged RET
    • M-x cancel-debug-on-entry RET triangle-bugged RET
  • M-x debug-on-variable-change RET myvar RET
    • M-x cancel-debug-on-variable-change RET myvar RET
  • M-x set-variable RET debug-on-quit RET t RET - whenever you type C-g (keyboard-quit). useful for debugging infinite loops.
  • M-x debug-on-message

emacs –debug-init - Enable Emacs Lisp debugger during the processing of the user init file ~/.emacs.

Explicit debuging: place (debug) at place where it required and eval C-M-x.

3.3.2. keys in debugger

frame - commands sequence in backtrace

Backtrace buffer - part of The Lisp Debugger

  • q Terminate the program being debugged; return to top-level Emacs command execution.
  • c Exit the debugger and continue execution.
  • d step
  • b/u set/unset breakpoint at frame, next time it will stop here
  • j enter edebug and temporarely disable all debug-on-entry in way to this frame

other:

  • l list debug-on-entry points
  • v show local variables
  • +/- toggle view
  • RET "push-button" go to definition
  • SPC scroll
  • "." expand

3.4. Edebug

source-level debugger - displays the source of the code you are debugging, with an arrow at the left

  • can not see variables, but can evaluate any expression (print val)

Instrumenting:

  • C-u C-M-x (‘eval-defun’ with a prefix argument) point into the definition of a function

3.4.1. commands

  • "i/o" (M-x edebug-step-in) to step in
  • "b" (M-x edebug-set-breakpoint) to set the break point (press "u" key unset break point. I don't use this though)
  • "g" (M-x edebug-go-mode) continue until next breakpoint
  • "h" (M-x edebug-goto-here) to proceed until at the current line
  • space step
  • w Move point back to the current stop point
  • e eval
  • C-x C-e eval expression outside

4. Info

  • F1 i open
  • M-: (info "(elisp) Writing to Files")

see shell#MissingReference

4.1. keys

i Search for a topic in this manual’s Index and go to index entry. c Get current Info path

4.2. extra Info files

  1. wget https://ftp.gnu.org/gnu/emacs/elisp-manual-21-2.8.tar.gz
  2. tar xpf elisp-manual-21-2.8.tar.gz
  3. cd elisp-manual-21-2.8
  4. ./configure
  5. make elisp
  6. make install (as root or change prefix)
  7. ~/.emacs: (add-to-list 'Info-directory-list "/usr/local/info")

or

bzip -d /usr/share/info/emacs-28/elisp.info.bz2

5. PROS

introspectable
You can always find out 'what code runs when I press this button?'.
incremental programming environment
There's no edit-compile-run cycle. There isn't even an edit-run cycle. You can execute snippets of code and gradually turn them into a finished project. There's no distinction between your editor and your interpreter.
mutable environment
You can set variables, tweak functions with advice, or redefine entire functions. Nothing is off-limits.
provides functionality without applications
Rather than separate applications, functionality is all integrated into your Emacs instance.
infinite clipboard
undoing to any historical state
reverse variable search
you can find variables with a given value.
structural editing
documentation culture
Emacs includes a usage manual, a lisp programming manual, pervasive docstrings and even an interactive tutorial.
broad ecosystem

In “Emacs is my “favourite Emacs package”” Protesilaos Stavrou talks about the importance of Emacs, the platform. The whole becomes greater than the sum of its parts.

graphical UI was added, lexical scope was implemented, rudimentary networking and concurrency primitives were introduced, and more.

6. CONS

  • M-f M-b - you are going to reach next world not the end of the current
  • M-v C-v - worst alternative to Page up Page down
  • M-</> - worst alternative to Home, End
  • C-u and C-k - not logic with C-h and C-d
  • C-w and M-d - not logic with C-h and C-d

Emacs:

  • do not save edit history
  • slow major releases - every 1-2 years
  • too much emphasise on FSF licensing - barrier to contribute - no rights for you
  • project cannot be part of Emacs until all who contributed to project will done copyrigt assiment to FSF
  • C is not popular. not many contributors
  • it is very easy for packages to interfere with one another, depend on functionality from other packages that get deprecated, changed in incompatible ways, or removed. There's currently no way for a package to depend on a specific version of another package, or for multiple versions of a single package to be loaded at the same time, for example.
  • Emacs packages can be valuable in isolation, combined, they amplify the platform that made them possible

Freedom has a price. — Richard Stallman(RMS) in “Re: New maintainer” (2015):

  • I think freedom is more important than technical progress. Proprietary software offers plenty of technical “progress”, but since I won’t surrender my freedom to use it, as far as I’m concerned it is no progress at all.
  • If I had valued technical advances over freedom in 1984, instead of developing GNU Emacs and GCC and GDB I would have gone to work for AT&T and improved its nonfree software. What a big head start I could have got!

Do you want a computing machine that respects your privacy, or a modern, powerful one?

7. encoding

  • M-x revert-buffer-with-coding-system
  • M-x set-buffer-file-coding-system (or C-x C-m f)
  • M-x recode-region
  • '' - coding: utf-8 --
  • best way to convert - just copy text from emacs to new created emacs window

or

  • iconv -f ISO-8859-1 -t UTF-8 input.file -o out.file
  • iconv -l

Вот такое удаление плохих символов иногда помогает:

cat file | sed 's/\r//g' > /tmp/file

8. keys

C-A-? autocompletion

8.1. help

C-h = F1 C-h ? i manuals a shutcommands r tutorial C-h l история c-h f lisp function (keyboard-translate ?\C-o ?\C-h) C-h b keys bindings C-h e message buffer C-h F help for command: org-mode C-h i info page

M-x shortdoc-display-group

8.2. basic

M-x or Esc x - eval-defun - evaluate lisp funcion

C-x C-=(-) enter zoom mode -out =in

M-x recover-file <RET> foo.c <RET> C-h t tutorial for Emacs C-h r read Emacs manual

Modes

  • M+x text-mode auto-fill-mode enriched-mode org-mode
  • C+x C+q read only/switch mode

C-\ сменить раскладку input-method - default-input-method: russian-computer; -*-

  • M-x set-input-method
  • F1 C-\ describe current input method

C-x RET r сменить windows-1251

C-g or C-q or C-] or q Cancel (exit from command line, close other window, Esc, )

C+u repeat

deletion:

  • C+d delete char
  • C+k del to the end of the line
  • C+h backspace not working (keyboard-translate ?\C-h ?\C-?)

C-o (open-line) - dont move cursor C-j (newline-and-indent) C-m (newline)

  • as

C-x n d Narrow the buffer to the contents of the current function (narrow-to-defun). This will narrow to the function as identified to the current function, even if it is nested in an object or another function. The logic to narrow the function is the same as the beginning-of-defun and end-of-defun commands – see Motion, and the mark-defun command – see above. C-x n w Undo any narrowing by widening the buffer again by making the rest of the buffer available (widen).

C-s C-i search and highlight for Tabs C-s space search for highlight for spaces

8.3. indentation

8.4. Copy paste etc

  • C+SPC start of selecton
  • C+q cancel, close other window
  • C+x C+x swap mark
  • C+x h mark all
  • M-h Mark the current function (c-mark-function). Puts the mark at the end and of the function and the point at the beginning. Useful if you want to kill the region with C-w or M-w, or indent the region with C-M-\ or C-x TAB (See Indentation.).
  • S-M-f select and go by word forward - special for Emacs
  • C+w copy
  • M+w cut
  • C+y paste (yank)
  • M+y scrooll paste
  • C+/ undo and redo
  • File
  • C+x C+f open file
  • C+x C+s save
  • C+x s save all buffers
  • EDE Emcas Development Environment
  • M+x global-ede-mode
  • new project1)visit file in folder 2)M+x ede-new
  • target - файл в который строим может состоять из нескольких файлов
    • C-c . t создать С-с . a add file C-c . c compile target C-c . C compile all targets
  • ETC.:
  • C+d delete character

8.5. Navigate

  • C+f b n p cursor nav
  • C+a beg of line
  • C+e end
  • M+m to the indentation the begining of text
  • M-a Move back to the beginning of the sentence (backward-sentence).
  • M-e Move forward to the end of the sentence (forward-sentence).
  • M+Shift+{} backward-paragraph forward-paragraph
  • C+v M+v PageDown, PageUp
  • C+l scrool
  • M+m to the indentation
  • C+s search C+r
  • C-x C-@ return back after search ( pop-to-mark-command)
  • M-x replace-string search and replace
  • M-% advanced search and replace
  • M+g+g go to line
  • C+Home or M+Shift+< start of the page
  • C+End or M+Shift+> end of the page
  • Scroll Lock - fixate cursor

8.5.1. buffers:

  • C+x C+b list buffers
  • C+x+k kill
  • C+x+array(left or right) - next or preview buffer in list

8.5.2. parentheses

  • C-M-f (forward-sexp)
  • C-M-b (backward-sexp)
  • C-M-d down-list
  • C-M-n forward-list
  • C-M-u backward-up-list

8.6. prefixes C-x, C-c, Esc

  • C-x is prefix key for general commands
  • C-c is prefix key of current major mode's commands.
  • Esc (global-set-key (kbd "\e\el") 'goto-line)

8.7. Marks

  • A-S-m set mark

8.8. macros

  • C-x ( start definition
  • C-x ) end definition
  • C-x e Execute
  • C-u 20 C-x e 20 times
  • C-x C-k n RET my M-x insert-kbd-macro RET my Insert in the buffer a keyboard macro’s definition, as Lisp code.

8.9. auto-fill

M-x auto-fill-mode M-q refill paragraph С-u C-x f set column to cursor

C+x f set fill column (margin)

9. key binding

http://ergoemacs.org/emacs/emacs_useful_user_keybinding.html

C-h k check binding for key C-h b all binding C-h l recent keystrokes

You cannot invoke a non-interactive function through a key binding — it must be a command.

Command is interactive functions. command has an (interactive …) form at the top of its function body.

9.2. Keyboard Translations

https://ftp.gnu.org/old-gnu/Manuals/emacs-20.7/html_node/emacs_457.html https://www.gnu.org/software/emacs/manual/html_node/elisp/General-Escape-Syntax.html https://ftp.gnu.org/old-gnu/Manuals/elisp-manual-21-2.8/html_node/elisp_693.html https://www.gnu.org/software/emacs/manual/html_node/elisp/Classifying-Events.html Emacs contains numerous keymaps that apply in different situations, but there is only one set of keyboard translations, and it applies to every character that Emacs reads from the terminal. Keyboard translations take place at the lowest level of input processing; the keys that are looked up in keymaps contain the characters that result from keyboard translation. (keyboard-translate ?\C-h ?\C-?)

(keyboard-translate ?\C-b ?c) - character

Why not work with M key?

  • keyboard-translate works with char tables, hence the characterp error. Modified keys are not necessarily valid as characters.
  • (elisp) Char-Tables tells us: "A char-table is much like a vector, except that it is indexed by character codes. Any valid character code, without modifiers, can be used as an index in a char-table."
  • The control modifier is a bit special, as typical control characters are still plain ASCII values, and hence valid for characterp.

9.3. Keymaps

9.3.1. basic

keymap is an internal data structure used by Emacs to store keys and their associated actions

M-x describe-keymap

  • keyboard-translate - swap keys
  • global-set-key - equal to (define-key (current-global-map) key command)
  • local-set-key - equal to (define-key (current-local-map) key command)
  • define-key - that is how
    • (define-key key-translation-map (kbd "C-l") (kbd "C-b"))
  • (global-unset-key KEY)
  • (local-unset-key KEY)

Most third-party packages don’t care about the key bindings they occupy. So keep that in mind.

Keys reserved for you:

  • prefixed with C-c ?
  • F-keys from F5 and onwards
  • hyper and super H- (e.g., H-q) and s- for super. Note that s is super and S is shift.
  • Windows key and the Application Context key
  • C-M-

9.3.2. exploration

  • M-x describe-keymap
  • C-h b

9.3.3. kbd macros

Ways to representing keys in Emacs: as a string, or as a vector. kbd use string.

<> required for: That includes F-keys, arrow keys and home row keys, like so: <home>, <f8> and <down>

(kbd "<home>")    ;; OK
(kbd "tab")       ;; Wrong, but valid -- missing < and >
(kbd "<tab>")     ;; OK
(kbd "C-c p")     ;; OK

kbd used to bind actions to keys

saving and executing macros - "kmacro":

M-x name-last-kbd-macro
M-x insert-kbd-macro
M-: (call-interactively (kmacro "C-n - C-n C-a C-a"))
M-x kmacro-edit-macro

kmacro syntax is equal to kbd. kmacro is used to execute keys by command

9.3.4. Remapping Commands

(define-key (current-global-map) [remap kill-line] 'my-homemade-kill-line)

9.3.5. Keymap Lookup Order

First, Emacs checks if there’s a minor mode key binding. Secondly, local keys set. And finally global keys are checked.

  1. overriding-terminal-local-map for terminal-specific key binds.
  2. overriding-local-map for keys that should override all other local keymaps. Be VERY careful if you use this!
  3. Keymap char property at point for keymaps that are local to the character point is at. Common use cases include in-buffer fields, like the ones you find in M-x customize.
  4. emulation-mode-map-alists for advanced multi-mode keymap management
  5. minor-mode-overriding-map-alist for overriding the keymaps used by minor modes in major modes.
  6. minor-mode-map-alist is exactly like the overriding version above, but the preferred means of specifying the keymaps for minor modes.
  7. Keymap text property at point is like the one above for char properties but this is for text properties only.
  8. current-local-map for keymaps defined in the buffers’ current local map
  9. current-global-map is the last place Emacs looks. It hosts keys that are global.

9.3.6. creating keymap and deactivate it

make-keymap is more efficient than a sparse keymap when it holds lots of bindings; for just a few, the sparse keymap is better.

use-local-map - override all Major Mode Bindings

Here is two approaches: remap keymap and activate own minor mode. Major mode is not possible to deactivate. Steps for remap keymap:

  1. Define a keymap.
  2. set-keymap-parent my-map oldmap # to add old keys to new
  3. use-local-map my-map # activate new
  4. use-local-map old # get old back

Steps for activate own minor mode:

  1. define minor mode with keymap
  2. activate it and deactivate it
  1. remap global keymap
    (defun myaa () (interactive)
                                      (set 'oldmap (current-local-map))
                                      ;; (suppress-keymap (current-local-map))
    
                                      (set-keymap-parent my-map oldmap)
                                      (use-local-map my-map)
    
                                      (print oldmap)
                                      (call-interactively 'org-goto)
                                      (use-local-map oldmap)
                                      )
                               (define-key org-mode-map (kbd "C-c C-j") 'myaa)
    
  2. minor mode with keymap
    (defun myaa () (interactive)
                                      (fix-org-goto-mode)
                                      (call-interactively 'org-goto)
                                      (fix-org-goto-mode -1)
                                      )
                               (define-minor-mode fix-org-goto-mode
                                 "Allow to exit from search with arrows."
                                 :lighter " fix-goto"
                                 :keymap (let ((map (make-sparse-keymap)))
                                           (define-key map (kbd "C-f") 'org-goto-ret)
                                           (define-key map (kbd "C-l") 'org-goto-ret)
                                           (define-key map (kbd "C-n") 'org-goto-ret)
                                           (define-key map (kbd "C-k") 'org-goto-ret)
                                           map))
                               (define-key org-mode-map (kbd "C-c C-j") 'myaa)
    
  3. links

9.3.7. use-package

unless you tell it otherwise, use-package defaults to global key bindings.

;; global key map
(use-package winner
  :config
  (winner-mode 1)
  :bind (("M-[" . winner-undo)
         ("M-]" . winner-redo)))

;; specify key map
(use-package eshell
             :bind (("C-c e" . eshell)
                    :map eshell-mode-map
                    ("M-m" . eshell-bol)))

(use-package package-name-here
  :bind (("kbd-here" . command-here)
         :map some-map
         ("kbd-here" . another-command-here)
         :map yet-another-map
         ("kbd-here" . some-command-here)))

9.4. function keys

https://www.gnu.org/software/emacs/manual/html_node/elisp/Function-Keys.html

  • ‘A-’ The alt modifier.
  • ‘C-’ The control modifier.
  • ‘H-’ The hyper modifier.
  • ‘M-’ The meta modifier.
  • ‘S-’ The shift modifier.
  • ‘s-’ The super modifier.

9.5. reserved

  • C-c followed by a control character or a digit are reserved for major modes.
  • C-c followed by {, }, <, >, : or ; are also reserved for major modes.
  • C-c followed by any other ASCII punctuation or symbol character are allocated for minor modes.
  • C-c and a letter (either upper or lower case; ASCII or non-ASCII) are reserved for users;
  • F5 - F9 without modifier keys are also reserved for users to define.

9.6. chords

  • order doesn’t matter: ab is the same chord as ba
  • two keys pressed simultaneously, or a single key quickly pressed twice

9.7. hydra

  • define modes like in vi with keys

for window size and zoom

(defhydra hydra-windowsize (global-map "C-x")
    ("{" shrink-window-horizontally)
    ("}" enlarge-window-horizontally))

(defhydra hydra-zoom (global-map "<f2>")
      "zoom"
      ("g" text-scale-increase "in")
   ("l" text-scale-decrease "out"))

9.8. forward-word, backward-word, backward-kill-word, kill-word

F1 s - syntax table

treat '. / . // aw' as a different Word and a./fg.s will be single word also

(modify-syntax-entry ?. "w")
(modify-syntax-entry ?/ "w")

10. file variables -*-

https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html File varibles -- coding: utf-8; mode: modename; var: value; … -- ;; -- mode: Lisp; fill-column: 75; eval: (print "hello"); -- M-x add-file-local-varible-prop-line предлагает доступные переменные

10.1. fill column

C-? v fill-column - help and get current C-x f - set-fill-column

11. folder variables - .dir-locals.el

  • .dir-locals.el
  • .dir-locals-2.el

Emacs searches for .dir-locals.el starting in the directory of the visited file, and moving up the directory tree

M-x copy-file-locals-to-dir-locals copies the file-local variables in the current file into .dir-locals.el.

https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html

((nil . ((indent-tabs-mode . t)
         (fill-column . 80)
         (mode . auto-fill))) ;; for any file in the directory tree
 (c-mode . ((c-file-style . "BSD")
            (subdirs . nil))) ;; for any C source file
 (eval . (add-to-list 'company-backends
                      '(company-jedi company-files)))
 ("src/imported"
  . ((nil . ((change-log-default-name
              . "ChangeLog.local")))))) ;; C mode settings are only to be applied in the current directory, not in any subdirectories.

12. global variables

  • F1 v describe global variable
  • M-x set-variable

13. package install

M-x list-packages - ELPA

after install:

  • add (package-initialize) to ~/.emacs
  • (require 'package-name) - to fully load the package
  • it's also recommended that you add (package-initialize) somewhere in your ~/.emacs file - to set up the load-paths and autoloads for installed packages.
  • (with-eval-after-load "package-name" …) or (eval-after-load 'package-name …) to run code after a package is loaded

to remove: M-x paclage-delete

  • after remove, to remove dependencies: M-x package-autoremove

;; only run this if rtags is installed (when (require 'rtags nil :noerror) ;; something here )

13.1. remove

  • M-x package-menu-mark-obsolete-for-deletion
  • M-x package-menu-execute

13.2. update

M-x package-list-packages

to mark all upgradable and update all:

  1. U package-menu-mark-upgrades
  2. x package-menu-execute

to filter all upgradable and update individual:

  1. / u package-menu-filter-upgradable
  2. manually install and remove obsolate

13.3. melpa add

https://melpa.org/#/getting-started

to ensure that Emacs has fetched the MELPA package list before you can install packages with M-x package-install or similar.

  • M-x package-refresh-contents or M-x package-list-packages

Updating Packages:

  1. package-list-packages
  2. type U (mark Upgradable packages)
  3. x (eXecute the installs and deletions).
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

OR

;; MELPA
(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
     ("http" . "srv-proxy:8080")
     ("https" . "srv-proxy:8080")))

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

13.4. load path

The default behavior is to load the first file found. This command prefers .elc files over .el files because compiled files load and run faster.

  • load-prefer-newer to a non-nil value, loads whichever version of the file is newest
  • load-path. list of directories (strings). These directories are searched, in the specified order
  • (require 'my-shining-package) ;; Loads my-shining-package.elc unconditionally.
  • (autoload 'my-func "my-shining-package") ;; Will load my-shining-package.elc when my-func is invoked.

13.5. (load "package.el")

Evaluate a complete file. you can leave out the extension and it will automatically load the "elc" or "el" file as appropriate. It also looks into the load-path directories.

Note that you have to add the lisp subdirectory to the load-path, not the top-level of the repository, and that elements of load-path should not end with a slash, while those of Info-directory-list should.

  • (add-to-list 'load-path "~/.emacs.d/site-lisp/dash")

Example:

  • (load "foo") (if "foo.el" is in the current directory or in the load-path").

13.6. (require 'foo)

load foo.el and require (provide 'foo) in file.

require is similar to load, except it prevents the file from being loaded more than once

13.7. (package-initialize)

initializes Emacs’ internal record of which packages are installed, and then calls package-activate-all.

(package-activate-all) This function makes the packages available to the current session. The user option package-load-list specifies which packages to make available; by default, all installed packages are made available.

13.8. Why use-package?

  • have to explicitly call (require 'package-name) in your init.el before you could do any configuration.
  • any configuration of the package may need to be wrapped in a (with-eval-after-load 'package-name …) block, to avoid running into undefined variables and functions before your package is fully loaded - to run code after a package is loaded,

13.9. autoinstall

  (package-initialize)
  ;; list the packages you want
  (defvar package-list)
  (setq package-list '(async auctex auto-complete autopair clang-format cmake-ide
                             cmake-mode company company-irony
                             company-irony-c-headers dash epl flycheck
                             flycheck-irony flycheck-pyflakes
                             google-c-style helm helm-core helm-ctest
                             helm-flycheck helm-flyspell helm-ls-git helm-ls-hg
                             hungry-delete irony
                             let-alist levenshtein magit markdown-mode pkg-info
                             popup rtags seq solarized-theme vlf web-mode
                             window-numbering writegood-mode yasnippet))
  ;; fetch the list of packages available
  (unless package-archive-contents
    (package-refresh-contents))
  ;; install the missing packages
  (dolist (package package-list)
    (unless (package-installed-p package)
      (package-install package)))

13.10. upgrade

  • M-x package-list
  • U
  • x
  • M-x package-autoremove

13.11. install from Git

  1. .emacs: (add-to-list 'load-path "~/.emacs.d/contrib/lisp/")
  2. git clone https://github.com/magit/magit.git ~/.emacs.d/contrib/lisp/magit
  3. .emacs: (require 'magit) or (package-initialize)

14. cool features

14.1. Registers

Each register has a name that consists of a single character

  • C-x r s ? - copy-to-register
  • C-x r i ? - insert-register
  • C-x r SPC ? - point-to-register
  • C-x r j ? - jump-to-register

Bookmarks - persistent registers with long names

  • C-x r l List all bookmarks (list-bookmarks).
  • C-x r m RET

    Set the bookmark for the visited file, at point.

C-x r m bookmark RET

Set the bookmark named bookmark at point (bookmark-set). C-x r M bookmark RET

Like C-x r m, but don’t overwrite an existing bookmark. C-x r b bookmark RET Jump to the bookmark named bookmark (bookmark-jump).

15. buffers

C-x C-LEFT goes to previous buffer C-x C-RIGHT goes to next buffer C-x k kills a buffer C-x 4 0 kills a buffer and its window C-x b switches to another buffer, or opens a new buffer C-x left/right - cycle buffers

cycling:

  • it is impossible to track key release event

15.2. buffer-flip Melpa

15.3. buffer-expose ELPA

16. windows

  • window - part of window
  • frame - sepparate window
  • C-x o Switch to other window other-window
  • C-x 0 Delete selected window delete-window
  • C-x 1 Delete all windows other than the selected one delete-other-windows
  • C-x 2 Split selected window horizontally split-window-below
  • C-x 3 Split selected window vertically split-window-right
  • C-x 4 C-f open a file in the other window
  • C-x 4 0 kills a buffer and its window
  • C-x ^ Make selected window taller enlarge-window
  • Unbound Make selected window smaller shrink-window
  • C-x } Make selected window wider enlarge-window-horizontally
  • C-x { Make selected window narrower shrink-window-horizontally
  • C-x - Shrink selected window to fit its buffer shrink-window-if-larger-than-buffer
  • C-M-v Scroll the other window forward scroll-other-window
  • C-M-S-v Scroll the other window backward scroll-other-window-down
  • C+x C+c quiet emacs
  • Esc Esc Esc - close other windows

consis of:

  • mode line ** mean was changed (editing mode)
  • echo area

M+x make-frame delete-frame

16.1. alternative windows switching

https://emacs.stackexchange.com/questions/3458/how-to-switch-between-windows-quickly

16.2. mode line

U:@— - saved

U:@**- - modified

cs:ch-fr  buf      pos line   (major minor)
  • cs string and the colon character after it describe the character set and newline convention used for the current buffer.

    • '-', that indicates no special character set handling (with the possible exception of end-of-line conventions,

    described in the next paragraph).

    • '=' means no conversion whatsoever, and is usually used for files containing non-textual data
    • ‘1’ represents ISO Latin-1.
    • two additional characters that describe the coding systems for keyboard input and terminal output.
  • ':' - end-of-line convention.
    • ‘\’ or ‘(DOS)’ - MS-DOS convention uses a carriage return character followed by a linefeed character;
    • (‘/’) or ‘(Mac)’ - older Macintosh systems, uses a carriage return character instead of a newline
    • ‘(Unix)’ - On some systems
    • '@' - This indication is typical for frames of an Emacs process running as a daemon
  • ch

    • ‘–’ - if the buffer displayed in the window has the same contents as the corresponding file on the disk; i.e., if

    the buffer is unmodified

    • ‘**’ - the buffer is modified
    • ‘%*’ - the buffer is modified for a read-only buffer
    • ‘%%’ - the buffer is not modified for a read-only buffer
  • ‘-’ -
    • ‘@’ if default-directory for the current buffer is on a remote machine, ‘@’ is displayed instead.
  • fr - It appears only on text terminals. The initial frame’s name is ‘F1’. gives the selected frame name
  • buf - is the name of the buffer displayed in the window.
  • pos - tells you whether there is additional text above the top of the window, or below the bottom
  • line - is the character ‘L’ followed by the line number at point.
  • major - is the name of the major mode used in the buffer.
  • minor - a list of some of the enabled minor modes
    • ‘Def’- means that a keyboard macro is currently being defined
    • ‘Narrow’ means that the buffer being displayed has editing restricted to only a portion of its text

17. modes

  • C-h m will reveal major mode and all minor modes that are active.
  • C-h v major-mode RET
  • M-: major-mode RET

to disable global mode: M-x customize-option mouse-wheel-mode ; set to nil

(call-interactively mode) - will switch off mode if mode is on

17.1. major modes

  • Every major mode is associated with a major mode command, whose name should end in ‘-mode’
  • unlike minor modes there is no way to “turn off” a major mode, instead the buffer must be switched to a different one

types:

  • buffer-local, and can be turned on (enabled) in certain buffers and off (disabled) in others.
  • global: while enabled, they affect everything you do in the Emacs session, in all buffers. Most minor modes are disabled by default, but a few are enabled by default.

modes:

fundamental-mode
has no mode-specific definitions or variable settings.
(no term)

17.2. minor modes

see 9.3.6.1

18. completion

by default:

  • TAB completion-at-point
  • C-M-i complete-symbol

19. code extension

19.1. hooks

(add-hook), (setq)

  • is a Lisp variable which holds a list of functions
  • You can set a hook variable with setq like any other Lisp variable, but the recommended way to add a function with add-hook
  • two types: normal hooks
    • Every variable whose name ends in ‘-hook’ is a normal hook.
    • abnormal hooks - names end in ‘-functions’, instead of ‘-hook’
  • Major mode hooks also apply to other major modes derived from the original mode
  • M-x eval-last-sexp RET - to test

C-u C-h a run-hook C-h i g (elisp)Running Hooks

Listing all the Mode Hooks: M-x apropos-variable RET -mode-hook$ RET

19.1.1. eval-after-load vs. mode hook vs require vs after-init-hook

eval-after-load code:

  • will be executed only once, so it is typically used to perform one-time setup such as setting default global values and behaviour. An example might be setting up a default keymap for a particular mode.
  • there's no notion of the "current buffer".
  • code will always be executed before any functions in the related library are called.

Mode hooks

  • execute once for every buffer in which the mode is enabled
  • run later than eval-after-load code; this lets them take actions based upon such information as whether other modes are enabled in the current buffer.

(require 'foo)

  • load the file only if it hasn’t been loaded already. Expect (provide 'foo) in file

after-init-hook

after-init-hook

  • the so-to-say brute-force approach to setting up customizations for packages.

19.1.2. ex

  • function (add-hook 'text-mode-hook 'auto-fill-mode)
  • lambda (add-hook 'latex-mode-hook (lambda () (auto-fill-mode -1))) ;; disable mods
(add-hook 'python-mode-hook
          (lambda ()
            (setq python-indent-offset 2)))

;; another example
(defun mp-add-python-keys ()
  (local-set-key (kbd "C-c q") 'shell))

(add-hook 'python-mode-hook #'mp-add-python-keys)

19.1.3. hooks emacs

  • kill-emacs-hook runs just before exiting Emacs
  • text-mode-hook - Text mode and other modes based on Text mode

19.2. advices

lets you add to the existing definition of a function,

  • defadvice - old
  • advice-add/advice-remove
add-function where place function &optional props
remove-function place function

19.2.1. place

  • :before - Both functions receive the same arguments
  • :after
  • :override - replace original
  • :around - Call function instead of the old function. (lambda (&rest r) (apply function oldfun r))
  • :before-while - Call function before the old function and don’t call the old function if function returns nil
  • :before-until
  • :after-while
  • :after-until - Call function after the old function and only if the old function returned nil.
  • :filter-args - Call function first and use the result (which should be a list) as the new arguments to pass to the old function.
  • :filter-return - Call the old function first and pass the result to function.

19.2.2. old magic

; Suppress "Beginning of buffer" and "End of buffer" messages
(defadvice previous-line (around silencer activate)
  (condition-case nil
    ad-do-it
    ((beginning-of-buffer))))

(defadvice next-line (around silencer activate)
  (condition-case nil
    ad-do-it
    ((end-of-buffer))))

19.2.3. ex

;; 1
(defun my-double (x)
  (* x 2))
(defun my-increase (x)
  (+ x 1))
(advice-add 'my-double :filter-return #'my-increase)

;; 2
(defun my-tracing-function (proc string)
  (message "Proc %S received %S" proc string))

(add-function :before (process-filter proc) #'my-tracing-function)

;; 3
(defun his-tracing-function (orig-fun &rest args)
  (message "display-buffer called with args %S" args)
  (let ((res (apply orig-fun args)))
    (message "display-buffer returned %S" res)
    res))

(advice-add 'display-buffer :around #'his-tracing-function)

;; 4 replace
(advice-add 'artist-no-rb-set-point2 :override #'(lambda (x y) (setq inhibit-message t)) )

19.3. TODO defun redefine

20. isearch

allow delete character in minibuffer:

(define-key isearch-mode-map "\C-h" 'isearch-delete-char) ;; delete character during search C-s

allow to edit search (code is not perfect):

(setq search-exit-option 'edit)

20.1. keys

Enter at empty line execute "Nonincremental search"

  • M-c Toggle search case-sensitivity.
  • C-w appends more words from text to the search string.
  • M-r Toggle between regular-expression searching and literal-string searching.
  • M-e Pause to edit the search string. Searching is disabled until you explicitly resume it with ‘C-j’ (or ‘C-s’ or ‘C-r’). reset search.

20.2. isearch.el - execution path for isearch-forward

  • isearch-mode forward &optional regexp op-fun recursive-edit regexp-function
    • forward = t
    • regexp = nil
    • op-fun = nil

20.3. search-exit-option edit

(setq search-exit-option 'edit)

when you type new key isearch hook it with 'pre-command-hook = isearch-pre-command-hook

  • isearch-edit-string
  • with-isearch-suspended
  • save variables like 'isearch-string'
  • (isearch-done t t) - terminate isearching until editing is done
  • (isearch-mode …) - Always resume isearching by restarting it
  • (setq isearch-string isearch-new-string) - Copy new local values to isearch globals
  • (isearch-post-command-hook) -> isearch-search-and-update

20.4. template for search:

;; - - - replace org-goto (header search) with native C-M-s
(defun my/org-header-search ()
  (if isearch-regexp
      (progn
        (setq isearch-case-fold-search 1)   ; make searches case insensitive
        (setq case-fold-search 1)   ; make searches case insensitive
        (isearch-push-state)
        (setq string "^*.*")
        (isearch-process-search-string
         string (mapconcat 'isearch-text-char-description string ""))
        )
    )
  )
;; (isearch-forward-regexp)
(add-hook 'isearch-mode-hook 'my/org-header-search)

21. history

M-x view-lossage - keys (F1 l)

  • 26.1 - concurrency.

22. Easy Customization Interface

  • interactive system for altering Emacs settings
  • Customize can also interactively change settings for all installed packages
  • All of those values are stored together in a single variable called custom-set-variables
  • M-x customize RET, or
  • M-x customize-group RET <group name> RET - jump you directly into the customization settings for a particular area, which is usually the name of a package itself

22.1. Theme

global:

  • F10 -> 'options' -> 'customize emacs' -> 'custom-themes'.

22.2. custom-set-variables per mode

(deftheme my-notmuch-theme
    " fix display help-echo link at cursor over link
   (custom-set-variables '(help-at-pt-display-when-idle t nil (help-at-pt))) ")
  (custom-theme-set-variables
   'my-notmuch-theme
   '(help-at-pt-display-when-idle t nil (help-at-pt)))
  (provide-theme 'my-notmuch-theme)


  (defun my/notmuch-show-hook ()
    (enable-theme 'my-notmuch-theme)
  )

  ;; (add-hook 'notmuch-search-hook 'my/notmuch-hook)
  (add-hook 'notmuch-show-hook 'my/notmuch-show-hook)

23. wrap lines

ways to handle long lines("Line Wrap"):

  • Hard-Wrap Lines
    • M-q fill-paragraph
    • auto-fill-mode - automatic M-q - insert a line ending after the last word that occurs before the value of option ‘fill-column’ (a column number).
    • refill-mode - it hits M-q automatically after changes to the buffer that might normally trigger auto-filling
  • Soft-Wrap
    • visual-line-mode (built-in)
    • "default wrapping" without toggle-truncate-lines - same as visual-line-mode
    • visual-fill-column-mode (external package)

hard-wrad cons:

  • doesn't perform well across multiple zoom levels
  • may not fill well during exporting

hard-wrad pros:

  • you don't rely on automatic wrapping
  • beauty is in your hands

23.1. fill column

https://www.gnu.org/software/emacs/manual/html_node/emacs/Fill-Commands.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Displaying-Boundaries.html

C-x f Set the fill column

minor modes:

  • M-x display-fill-column-indicator-mode locally
  • M-x global-display-fill-column-indicator-mode globally

24. Dvorak

C-x RET C-\ english-dvorak RET

25. fonts

26. games

  • 5x5 - fill in all the squares
  • animate - make text dance
  • blackbox - find objects by firing beams into a black box
  • bubbles - remove as many bubbles as possible in as few moves as possible.
  • DecipherMode - help for cracking a simple alphabetic substitution cipher
  • DissociatedPress – fun with gibberish
  • EmacsDoctor - psychological help from a Rogerian analyst, for when it’s all getting too much for you
  • dunnet - text-mode dungeon adventure game
  • gomoku - five-in-a-row against the computer
  • hanoi - computer solving the towers of hanoi game
  • igo - Play Go / Weichi / Baduk or read a game in SGF.
  • landmark - neural net robot that learns landmarks; in Emacs 24 it is invoked with landmark; in previous version it is invoked with lm http://www.gnu.org/software/emacs/news/NEWS.24.2
  • life - John Conway’s game of life
  • meese - stop impressionable young minds of America from seeing the etc/sex.6 man page
  • MorseCode - convert text to and from morse code
  • mpuz - multiplication puzzle (hidden digits)
  • pong - two-player computerized ping-pong
  • snake - guide a snake around the screen, eat to grow
  • solitaire - balls on an 8x8 cross shaped grid
  • spook - Generates words to get government’s attention
  • studlify-region - convert text to stUdlY caps
  • TetrisMode - arrange falling blocks (see also: https://github.com/skeeto/autotetris-mode)
  • yow - random Zippy quote
  • ZoneMode - crazy screen effects when idle

27. backup

~backup_file - Single or Numbered Backups #file# - autosave every 300 characters or 30 seconds of idleness. auto save

Created file~ only the first time the file is saved from a buffer

  • diff-backup - see difference with file~

M-x recover-file <RET> foo.c <RET> yes <RET> C-x C-s

M-x recover-session - to recover if crash

27.1. vc-backup

a VC backend that uses "Emacs backup files" for single-file version control.

27.2. autosave

Сохранять #файлы# автосохранения в (setq auto-save-file-name-transforms `((".*" "~/.emacs-saves/" t)))

auto-save-default default is t config:

  • auto-save-interval, default 300 - specifies how many characters there are between auto-saves
  • auto-save-timeout, default 30 seconds

28. diff and ediff

M-x diff/ ediff

  • diff -default -u

ediff

  • n/p - next/previous hunk
  • a - apply version A's hunk
  • b - apply version B's hunk
  • r - revert, undo the applying of the A/B hunk.
  • q - quit ediff session
  • ! - update diff

submenus:

  • Compare
  • Merge
  • Apply Patch.

a b=

29. Narrowing

  • C-x n n narrow-to-region Narrow down to between point and mark.
  • C-x n e narrow-to-element
  • C-x n s narrow-to-subtree in Org mode
  • C-x n w widen Widen to make the entire buffer accessible again
  • C-x n p narrow-to-page
  • C-x n d narrow-to-defun

29.1. pages

  • C-q C-l insert ^L - page delimiter
  • M-x what-page
  • C-x [ backward-page
  • C-x ] forward-page
  • C-x C-p mark-page
  • C-x l count-lines-page
  • C-x n p narrow-to-page

29.2. Cursor Position Information

  • C-x = Display the character code of character after point, character position of point, and column of point
  • M-x what-line
  • M-= count-words-region
  • M-x hl-line-mode - Enable or disable highlighting of the current line

30. Programming

30.1. emacs-lisp-mode

  • C-M-x eval-defun - at any postion
  • C-x C-e eval-last-sexp - only after line
  • M-x eval-region
  • M-x eval-buffer
  • F1 e message buffer
  • F1 f describe function
  • F1 v describe global variable
  • C-M-v/C-M-S-v scroll another window

30.2. IDE Theory

  • highlight syntax
  • find includes
  • find where used

30.3. Project management

https://www.emacswiki.org/emacs/CategoryProject

M-x speedbar - fast navigate between files

30.3.1. projectile

Commands

  • ? p p - list of known Projects
  • ? p m projectile-commander - ? for help
  • ? p k Kills all project buffers.
  • ? p D Opens the root of the project in dired
  • s-p 4 D Opens the root of the project in dired in another window.
  • s-p 5 D Opens the root of the project in dired in another frame.
  • s-p x t Start or visit an ansi-term for the project.
  • s-p C-h(f1) Keys
  • Grep in project: C-c p g s
  1. install

    M-x package-install [RET] projectile [RET]

    (require 'projectile) (with-eval-after-load 'projectile (projectile-mode +1) ;; Recommended keymap prefix on Windows/Linux (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) )

30.4. common keys

  • C-j new line and indent
  • C-M-q indent C-M-\ indent region or all
  • C-i switch indenation for line
  • M-x speedbar
  • M-/ expand previous word
  • C-M-a|e begining|end of function
  • M-x delete-trailing-whitespace
  • M-x whitespace-newline-mode
  • M-; add comment or un/comment region
  • M-j continue comment at new line
  • C-x C-; un/comment line
  • M-s h . highlight all occurance

indentation кол-во пробелов: tab-width (default 8)

  • F1 e messages
  • C-x d dired
  • C-x C-e debugging

C-x TAB indentation mode with arrows.

M-x toggle-truncate-lines Disable lines wrap

30.4.1. balanced expressions (NavigatingParentheses)

Navigation

  • C-M-d/k down/up-list
  • C-M-n/p forward/backward-list Move forward over a parenthetical group
  • C-M-f forward-sexp Move up
  • C-M-b backward-sexp Move down
  • C-M-k kill-sexp Kill balanced expression forward
  • C-M-SPC mark-sexp select balanced expression forward

30.4.2. copy in terminal

Ctrl+W: Cut the word before the cursor Ctrl+K: Cut after the cursor Ctrl+U: Cut before the cursor

30.4.3. Looking Up Identifiers (xref)

  • M-. go to definition
  • C-x 4 . RET Find definitions of identifier, but display it in another window
  • C-x 5 . RET Find definition of identifier, and display it in a new frame
  • M-, Go back to where you previously invoked M-. and friends
  • C-M-. pattern Find all identifiers whose name matches pattern

30.5. Perl

M+x cperl-mode help C-h f cperl-mode

30.6. TODO company-mode

https://www.monolune.com/configuring-company-mode-in-emacs/ https://readingworldmagazine.com/emacs/2020-07-27-emacs-company-mode/ https://readingworldmagazine.com/emacs/2021-09-01-emacs-company-continued-first-thing-to-do-when-developing-with-emacs/

  • company
  • company-jedi - company-mode completion back-end for Python JED
  • emacs completion framework It comes with several back-ends: Elisp, Clang, Semantic, Ispell, CMake, BBDB,

Yasnippet, Dabbrev, Etags, Gtags, Files, Keywords

  • Not Python

30.7. Python

pip jedi - Python JEDI lib - autocompletion, static analysis and refactoring library for Python

pappasam/jedi-language-server - LSP server for jedi

plugins

  • elpy - big
  • jedi - big
  • Eglot - part of Emacs since 2.9

completion by itself

  • CompanyMode - become more popular
  • AutoComplete

auto-completion for Python

Code generation

  • yasnippet

Code checker

  • Flycheck and FlyMake can be used to wrap checkers such as pep8, pyflakes (flake8 includes both), pylint and pychecker. Both support multiple checkers per buffer.
  • autopep8 - formats Python code to conform to the PEP 8 style guide using the pep8 tool.
  • black

Viewing generated documentation

  • pydoc
    • helm-pydoc
  • elpy

30.7.1. jedi - static analysis tool for Python

  • refactoring, code search and finding references
  • (Jedi.el, company-mode, elpy, anaconda-mode, ycmd)
  1. jedi-core details
    • Not support v 18
    • jedi-core configuration without jedi:install-server:
    • info - jedi:show-setup-info

    dependencies:

    • python-environment-0.0.2 - virtualenv API for Emacs Lisp
      • deferred-0.3.1 - Simple asynchronous functions for emacs lisp
    • epc-0.1.0

    jediepcserver.py - located in .emacs.d/elpa/jedi-core-0.2.8/jediepcserver.py

    jedi install server:

    • "pip" "install" "–upgrade" ,(convert-standard-filename jedi:source-dir)
    • python-environment-default-root-name is used
    • jedi:environment-root

    steps:

    • pip download jedi
    • pip hash –algorithm sha512 ./jedi-0.17.1.tar.gz
    • requirements.txt
      • jedi==0.17.1 –hash=sha512:b86297b2fbb212695469b34288836e3346a33c5c6b83337dbe4ceaaeb2b4185dcb6c888336e24f6da3fe22a39c803af5c34ae5a4ed1d177fde1c1d7fc143bf09
      • parso==0.7.1 –hash=sha512:19c30d07a8982323ffbeba3fa36c8f504f49991c54df595e47defca1b1ba94ab3f5203485e6459012adfd440cc648dd8cfd44c571f02db7ed8e49f372eb3df3a
      • epc==0.0.5 –hash=sha512:e2b75850e39bb0f3c16f5b84f55dec675a8fe2b61ff5fd55704ef677317d698865a99fc495247cd753a2c8329729f45bc7f81f42dd4c6d27b31810c0aac831e2
      • sexpdata==0.0.3 –hash=sha512:419fa731fb0b953c404a71f1b5f88777546405618913b1d2e4abab7a876d285d43cd035addffb9d221571214e00151e908e8ef6b99295dacee8ca3f4c8ba942e
    • pip install –no-cache-dir –use-pep517 –no-binary=:all: –require-hashes –user -r requirements.txt
  2. emacs-jedi

    completion framework for jedi

    requirements:

    • virtualenv
    • setuptools
    • pip install virtualenv –user
    • M-x package-install RET jedi

    (with-eval-after-load 'jedi-core ;;standard-jedi-settings (setq jedi:environment-virtualenv (list (expand-file-name "~/.emacs.d/.python-environments/"))) ;; (setq jedi:environment-root "jedi") ; or any other name you like (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t) (setq jedi:use-shortcuts t) )

    1. M-x jedi:install-server in Emacs
    1. keys

      <C-tab> jedi:complete

      Complete code at point.

      C-c ? jedi:show-doc

      Show the documentation of the object at point.

      C-c . jedi:goto-definition

      Goto the definition of the object at point.

      See jedi:goto-definition-config for how this function works when universal prefix arguments (C-u) are given. If numeric prefix argument(s) (e.g., M-0) are given, goto point of the INDEX-th result. Note that you cannot mix universal and numeric prefixes. It is Emacs’s limitation. If you mix both kinds of prefix, you get numeric prefix.

      When used as a lisp function, popup a buffer when OTHER-WINDOW is non-nil. DEFTYPE must be either assignment (default) or definition. When USE-CACHE is non-nil, use the locations of the last invocation of this command. If INDEX is specified, goto INDEX-th result.

      C-c , jedi:goto-definition-pop-marker

      Goto the last point where jedi:goto-definition was called.

      variable (jedi:use-shortcuts nil)

      If non-nil, enable the following shortcuts: M-. jedi:goto-definition M-, jedi:goto-definition-pop-marker

  3. company-jedi

    completion back-end of company autocompletion framework for JEDI

    • M-n/M-p - next/previous candinate
    • Tab - Insert the common part of all the candidates
    • C-c ? - show doc (jedi)
    • M-x company-ispell - english words candidated
    • F1 - show doc after menu opens
    (add-hook 'python-mode-hook 'jedi:setup)
    (add-hook 'python-mode-hook 'company-mode)
    
    (with-eval-after-load 'jedi-core
      (setq jedi:environment-virtualenv (list (expand-file-name "/home/u/.local/lib/python3.10/site-packages")))
    
      (setq jedi:complete-on-dot t)
      (setq jedi:use-shortcuts t)
      ;; my
      (setq jedi:get-in-function-call-timeout 0
        jedi:get-in-function-call-delay   0
        jedi:goto-definition-config    '((nil definition nil))
        )
      (add-to-list 'company-backends 'company-jedi)
      )
    

    old:

    (with-eval-after-load "company-jedi"
      ;; use-package company-jedi             ;;; company-mode completion back-end for Python JEDI
    
      ;;standard-jedi-settings
      (add-hook 'python-mode-hook 'jedi:setup)
      (setq jedi:complete-on-dot t)
      (setq jedi:use-shortcuts t)
      ;;company-jedi-settings
      (setq jedi:environment-virtualenv (list (expand-file-name "~/.emacs.d/.python-environments/")))
      (defun my/python-mode-hook ()
        (add-to-list 'company-backends 'company-jedi))
      (add-hook 'python-mode-hook 'my/python-mode-hook)
    
      ;; backend-settings
      (setq elpy-rpc-backend "jedi")
    
      )
    
  4. anaconda-mode
    • support jedi 18
    • required:

      • service_factory
      • jedi

      optional requirements: company-anaconda

  5. troubleshooting

    deferred error : (wrong-type-argument epc:manager nil)

    • solution: comment # import pkg_resources in ~/.emacs.d/contrib/lisp/emacs-jedi/jediepcserver.py

30.7.2. TODO lsp-pyright vs pyright - type checking

30.7.3. TODO elpy+pyright+eglot

30.7.4. eglot - lsp interface: pyright

Distributed with GNU Emacs since Emacs version 29.1

for jedi require jedi-language-server

https://github.com/joaotavora/eglot

30.7.5. company-jedi

requirements: pip install sexpdata-0.0.3.tar.gz pip install epc-0.0.5.tar.gz pip install virtualenv-15.1.0.tar.gz

M-x jedi:install-server

jedi required 0.17.2

C-c ? - get documentatio for object

30.7.6. elpy MELPA

install elpy for MELPA

  • pip3 install flake8 –user
  • .bashrc: export PATH=$PATH:~/.local/bin
  • M-x elpy-doc - configure doc for C-c C-d
  • C-c C-p - start python window
  • C-c C-c - in text - run all bufer in started python window
  • C-c C-r - in text - run region
  1. setup example

    (defun my/python-mode-hook () (add-to-list 'company-backends 'company-jedi))

    (add-hook 'python-mode-hook 'my/python-mode-hook) (company-jedi 1)

    (setq elpy-rpc-backend "jedi") (add-hook 'python-mode-hook 'jedi:setup)

    (global-set-key "\C-x\C-j" 'jedi:goto-definition) (global-set-key "\C-x\C-k" 'jedi:goto-definition-pop-marker)

  2. TODO artile
    1. install elpy for MELPA
    2. install:
      • dev-python/jedi - wesome autocompletion, static analysis and refactoring library for Python
      • dev-python/black - Python code formatter
      • dev-python/autopep8 - automatically formats Python code to conform to the PEP 8 style guide
      • dev-python/yapf - ?
      • dev-python/flake8 - syntax checker
      • dev-python/rope - ?
    3. M-x elpy-config
    4. M-x pyvenv-activate ( not shure)
    5. M-x elpy-rpc-reinstall-virtualenv ( not shure)
    6. (setq elpy-rpc-virtualenv-path 'current) (not shure)
    7. Enable:
      • file variables: # ; -- mode: Python; eval: (elpy-enable); fill-column: 100; --
      • or .emacs
    1. keys:
      • C-C C-d - get doc
      • M-Tab - autocompletion
      • C-c C-v - elpy-check syntax (automatic at save)
      • M-; - comment
      • C-c C-c - send all to python shell
      • C-RET - send current line
      • C-c C-r - rename varibale
      • C-c < python-indent-shift-left
      • C-c > python-indent-shift-right
    2. ERROR line too long
  3. in org

    ipython:

       (org-babel-do-load-languages
        'org-babel-load-languages
        '((python . t)))
    
       (setq org-babel-python-command "ipython3 --no-banner --classic --no-confirm-exit")
    

    or with shell:

       (org-babel-do-load-languages
        'org-babel-load-languages
        '((python . t)))
    
       (setq shell-command-switch "-ic")
    

    execute without ask

       ;; all python code be safe
       (defun my-org-confirm-babel-evaluate (lang body)
         (not (string= lang "python")))
       (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
    

30.7.7. flymake - erros checking

  • require python-pyflakes
  • emerge –ask dev/python-pyflakes (add-hook 'python-mode-hook (lambda () (flymake-mode) ))

i am not shure if it is required:

  • package: flymake-python-pyflakes
  • .emacs
    • (require 'flymake-python-pyflakes)
    • (add-hook 'python-mode-hook 'flymake-python-pyflakes-load)

30.7.8. flycheck - errors checking

native supprot for: python-flake8 or python-pylint, and falls back to python-pycompile if neither of those is available

  • emerge –ask dev-python/flake8
(add-hook 'python-mode-hook
  (lambda ()
    (flycheck-mode)
    ))

(defun my/python-mode-hook () (local-set-key (kbd "<M-left>") 'python-indent-shift-left ) (local-set-key (kbd "<M-right>") 'python-indent-shift-right ) ;; (display-line-numbers-mode) ;; indentation (setq python-indent-offset 4) ;; errors checking (flycheck-mode) kk)

  1. links

30.7.9. treesit tree-sitter

  1. app-editors/emacs tree-sitter
    • M-: (treesit-available-p) RET should return t
  2. emerge –ask dev-libs/tree-sitter-python # replace M-x treesit-install-language-grammar
    • treesit-language-source-alist - list of sources in github
    • M-: (treesit-language-available-p 'python) RET should return t
  3. python-ts-mode and python-mode - are different. To remap:
    • (add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
    • (setq major-mode-remap-alist '((c-mode . c-ts-mode) (yaml-mode . yaml-ts-mode) (bash-mode . bash-ts-mode)))

Notes:

  • get supported ts mode: C-h a -ts-mode

Before Tree-sitter, your beautiful source code was parsed using some sort of regex engine in most editors.

for:

  • syntax highlighting, code analysis, or incremental selection for example
  • code folding
  • selection around cursor
  • intelligence code snippets
  1. function

    tree-sitter-save-excursion

30.9. php mod

C-M-<HOME> Move point to the beginning of the current function (beginning-of-defun). C-M-<END> Move point to the end of the current function (end-of-defun).

C-M-\ Properly indent each line of region (indent-region). C-c C-q Properly indent each line of current top-level function or top-level class (c-indent-defun).

M-; Insert comment at point (comment-dwim). If comment already exist, indent comment (comment-indent). M-j Insert a newline in a comment on the next line with the comment starting at the same column as the current line (c-indent-new-comment-line). C-c C-c Comment out the current region (comment-region). If region is already commented, the region is uncommented. C-u M-; Kill the comment on the current line (comment-kill called by comment-set-column or comment-dwim). C-u n M-; Kill the next n comments (comment-dwim).

convert the tabs to spaces:

  1. C-x h
  2. M-x untabify RET

M-? find usages (xref-find-references)

30.10. Ctags or tagging system

people usually use ctags to do two things

  • Code navigation
  • Auto-complete/IntelliSense

30.10.1. GNU Global

https://developpaper.com/use-gnu-global-to-read-code-in-emacs/ ggtags https://github.com/leoliu/ggtags

Emacs frontends to GNU Global:

  • It is similar to older tagging software such as ctags and etags, but differs in its independence from any specific text editor.
  • alternative with better functionality for C, C++, Yacc, Java, PHP4 and assembly language.
  • ggtags
  • helm-gtags
  • gtags-mode (global build in)

create tags:

  • M-x ggtags-create-tags RET
  • $ gtags
  • $ gtags -c create compact database

find

  • global -T -x string - T search in libs. x - verbose
  1. Libraries:

    https://emacs.stackexchange.com/questions/13254/find-external-definition-with-gtags-or-ggtags

    • If you want to locate symbols that are not defined in the source tree, then you can specify library directories with GTAGSLIBPATH environment variable.
    • You should execute gtags(1) at each directory in the GTAGSLIBPATH. If ‘GTAGS’ is not found there, global ignores such directories.
      • $ global strlen # strlen() is not found
      • $ (cd /usr/src/lib; gtags) # library source
      • $ (cd /usr/src/sys; gtags) # kernel source
      • $ export GTAGSLIBPATH=/usr/src/lib:/usr/src/sys
      • $ global strlen ../../../usr/src/lib/libc/string/strlen.c # found in library $ global access ../../../usr/src/sys/kern/vfs_syscalls.c # found in kernel

    or

    • $ ln -s /usr/src/lib .
    • $ ln -s /usr/src/sys .
    • $ gtags

    locate library

    • $ gcc -v –print-file-name=libc.a
    • By default libraries are installed in /usr/lib and header files will be in /usr/include
    • Usually extension of the library file is .so(dynamic) .a(static) and corresponding header file will be .h
    • $ echo "#include <bogus.h>" > t.c; gcc -v t.c; rm t.c
    • echo "#include <bogus.h>" | gcc -v -x c -

30.10.2. GNU etags, ctags - generate tag file for Emacs, vi

  • part of GNU Emacs - The Emacs distribution includes etags, a command for tagging identifier definitions in programs
  • create tag table (defaults file names: TAGS for etags, tags for ctags)
  • The etags format understood by emacs(1);
  • the ctags format understood by vi(1).
  • key bindings for tag navigation were mostly given to Xref (see 30.10.3), Some major modes provide built-in means for looking up the language symbols.
  • Semantic package provides another way to generate and use tags, separate from the etags facility.
  • The Ebrowse facility is similar to etags but specifically tailored for C++.

create a tags table file:

find . -name "*.[chCH]" -print | etags -
  • Emacs has at any time at most one selected tags table
    • M-x visit-tags-table RET / RET
    • (setq tags-table-list '("~/.emacs.d" "/usr/local/lib/emacs/src"))
    • Do not set both tags-file-name and tags-table-list.

to enable table:

  • M-x visit-tags-table RET / RET

simple approach:

  • (require 'etags-select)
  • (require 'etags-table)
  • (global-set-key "\M-." 'etags-select-find-tag)

30.10.3. emacs Xref

Starting with Emacs 25, the default key bindings for tag navigation were mostly given to Xref, but the tags commands they were previously bound to are still available.

  • Xref abstracts over multiple identifier-searching backends (one of them being the tags backend)
  1. Xref Keys
    • `M-.’ (‘xref-find-definitions’)
    • `C-x 4 .’ (‘xref-find-definitions-other-window’) – select the buffer containing a tag’s definition in another window, and move point there.
    • `M-,’ (‘xref-pop-marker-stack’) – jump back
    • `C-M-.’ (‘xref-find-apropos’) – find all meaningful symbols that match a regexp or word list
    • `M-?’ (‘xref-find-references’) – find all references to the identifier at point
  2. Tags Keys
    • `M-.’ (‘find-tag’) – find a tag, that is, use the Tags file to look up a definition. If there are multiple tags in the project with the same name, use `C-u M-.’ to go to the next match.
    • ‘M-x find-tag-other-window’ – selects the buffer containing the tag’s definition in another window, and move point there.
    • ‘M-*’ (‘pop-tag-mark’) – jump back
    • ‘M-x tags-search’ – regexp-search through the source files indexed by a tags file (a bit like ‘grep’)
    • ‘M-x tags-query-replace’ – query-replace through the source files indexed by a tags file
    • `M-,’ (‘tags-loop-continue’) – resume ‘tags-search’ or ‘tags-query-replace’ starting at point in a source file
    • ‘M-x tags-apropos’ – list all tags in a tags file that match a regexp
    • ‘M-x list-tags’ – list all tags defined in a source file
  3. links

30.10.4. rtags

based on LLVM/Clang

executables

  • rdm - server application, and monitors all your indexed files for changes, and reindexes
    • rp - used by rdm, when a source file or one of its dependencies is modified
    • rc - needs specific information about how your sources are compiled to be able to properly index them
    • ~/.rdmrc - to start rdm with specific options

30.11. Flymake vs Flycheck

  • Flymake is build-in

Flycheck uses backend check program https://www.flycheck.org/en/latest/languages.html#flycheck-languages

30.12. semantic

  • integrated with etags
  • build in
  • supported tools are GNU Global, GNU Idutils, CScope, and Grep (the fallback method). For best results, use GNU Global.

usage:

  • right mouse button
  • C-c , j semantic-complete-jump-local defined in the current file
  • C-c , J semantic-complete-jump defined in any file Emacs has parsed, and move point there
  • C-c , SPC Display a list of possible completions for the symbol at point (semantic-complete-analyze-inline)
  • C-c , l Display a list of the possible completions of the symbol at point, in another window

(semantic-add-system-include "/usr/include/boost" 'c++-mode) (semantic-add-system-include "~/linux/kernel") (semantic-add-system-include "~/linux/include")

30.13. TODO gdm

https://tuhdo.github.io/c-ide.html (setq ;; use gdb-many-windows by default gdb-many-windows t

;; Non-nil means display source file containing the main routine at startup gdb-show-main t )

M-x gdb

run gdb (like this):gdb -i=mi source_file

To use gdb-many-windows, you must always supply the -i=mi argument to gdb, otherwise gdb-many-windows won't work.

30.14. autoformat

  • M-q fill-paragraph

You can control such indentation using options lisp-indent-offset and lisp-body-indent, option lisp-indent-function, or symbol property lisp-indent-function. One possible value for option lisp-indent-function is the value of common-lisp-indent-function. http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Indent.html http://www.gnu.org/software/emacs/manual/html_node/emacs/Program-Indent.html

30.15. SQL mode

M-x sql-sqlite

30.16. SQL in org:

SQL mode is used to edit SQLite source code blocks.

two variants: sql and sqlite

there is package in MELPA: ob-sql-mode - SQL code blocks evaluated by sql-mode

sql-mode

30.16.1. sqlite

sqlite3 to evaluate SQL statements

ob-sqlite.el used, must be part of emacs

(org-babel-do-load-languages
 'org-babel-load-languages (quote ((emacs-lisp . t)
                                    (sqlite . t)
                                    (sql . t)
                                    (R . t)
                                    (python . t))))
create table greeting(one varchar(10), two varchar(10));
insert into greeting values('Hello', 'world!');
select * from greeting;

30.17. yaml

  • (yaml . t) ;; llhotka/ob-yaml
  • flymake-yamllint ;; require dev-util/yamllint (based on python dev-python/pyyaml
  • flymake-yaml ;; require Psych or Syck (Ruby 1.8/1.9 standard library) dev-ruby/psych and flymake-easy emacs package.

flymake-goto-next-error’ and ‘flymake-goto-prev-error

  1. flymake-yamllint
    (add-hook 'yaml-mode-hook 'flymake-yamllint-setup)
    
    (add-hook 'yaml-mode-hook (lambda ()
                                (local-set-key "\C-c\C-n" 'flymake-goto-next-error)
                                (local-set-key "\C-c\C-k" 'flymake-goto-next-error)
                                ))
    
  2. serialize with PyYAML

    dev-python/pyyaml

    aa:
      - b
      - 'c"as"c'
    
    ---
    s: asd
    
    import yaml
    for data in yaml.load_all("""
    aa:
      - b
      - 'c"as"c'
    
    ---
    s: asd""", yaml.SafeLoader):
        print(data)
    
    {'aa': ['b', 'c"as"c']}
    {'s': 'asd'}
    

30.18. ELisp

https://github.com/susam/emacs4cl - tiny .emacs file to set up Emacs quickly

31. completion

32. spell checking

32.1. aspell

  • emerge app-text/aspell - English and flycheck-aspell Emacs package
  • C-M-i Complete the word before point based on the spelling dictionary (ispell-complete-word).
  • M-x ispell-change-dictionary RET dict RET

USE="l10n_en l10n_ru" emerge app-text/aspell

32.2. flyspell (not used)

aspell dicts # available dictionaries
(add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
(require 'flyspell)
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'org-mode-hook 'flyspell-mode)
(define-key flyspell-mode-map (kbd "C-.") 'helm-flyspell-correct)
(setq-default ispell-program-name "aspell")

32.3. TODO hunspell

  • emerge app-text/hunspell

link https://hunspell.github.io/

33. Math symbols

33.1. xah-math-input

http://xahlee.info/emacs/emacs/xmsi-math-symbols-input.html

install:

Type “inf”, then press 【Shift+Space】 `xah-math-input-change-to-symbol', then it becomes “∞”.

For the complete up-to-date list: Alt+x xah-math-input-list-math-symbols

inf ∞ empty,es ∅ +- ± forall ∀ exist ∃ isin ∈ notin ∉ ni ∋ sum ∑ int ∫ cap ∩ union,cup ∪ sim ∼ asymp ≈ equiv ≡ ne ≠ nsub ⊄ sube ⊆ supe ⊇ sub ⊂ sup ⊃ D Δ O Ω q θ nabla ∇ part ∂ rt √ rp ∘ cp ⊕ ct ⊗

Ancient Greek:

  • a - α; b-β; g-γ; d-δ; e-ε; z-ζ; h-η; q-θ; i-ι; k-κ; l-λ; m-μ; n-ν; x-ξ; p-π; r-ρ; s-σ; t-τ; v-υ; f-φ; c-χ; y-ψ; o-ω
  • A-Α; B-Β; G-Γ; D-Δ; E-Ε; Z-Ζ; H-Η; Q-Θ; I-Ι; K-Κ; L-Λ; M-Μ; N-Ν; X-Ξ; P-Π; R-Ρ; S-Σ; T-Τ; V-Υ; F-Φ; C-Χ; Y-Ψ; O-Ω;

and https://github.com/xahlee/xah-math-input/blob/master/xah-math-input.el

install from MELPA: Alt+x list-packages

33.2. company-math

Start math completion by typing the prefix \ key.

  • math latex tags company-math-symbols-latex
  • math unicode symbols company-math-symbols-unicode
  • latex commands company-latex-commands

34. Terminal, shell

emacs -g '80x24' –eval '(term "/bin/bash")'

M-x term

  • C-c C-k char mode
  • C-c C-j line mode
    • C-c char = C-x char
  • C-c C-c = C-c (term-interrupt-subjob)
  • C-c C-q - page at a time feature
    • q - exit - Not working
  • S-insert - yank in char mode

insert result of shell command to buffer:

C-u A-!

35. dired

35.1. basic

  • C-x d M-x dired
  • C-x C-j M-x dired-jump - Jump to Dired buffer corresponding to current buffer.

C-x C-f - ?

Mark:

  • h help
  • m dired-mark
  • % m mark with regex
  • u/U unmark/Unmark all marked
  • * Mark all executable file
  • @ Mark all symbolic links
  • / Mark with `*' all files which are actually directories
  • % d regexp RET - mark with regex by name
  • t invert selection

Delete:

  • d mark for deletion
  • x Delete the files that are flagged for deletion.

Visit:

  • e/f/RET dired-find-file
  • v view-mode and q to close
  • f/o/C-o visit in other window/dont switch
  • a visit and kill current buffer
  • & open in any program
  • W open in default program

Navigation:

  • ^ dired-up-directory
  • > next directory
  • < preview directory
  • SPC moves the cursor down one item.
  • ( dired-hide-details-mode

Commands:

  • c compress to (TODO)
  • shift+c copy file - dired-do-copy
  • shift+r rename/move - dired-do-rename
  • shuft+d delete - dired-do-delete
  • + dired-create-directory
  • shift+z Compress/decompress the file by gzip
  • ! shell command on file
  • g Update the entire contents of the Dired buffer
  • l Update the specified files

Submodes:

  • C-x C-q (dired-toggle-read-only) - wdired
    • SPC - change permission

not defined:

  • b z F K @ [ { ; \ | , / `
  • r E J V ) ] } ' "

Open:

BKSP moves the cursor up one item.

g rereads the directory. RET opens the item in the current window. o (small O) opens the item in the other window.

Use C-h m or M-x describe-mode to get some help.

35.2. Copy files dired

Mark the files with m or unmark with u. Press R. Enter the destination directory. Press RET.

  1. in .emacs: (setq dired-dwim-target t)
  2. C-x 3 - to open other window
  3. m - mark files
  4. shift+c - copy; shift+r - move

35.3. over ssh

TRAMP stands for “Transparent Remote (file) Access, Multiple Protocol”.

  • /ssh:user@host:/path/to/file
  • /sudo:localhost:/path/to/file # as root
  • /sftp:user@host:/path/to/file
  • /sshfs:user@host:/path/to/file.
  • /adb::/path/to/file # android
  • /ssh:bird@bastion|ssh:you@remotehost:/path RET
  • /ssh:daniel@melancholia#42:.emacs # port 42
  • /ssh:[::1]:.emacs # ipv6

steps:

  1. C-x C-f to initiate find-file, enter part of the TRAMP file name, then hit TAB for completion.
  2. TRAMP invokes connection to remote host
  3. Upon successful login, if TRAMP recognizes the shell prompt from the remote host, invokes /bin/sh.
  4. executes cd and ls commands to find which files exist on the remote host. TRAMP checks if a file or directory is writable with test.
  5. TRAMP transfers the file contents from the remote host.
  6. Edit, modify, change the buffer contents as normal, and then save the buffer with C-x C-s.
/:/tmp/foo*bar # ‘/:’ can also prevent ‘~’ and '*' from being treated as a special character

35.4. usecase

I use dired in a "two pane" style (two windows with dired buffers and (setq dired-dwim-target t)) in a separate frame on it's own workspace. I use arrow-keys for navigation (see key-bindings below) this way dired buffers accumulate quickly, I use helm to switch between them. Never felt the need for something like bookmarks.

I also use:

dired-async.el

trashed

dired-subtree

dired-du

dired-filter

dired-rifle

Here is the dired related part of my .emacs

(defun always-t-p (args) "always returns true" (interactive "P") t ) (setq dired-isearch-filenames 'dwim dired-listing-switches "-alhv –time-style=+%F –group-directories-first" dired-no-confirm t ;don't list marked files when performing action, still asks for confirmation dired-deletion-confirmer 'always-t-p ;don't ask for confirmation trashed-action-confirmer 'always-t-p dired-clean-confirm-killing-deleted-buffers nil ;kill dired-buffer when corresponding dir is deleted delete-by-moving-to-trash t ;use systems trash dired-recursive-deletes 'always ;delete dirs even if non-empty dired-dwim-target t ;copy/move to other side dired-filter-revert 'always wdired-allow-to-change-permissions t dired-du-size-format t )

(add-hook 'dired-mode-hook (setq display-line-numbers 'relative)))

;; some function-definitions and keybindings for dired (defun dired-toggle-details-and-du-mode () (interactive) """toggles dired-du-mode together with dired-hide-details-mode""" (if dired-hide-details-mode (progn (dired-hide-details-mode 0) (dired-du-mode 1)) (progn (dired-hide-details-mode 1) (dired-du-mode -1)))) (define-key dired-mode-map (kbd ".") 'dired-hide-dotfiles-mode) (define-key dired-mode-map (kbd "r") 'dired-rifle) (define-key dired-mode-map (kbd "b") 'dired-subtree-toggle) (define-key dired-mode-map (kbd "i") 'dired-subtree-toggle) (define-key dired-mode-map (kbd ";") 'dired-subtree-down) (define-key dired-mode-map (kbd "'") 'dired-subtree-up) (define-key dired-mode-map (kbd "\"") 'dired-subtree-narrow) (define-key dired-mode-map (kbd "f") 'dired-filter-mode) (define-key dired-mode-map (kbd "z") 'dired-du-mode) (define-key dired-mode-map (kbd ",") 'trashed) (define-key dired-mode-map (kbd "l") 'dired) (define-key dired-mode-map (kbd "\\") dired-filter-mark-map) (define-key dired-mode-map (kbd "]") 'dired-rsync) (define-key dired-mode-map (kbd "<tab>") 'other-window) (define-key dired-mode-map (kbd "<right>") 'dired-find-alternate-file) (define-key dired-mode-map (kbd "<left>") 'dired-up-directory) (define-key dired-mode-map (kbd ")") 'dired-toggle-details-and-du-mode) (define-key trashed-mode-map (kbd "<tab>") 'other-window)

35.5. images

M-x image-dired - show image thumbnails

35.7. How to open several files in Dired:

  • mark files with #'dired-mark
  • for sync call: press ! #'dired-do-shell-command and for async call: & '#dired-do-async-shell-command
  • type name of command to execute command for each file separately.
  • if you want to execute file by concatenating them to one command type: "command *"

36. Org mode

#+STARTUP: overview

overview top-level headlines only content all headlines showall no folding of any entries showeverything show even drawer contents

Any trouble: M-x toggle-debug-on-error

36.1. navigate keys

  • C-c C-n/p next prev heading
  • C-c C-f/b next prev same level heading
  • C-c C-u Backward to higher level heading.
  • C-c C-j search in headers!
  • M-{ org-backward-element
  • M-} org-forward-element

36.2. keys

  • C-c ' special editor: src block, tables, LaTeX, footnote, timestamp
  • C-c Tab narrow header
  • C-u Tab harrow all headers
  • C-u C-u Tab startup headers visibility

36.3. TODO attachments

C-c C-a

36.4. special symbols (TAB)

C-q TAB insert TAB C-u 4 C-q insert 4 TABs

  • asd
  • asd
  • asd
  • asd
  • asd
  • df

36.5. headers

:VISIBILITY: all

  • property, may be: folded, children, content, and all
  • (custom-set-variables '(org-startup-folded t) - every headers will start folded
  • TAB S-TAB hide show
  • C-c Tab hide current header
  • C-c C-npfbu navigate by headers

M-S-Left/Right PROMOTE SUBTREE

C-RET inser HEADER after all text C-c * text to header M-RET new list item M-S-RET TODO S-righ, left or C-c C-t TODO, DONE M(-S)-right lieft up down move and indentation

C-x n s/w редактировать только один уровень

C-c / C-c C-c. sparse tree

36.5.1. TAGS

header tags: * header :as:asd: subheadings willl accumulate all tags. file tags: #+FILETAGS: :Peter:Boss:Secret: C-c C-q (C-c C-c) insert C-c \ search

36.5.2. TODO

S-LEFT/RIGHT - cycle S-UP/DOWN - change item priority

36.6. lists

ordered lists: 1.1) unordired -,+,* description list

asd
asd
[ ] (no term)
sss

M-RET insert new S-left,right cycle bullets -,+,*,1 (C-c -) M-left,right Increase the indentation of an item M-S-RIGHT Increase the indentation of an item with children C-C Toggle check box

C-c ^ sort

C-c - Convert lines to lists

C-x r N and C-u C-x r N - emacs list

36.7. Checkboxes

  • M-S-RET create at list - cursor at the end of the end of the list item
  • C-c C-c togle
  • C-c C-x C-r toggle-radio-button - switch others ff
[/]		add parts
[%]		add percents

ex:

  • [-] percet [1/2] [50%]
    • [X] 1
    • [ ] 2

36.8. Properties

C-c C-x p Set a property. C-c C-c d Remove

see headers.

36.9. Time Stamp

  • C-c . ins. for agenda
  • C-c ! ins. inactive
  • S-left/right by one day
  • M-S-LEFT / M-S-RIGHT move selection 1 month backward/forward
  • < / > scroll calendar by 1 month
  • C-v / M-v scroll calendar by 3 months
  • M-S-UP / M-S-DOWN scroll calendar by 1 year
  • S-up/down change at cursor

36.10. Tables

http://orgmode.org/manual/Built_002din-table-editor.html

C-c | create table 5x2 C-c autoaligh all table

asd asd

M-a/e move back forward at cells M-arrays move line or row in table Tab - autocomplition

36.11. links [ [ link][description]]

  • C-c C-l edit link
  • C-c C-x C-v show hide image inline
  • C-c C-o open link
  • C-u C-u C-c C-o open not in emacs
  • M-x org-toggle-link-display

[[LINK][DESCRIPTION] ] [[ ./a.img - inline image ends with \]\]

Local links (same buffer) :

  1. [[Target local link to header
  2. [[My Target local link to just string #+NAME: My Target
  3. [[./papers/last.pdf’]

external links(sepparate buffer)

  1. projects.html:: name - go had "* name" OR to <<name >>
  2. papers/last.pdf
  3. sometextfile:: NNN (jump to line number)
  4. projects.html:: *task title’ (headline search)
  5. projects.html:: #custom-id’ (headline search)
  6. ls
  7. org-store-link
  8. org#External
  9. https://orgmode.org/
  10. java:Active

org#External links

Internal links.

  • coderef:
  • custom-id:
  • fuzzy:
  • radio:

example Mylink to TragetEx

36.11.1. Applications for opening `path' items in a document:

(setq org-file-apps
    '(("\\.docx\\'" . default)
      ("\\.mm\\'" . default)
      ("\\.x?html?\\'" . default)
      ("\\.pdf\\'" . default)
      ("\\.png\\'" . default)
      ("\\.jpg\\'" . default)
      ("\\.jpeg\\'" . default)
      (auto-mode . emacs)))

36.11.2. links

(org-open-at-point) calls (org-link-open) which uses the variable (org-link-parameters)

;;;; "http", "https", "mailto", "ftp", and "news" link types
;; (dolist (scheme '("ftp" "http" "https" "mailto" "news"))
(dolist (scheme '("http" "https"))
  (org-link-set-parameters scheme
               :follow
               (lambda (url arg)
                 (browse-url (concat "http:" url) arg))))

36.12. links images, inline images

STARTUP(org-startup-with-inline-images) - inlineimages or noinlineimages

  • C-c C-x C-v (org-toggle-inline-images)

example:

[[path to image]

configuration:

  • (setq org-startup-with-inline-images "inlineimages")
  • (setq org-mode-actual-width)
    • t - When non-nil, use the actual width of images when inlining them
    • 300 - When set to a number, use imagemagick (when available) to set the image’s width to this value.
    • '(300 200) - use #+ATTR.* keyword if it matches a width specification like #+ATTR_HTML: :width 300px or this number
    • nil - use #+ATTR.* or dont resize

M-x

  • org-redisplay-inline-images
  • org-display-inline-images
  • org-toggle-inline-images
  • org-remove-inline-images
  1. si
    1. M-x add-file-local-varible-prop-line
    2. org-image-actual-width
        org-image-actual-width is a variable defined in ‘org.el’. Its value is t
    
        Documentation: Should we use the actual width of images when inlining them?
    
        When set to t, always use the image width.
    
        When set to a number, use imagemagick (when available) to set the image’s width to this value.
    
        When set to a number in a list, try to get the width from any #+ATTR.* keyword if it matches a width specification like
    
    #+ATTR_HTML: :width 300px
    
        and fall back on that number if none is found.
    
        When set to nil, try to get the width from an #+ATTR.* keyword and fall back on the original width if none is found.
    
        This requires Emacs >= 24.1, build(sic) with imagemagick support.
    

36.13. Inline source code babel

Exclude tree and its subtrees:

  • C-c C-q set tag "noexport"

exclude tags: EXCLUDE_TAGS - default value "noexport"

36.13.1. theory

#+begin_src <language>  <switches> <header arguments>
,<body>
#+end_src
  • <switches> Control code execution, export, and format.
  • <header arguments> Header arguments control many facets of code block behavior, including tangling, evaluation, handling results of evaluation, and exporting.

36.13.2. header arguments

set default arguments for source code blocks:

Buffer wide:

heading wide:

:PROPERTIES:
:header-args:python: :exports both
:END:
;; The example below sets ‘:noweb’ header arguments to ‘yes’,
;; which makes Org expand ‘:noweb’ references by default.
(setq org-babel-default-header-args
      (cons '(:noweb . "yes")
            (assq-delete-all :noweb org-babel-default-header-args)))
  • :eval never-export - prevent code blocks from being evaluated at export time:
  • :exports both - export code and result

sytem-wide

  • org-babel-default-header-args (for all languages)
  • org-babel-default-header-args:<lang> (language specific)

https://org-babel.readthedocs.io/en/latest/header-args/

36.13.3. commands

  • C-c ' Edit the source code
  • C-c C-v d create
  • C-c C-c execute
  • C-c C-v e execute
  • org-src-fontify-block code highlighting

templates:

  • <s Tab create
  • after #+ autocompletion

36.13.4. template

Название языка строчными!

Some example from a text file.
Some example from a text file.
data p_datum type datum. "15.01.2018
data p_molga type MOLGA value '33'.
p_datum = sy-datum.

36.13.5. python

return "aasd"
aasd
print("aasd")
aasd

36.13.6. output result

https://orgmode.org/manual/Results-of-Evaluation.html

  • :results output raw - do nothing with output
  1. example output json
    curl -X GET "http://anonchek.ru/get?id=a43219ce4a4a490d9cd34beb718cb09f" -H  "accept: application/json"
    

36.13.7. python sessions

#+BEGIN_SRC python :results output :session a
import numpy
import pandas as pd
v = pd.DataFrame({'as':[1,2], 'ssd':[3,2]})
print(v)
print(v.describe())

#+end_src

36.13.8. python images

The ‘mkdirp’ header argument creates parent directories for tangled files if the directory does not exist. A ‘yes’ value enables directory creation whereas ‘no’ inhibits it.

from matplotlib import pyplot as plt
x = [1, 2, 3]
y = [1, 4, 3]

plt.plot(x, y)
# plt.show()
plt.savefig('1.png')

36.13.9. python pandas tables

  1. original - not working with sessions
    import pandas as pd
    df = pd.DataFrame({
          "a": [1,2,3],
          "b": [4,5,6]
    })
    
    
      a b
    0 1 4
    1 2 5
    2 3 6
  2. with sessions
    import pandas as pd
    
    def pd2org(df_to_table):
        "can be used any blocks in same session"
        return tabulate(df_to_table, headers=df_to_table.columns, tablefmt='orgtbl')
    
    df = pd.DataFrame({
          "a": [1,2,3],
          "b": [4,5,6]
    })
    pd2org(df.describe())
    
      a b
    count 3 3
    mean 2 5
    std 1 1
    min 1 4
    25% 1.5 4.5
    50% 2 5
    75% 2.5 5.5
    max 3 6

36.13.10. shell sorce code blocks

for shell:

set -- "2\n22"
echo -e "$@"

this works like #include in C:

print('echo -e "$@"')

36.13.11. templates for source code (org-tempo)

  • (require 'org-tempo) for <s TAB is old system
  • C-c C-, s and it will wrap your selection inside #+begin_src and #+end_src.

(require 'org-tempo)

(add-to-list 'org-structure-template-alist '("sh" . "src shell")) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (add-to-list 'org-structure-template-alist '("py" . "src python"))

36.13.12. calling blocks

syntax:

#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>

inside header arguments - change header of block

end header arguments - affect the results returned by the code block.

  1. ex
    s asd2 s2

    s asd2 s2 s asd2 s2

    bla bla

    echo s $x s2
    
  2. ex with :var x=name
    a = 2
    
    print(a)
    
    2
    

36.13.13. evaluatlion

prevent evaluation:

:eval no
:eval never
#+PROPERTY: header-args :eval no

prevent evaluation if code not changed:

:cache yes

prevent evaluation if Org source blocks during export:

  • per block
#+begin_src <language> :eval never-export
  • per file
#+PROPERTY: header-args :eval never-export
  • global
(setq org-babel-default-header-args
      (cons '(:eval . "never-export")
            (assq-delete-all :eval org-babel-default-header-args)))

links

36.13.14. babel library

  • /usr/share/emacs/29.1/lisp/org/org.el
    • org-babel-do-load-languages - (require ob-'lang'.el
    • org-ctrl-c-ctrl-c
    • ob-core.el: org-babel-execute-src-block
      • org-babel-process-params
    • org-babel-execute:lang body params
    • ob-eval.el: org-babel-eval
  • /usr/share/emacs/29.1/lisp/org/ob-core.el
  1. default params for org-babel-execute:lang
    ((:colname-names)
     (:rowname-names)
     (:result-params "replace" "output")
     (:result-type . output)
     (:results . "replace output")
     (:exports . "code")
     (:session . "none")
     (:cache . "no")
     (:noweb . "no")
     (:hlines . "no")
     (:tangle . "no"))
    
  2. terms
    • Literate Programming - invented by Donald Knuth in 1980’s. Self-documented code file that generate 1) documentation 2) source code
      • weave, weaving - the documentation
      • tangle, tangling - the source code. (ex. Org-mode file is tangled and executed)
    • Functional Mode - ":results value" - the code block is a function with a return value. The return value of one code block can be used as input for another code block, even one in a different language.
    • Scripting Mode - ":results output" - stdout to result

36.13.15. org-babel-eval (command query)

ob-eval.el

org-babel–shell-command-on-region

process-file("/bin/bash" "/tmp/babel-r8qnrq/ob-input-NupvRT" (t "/tmp/babel-r8qnrq/ob-error-cNDFv1") nil "-c" "mypy")

call-process "/bin/bash" "/tmp/babel-r8qnrq/ob-input-ZiSUmz" (t "/tmp/emacsIHqeyU") nil ("-c" "mypy")

call-process "/bin/bash" "~/aaa" (t "/tmp/emacsIHqeyU") nil ("-c" "mypy")

(call-process "/bin/bash" "~/aaa" t nil "-c" "python")
(call-process "/bin/bash" "~/aaa" t nil "-c" "mypy")
(call-process "/bin/bash" "~/aaa" t nil "-c" "/usr/local/bin/mypy.sh")
print("wes")
Success: no issues found in 1 source file

36.13.16. indentation

(org-cycle) -> with babel python (org-cycle) -> indent-for-tab-command -> org-indent-line with record!

(execute-extended-command nil "indent-for-tab-command" nil)
  • org-babel-do-key-sequence-in-edit-buffer("\11")
  • org-babel-do-in-edit-buffer
  • org-edit-src-code, org-edit-src-exit , sequence:
    • (beg org-src–beg-marker)
    • (end org-src–end-marker)
    • (narrow-to-region beg end)
    • org-replace-buffer-contents = replace-buffer-contents (SOURCE &optional MAX-SECS MAX-COSTS))
  1. highlight-changes-mode - how it works:

    hilit-chg-set-face-on-change:

    • set hook for local buffer with depth nil
    (add-hook 'after-change-functions 'hilit-chg-set-face-on-change nil t))
    

    :(defun hilit-chg-set-face-on-change (beg end leng-before

         &optional no-property-change)
    
    • beg/end - beginning and end of the range of changed text,
    • leng-before - length in chars of the pre-change text replaced by that range.

36.14. completions

  • C-c C-, (org-insert-structure-template) - #+ ….

36.14.1. M-TAB completion

  • after '* '
  • After ‘\’, complete TeX symbols supported by the exporter.
  • After ‘:’ in a headline, complete tags
  • After ‘:’ and not in a headline, complete property keys
  • After ‘[[’, complete link abbreviations
  • After ‘[[*’, complete headlines in the current buffer
  • After ‘#+’, complete the special keywords
  • After #+STARTUP: keyword, complete startup items.
  • When point is anywhere else, complete dictionary words using Ispell. ???

36.14.2. disable org-tempo

works like [[skeletons]

36.15. LaTeX

https://orgmode.org/org.html#LaTeX-header-and-sectioning https://en.wikibooks.org/wiki/LaTeX/Internationalization для русского:

статья:

статья: [10pt,a4paper,twocolumn]{article} широко:

очень широко:

\begin{equation} x=\sqrt{b} \end{equation}

\[ a=+\sqrt{2} \] or \[ a=-\sqrt{2} \]

36.16. archiving

C-c C-x C-a archive subtree.

36.17. inline images

(setq org-startup-with-inline-images t) or:

[[org-level-hist.png]

36.18. Tables and Spreadsheets

  • C-c ? learn about field
  • |- start pattern
  • :=vmean($2..$3) calculate the mean for fields from the second ($2) to the third ($3) field in this row
  • C-c C-c calc table
  • #+TBLFM line contains all the formulas for the table above, and you should be careful while editing it manually.
  • C-u C-c * (or C-c C-c if you're on the #+TBLFM) reapplying all formulas
  • C-c = editing column formulas
  • C-u C-c = field formulas
  • C-c ' edit formulas more interactively in a dedicated buffer
  • S-arrows swap columns
  • C-c { Turn the formulas debugger on
n n^2
1  
2  

36.19. indent-mode

  • M-x org-indent-mode
  • (setq org-startup-indented t)

use '(org-hide-leading-stars t) inside

36.21. TODO Capture C-c c and templates, notes

36.22. columnar view

36.22.1. keys

  • C-c C-x C-c (org-columns)
  • r/g redo
  • C-c C-c or q quit
  • LEFT, RIGHT, UP, DOWN Move through the column view from field to field.
  • S-left/right cycle throught possible values
  • M-left/right move columns left/right
  • e edit-value
  • v show-value
  • a edit-allowed - possible values
  • C-c C-c (org-columns-toggle-or-columns-quit) When there is a checkbox at point, toggle it.
  • </> columns-widen
  • S-M-RIGHT org-columns-new

36.22.2. org-columns-default-format

"%25ITEM %TODO %3PRIORITY %TAGS" or #+COLUMNS %25ITEM %TODO %3PRIORITY %TAGS

36.22.3. format

%[WIDTH]PROPERTY[(TITLE)][{SUMMARY-TYPE}]

36.22.4. properties

  • ITEM The content of the headline.
  • TODO The TODO keyword of the entry.
  • TAGS The tags defined directly in the headline.
  • ALLTAGS All tags, including inherited ones.
  • PRIORITY The priority of the entry, a string with a single letter.
  • DEADLINE The deadline time string, without the angular brackets.
  • SCHEDULED The scheduling time stamp, without the angular brackets.

36.22.6. effort template

#+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
#+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort){:} %CLOCKSUM

36.22.7. org-clock-report or clocktable

36.23. priorities

36.23.1. custom priorities:

(setq
  org-lowest-priority  1
  org-highest-priority 10
  org-default-priority 5
  )

36.24. sort

36.25. TAGS

  • ! add timestemp without asking
  • @ ask whether to add timestamp or not
  • /! when switching back from it add timestamp to TODO word staying before
  • computer @phone - at most one of them should be selected

keys

  • C-c C-q (org-set-tags-command)
  • C-c C-c (org-set-tags-command)

36.26. .TODO

#-- org-todo-keyword-faces: (("TODO" . org-warning) ("FAILED" . "red") ("DONE" . "green")); --

-- org-todo-keyword-faces: (("TODO" . "red") ("WAIT" . "orange") ("DONE" . "green")); --

Colours for TODO:

(setq org-todo-keyword-faces
  '(("TODO" . org-warning)
     ("STARTED" . "red")
     ("WAITING" . "yellow")
     ;; ("CANCELED" . (:foreground "cyan" :weight bold))
     ("CANCELED" . "cyan")
     ))

https://orgmode.org/manual/Tracking-TODO-state-changes.html

36.27. export

  • C-c C-e # - inserts a template containing all the options:

Disabling underscore-to-subscript

  • #+OPTIONS: ^:nil
  • (setq org-export-with-sub-superscripts nil)

36.28. export to markdown

to activate:

  • M-x customize-variable <Ret> org-export-backends <Ret>
  • C-c C-e m m (org-md-export-to-markdown) Export to a text file with Markdown syntax
  • C-c C-e m M (org-md-export-as-markdown) Export to a temporary buffer. Does not create a file.
  • C-c C-e m o Export as a text file with Markdown syntax, then open it.
  • supported export formats: https://orgmode.org/worg/exporters/ox-overview.html
#!/bin/sh

for filename in $(find . -maxdepth 1 -type f \
                       -not -name '*.html' -not -name '.nojekyll' \
                       -not -name '*.md' -not -name '*.png' -not -name 'export.sh' \
                       -not -name '.*.sh'); do
    echo "put ${filename}";
    emacs "${filename}" --eval "(progn (org-md-export-to-markdown) (save-buffers-kill-emacs))"
done

36.29. presentation mode

  1. sudo apt install texlive-full
  2. Ctrl+C, Ctrl+E, #
  3. add lines at the end:
    • #+LaTeX_CLASS: beamer
    • #+LaTeX_CLASS_OPTIONS: [bigger]
  4. export your slide as a Beamer presentation(pdf):
    • Ctrl+C, Ctrle+E, Shift+O

will not be exported:

  • C-x ; - org-toggle-comment
  • any lines strted with #

37. Outline mode

Org mode was originally the author's extensions to Outline mode, and grew, and grew, and grew. Even today, org-mode is derived from outline-mode.

first line of file:

;-*- eval: (outline-minor-mode 1) ; outline-regexp: ";; \\-+" -*-

You can configure it to use a header format that's compatible with your program syntax, and many major modes do so, by setting the outline-regexp variable to a regexp that matches the start of a header. For example, this is the default value in Emacs Lisp mode:

";;;\\(;* [^ \t\n]\\|###autoload\\)\\|("

i.e. section headers start with three or more semicolons and a single space

https://emacs.stackexchange.com/questions/3143/can-i-use-org-mode-to-structure-my-emacs-or-other-el-configuration-file/3416#3416

38. Org agenda

provides a convenient way of tracking your projects and managing your calendar.

terms:

  • Agenda Dispatcher - view selector

38.1. keys

38.1.1. keys in org mode for TODO:

  • C-c '[' or ']' add/remove file to agenda list in .emacs '(org-agenda-files '("~/tasks.org"))
  • shift -> or C-c C-t - change status TODO DONE
  • C-c . insert timestamp
  • C-c > go to calendar
  • C-c C-d deadline - is supposed to be finished on that date.
  • C-c C-s schedule - you are planning to start working on that task on the given date.
    • +n or +1 add days
    • +mon/mon at next monday
    • +1w +7 days
    • n day
    • 2022-05-22
    • 05-22
  • C-c / sparse tree - filter
  • M-x org-agenda
  • M-x org-sort-entries - ????????
  • M-x org-cyle-agenda-files - open files
  • C-c C-x C-s (org-archive-subtree)
  • C-c C-t togle TODO (S-arrow)
  • C-c C-x e (org-set-effort) (e in agenda)
  • C-c C-x C-e (org-clock-modify-effort-estimate)

38.1.2. in agenda:

  • f/b/j navigation
  • D toggle diary
  • d/w/l day/week/log view
  • i insert diary
  • SPC/TAB/RET go to todo line in agenda file (diary open buffer required)
  • t Change the TODO state of the item everywhere
  • C-k kill entry
  • $ archive to ~/<original_file>_archive
  • c calendar
  • r/g recreate
  • o Delete other windows.
  • notes ~/.notes

38.2. time format

  • date: <YYYY-MM-DD DAY>
  • timestamp: <YYYY-MM-DD DAY HH:MM>
    • 2022-08-02 Tue 12:05
  • time range: <YYYY-MM-DD DAY HH:MM-HH:MM>
  • <2005-10-01 Sat +1w> - every Wednesday
  • <2005-10-01 Sat +1m -3d> - repeater and a special warning period
  • <%%(diary-float t 4 2)> Diary-style sexp entries
  • <2004-08-23 Mon>–<2004-08-26 Thu> - Time/Date range
  • [2004-08-23 Mon] - inactive timestamp
  • DEADLINE: <2008-02-10 Sun ++1w> - Marking this DONE shifts the date by at least one week, but also by as many weeks as it takes to get this date into the future.
  • DEADLINE: <2005-11-01 Tue .+1m> - Marking this DONE will shift the date to one month after today.

38.3. date, timestamp and timer

  • C-c < org-date-from-calendar insert current <>
  • C-c . org-time-stamp select date <>
  • C-c ! org-time-stamp-inactive select date []
  • C-c C-c fix timestamp

timer:

  • C-c C-x , org-timer-pause-or-continue
  • C-c C-x - org-timer-item
  • C-c C-x . org-timer Insert current timer value after start
  • C-c C-x 0 org-timer-start Start or reset the relative timer.
  • C-c C-x ; org-timer-set-timer how much timer set? when time left it try to use dbus
  • C-c C-x _ org-timer-stop
  • C-c C-y org-evaluate-time-range

https://orgmode.org/manual/Timers.html

38.4. parser perl

$cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"a\"  org-agenda-span (quote day) org-agenda-include-diary t diary-file \"/home/u/.emacs.d/diary\")'
2>/dev/null";

# run it and capture the output
$agenda = qx{$cmd 2>/dev/null};

# loop over all lines
foreach $line (split(/\n/,$agenda)) {
    # get the individual values
    ($category,$head,$type,$todo,$tags,$date,$time,$extra,
     $priority_l,$priority_n) = split(/,/,$line);
    # process and print
    print "[ ] $category,$head,$type,$todo,$tags,$date,$time,$extra,
     $priority_l,$priority_n \n";
}

38.5. parser python

import os
cmd="emacs -batch -l ~/.emacs -eval '(org-batch-agenda \"a\"  org-agenda-span (quote day) org-agenda-include-diary t diary-file \"/home/u/.emacs.d/diary\")' 2>/dev/null"
cmd = cmd.split(' ')
# run it and capture the output
import subprocess
child = subprocess.Popen(['cat', 'task.org'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

agenda = os.system(cmd + " 2>/dev/null")


# loop over all lines
foreach $line (split(/\n/,$agenda)) {
    # get the individual values
    ($category,$head,$type,$todo,$tags,$date,$time,$extra,
     $priority_l,$priority_n) = split(/,/,$line);
    # process and print
    print "[ ] $category,$head,$type,$todo,$tags,$date,$time,$extra,
     $priority_l,$priority_n \n";
}


with open('university_records.csv', 'r') as csv_file:
    reader = csv.reader(csv_file)

    for row in reader:
        print(row)

38.6. config

(global-set-key (kbd "C-c a") 'org-agenda)
(global-set-key "\C-ca" 'org-agenda)
;; open agenda every time at start
(org-agenda nil "a")
;; Use a one day agenda view (rather than a seven day view).
(setq org-agenda-ndays 1)
;;(setq diary-mail-addr "geekard@qq.com")
;; Times of Sunrise and Sunset
;; https://www.latlong.net/
(setq calendar-latitude 50.596722)
(setq calendar-longitude 36.587780)
(setq calendar-location-name "Belgorod")
(setq calendar-time-zone -360)
(setq calendar-standard-time-zone-name "CST")
(setq calendar-daylight-time-zone-name "CDT")


(setq mark-diary-entries-in-calendar t)
(setq org-agenda-include-diary t)
;; disable holidays
(diary-show-holidays-flag nil)
(setq christian-holidays nil
      hebrew-holidays nil
      islamic-holidays nil
      solar-holidays nil
      bahai-holidays nil)
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)
(autoload 'chinese-year "cal-china" "Chinese year data" t) -?????
# Monday is the first day of the week
(setq calendar-week-start-day 1)

38.7. TODO russian holidays

38.8. example

#+PRIORITIES: 1 4 1
#+TODO: TODO(t!) STRD(t!/!) WAIT(w) | DONE(d!) CNLD(c@)
#+TAGS: airflow(i) superset(s) pipeline(p) Анатолий(a) Александр(l) Марат(m)
# C-c C-c - set tag
# C-c C-s - schedule
:* my work
:** TODO add pipeline to airflow                     :airflow:pipeleine:
- State "STRD"       from "WAIT"       [2022-06-06 Mon 10:34]
- State "WAIT"       from "STRD"       [2022-06-06 Mon 10:34]
- State "STRD"       from "TODO"       [2022-06-06 Mon 10:34]
- State "TODO"       from              [2022-06-06 Mon 10:34]
- State "STARTED"    from "TODO"       [2022-06-06 Mon 10:32]
- State "TODO"       from              [2022-06-06 Mon 10:32]

39. appt - reminder for diary

39.1. appt reminder

  • M-x appt-activate
  • M-x appt-add add reminder without diary and todo files
  • appt-check - internal func which checks diary and decide show message or not

39.2. appt default config

  • start time = appt-message-warning-time or "warntime" in diary
  • interval = appt-display-interval
;; -- time
;; appt-display-message interval - minutes
(setq appt-display-interval 3)
;; before an appointment that the warning begins - minutes
;; can be overriden in diary with "wanrntime 30" - minutes
(setq appt-message-warning-time 12)
;; display window appointment text after time record duration - seconds
(setq appt-display-duration 10
;; enable audio
(setq appt-audible nil)
;; emacs print diary , I guess controlled by appt-display-interval
(setq appt-display-diary t)
;; echo, nil
(setq appt-display-format 'window)

39.3. my reminder:

;; ---- my X notification system---
;; notify-send in by first emacs process
(setq appt-disp-window-function
  (lambda (min-to-app timenow msg)
    ;; get emacs pids as "123 123 123"
    (set 'v (shell-command-to-string "pidof emacs"))

    ;; largest of "1 2 3" as number
    (setq val (car ;; get ferst element of a list
                (last
                  (sort (mapcar  'string-to-number (split-string v)) #'>))
                )
      )
    ;; do if emacs-pid == val, 5000=5sec
    (if (eq (emacs-pid) val)
      (shell-command (format "notify-send --expire-time 15000 -i emacs '%s'" msg)
        ) )
    ) )

;; update diary from for appt with timeout
(defun oo () (appt-check t))
(run-with-timer 120 120 'oo)
;; --<< my X notification system

39.3.1. reminder

sudo -u u DISPLAY=:0 notify-send –expire-time 3000 -i emacs "hay"

emacs -batch -l ~/.emacs -eval '(org-batch-agenda "a" org-agenda-include-diary t diary-file "/home/u/.emacs.d/diary")'

2>/dev/null

appt:

  • (setq appt-disp-window-function (function psachin/appt-display))

https://orgmode.org/manual/Extracting-Agenda-Information.html

appt-disp-window-function https://psachin.gitlab.io/emacs_diary_desktop_notification.html

39.4. config reminder server-clients

;; notification
(setq appt-disp-window-function
      (lambda (min-to-app timenow msg)(
                                        shell-command (format "notify-send --expire-time 5000 -i emacs '%s'" msg)
                                                      )
        )
)
;; activate notification
(appt-activate t)

40. calendar mode and diary

  • M-x calendar

40.1. calendar keys

navigation

  • C-a/e - begin/end of week
  • C-b/f - day
  • C-n/p - next/previous week
  • . today
  • g d go to date
  • o go to month

mark

  • m/u mark/unmark

diary .emacs.d/diary

  • s show all entries
  • i d insert entry
  • i b insert block
  • i c insert cycle
  • i m/w/y insert monthly/weekly/yearly
  • D other diary file

other

  • M-= calendar-count-days-region
  • M-x appt-activate reminder

40.2. diary

40.2.1. file

record:

  • 2011/06/01 12:00 Do something ## warntime 30
  • 02/23/89 note for day
  • \t12:00 message
  • \tpart_of_message
  • \tpart_of_message

here:

  • 2011/06/01 - day record
  • 12:00 - start of time record
  • ## - meanth nothing
  • warntime 30 - warn before 30 minutes when using appt
    • warntime - regex expression in appt-warning-time-regexp in appt
  • big day - note for day, not passed anywhere

other record ex.:

  • 12/22/2015 Twentieth wedding anniversary!
  • 10/22 Ruth's birthday.
  • * 21, *: Payday
  • Tuesday–weekly meeting with grad students at 10am
    • Supowit, Shen, Bitner, and Kapoor to attend.
  • 1/13/89 Friday the thirteenth!! - month/day/year
  • thu 4pm squash game with Lloyd.
  • mar 16 Dad's birthday
  • April 15, 2016 Income tax due.
  • * 15 time cards due.
  • Thursday 11:45am Lunch meeting.

41. hidepw-mode - minor mode

allow to hide passwords.

activation: ; -- mode: Org ; eval: (hidepw-mode 1) --

41.1. how it works

it sets up `font-lock-add-keywords'

41.2. my modification for compatibility with org-mode:

(setq hidepw-patterns '("\\(password\\|pass\\): \\(.+\\)$"))

(advice-add 'hidepw-font-lock-keywords :override
  (lambda ()
    (mapcar (lambda (pat) `(,pat 2 (hidepw-render)))
          `(,@hidepw-patterns ,@(when hidepw-hide-first-line '("\\`\\(.*\\)$"))))
    )
  )

42. ob-http - REST client

42.1. options

option curl example

  • :proxy -x :proxy localhost:8118
  • :noproxy –noproxy * N/A
  • :cookie-jar –cookie-jar :cookie-jar username
  • :cookie –cookie :cookie username
  • :max-time –max-time default is 10
  • :user –user :user admin:passwd
  • :pretty N/A :pretty use Content-Type, to overwrite :pretty json
  • :select N/A :select path path will be passed to jq for json or pup for html or xmlstarlet for xml
  • :get-header N/A :get-header X-Subject-Token
  • :curl N/A :curl –insecure –compressed additional arguments for curl
  • :resolve –resolve :resolve example.com:80:127.0.0.1,example.com:443:127.0.0.1

42.2. examples

42.2.1. http source block

GET https://api.github.com/repos/zweifisch/ob-http/languages
Accept: application/vnd.github.moondragon+json

42.2.2. json source block

#+BEGIN_SRC http :pretty
POST http://httpbin.org/post
Content-Type: application/json

{
  "key": "value"
}

#+end_src

42.2.3. form submit

PATCH http://httpbin.org/patch

key=value&foo=value

42.2.4. varibale

POST http://httpbin.org/post
Content-Type: application/json

{
    "auth": {
        "name": "${name}",
        "password": "${password}"
    }
}

42.2.5. properties

POST /post
Content-Type: application/json
X-Auth-Token: ${token}

42.3. require

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (http . t)))

43. Magit

You see: 1) HEAD commit info 2) Recent commits.

  • C-x g - main screen
  • ? - keys help
  • q - change buffer
  • TAB -
  • C-m/RET
  • e - ediff, Alt+Tab z - to exit

43.1. conflict resolution:

  1. select file listed in the "Unstaged changes" and/or "Staged changes" sections. They are prefixed with the word "unmerged", which in this context essentially is a synonym for "unresolved".
  2. smerge-mode -
    • C-c ^ C-h for keys
    • C-c ^ n smerge-next
    • C-c ^ m choose head
    • C-c ^ o keep the version that follows "|||||||"
    • C-c ^ n smerge-next - to move to the next conflicting area in the same file.
    • C-c ^ p smerge-prev
    • C-c ^ RET smerge-keep-current
    • C-c ^ l smerge-keep-lower
    • C-c ^ m smerge-keep-upper
    • C-c ^ a smerge-keep-all

To resolve conflicts in a file using Ediff press e while point is on such a file in the status buffer.

44. cua-mode

  • C-x, C-c, C-v, and C-z - copy, undo
  • C-x C-c still work
  • activates Delete-Selection mode (to disable cua-delete-selection to nil):
    • when there is active region (see 1) - any key will erase region
  • CUA mode provides enhanced rectangle support
    • C-RET to start a rectangle (shadow C-c RET org-ctrl-c-ret)
  • it adds ability to save to copy and yank to registers.
    • C-1 C-c copies the region into register 1
    • C-2 C-v yanks the contents of register 2
  • C-S-SPC global mark feature - all text inserted at the global mark

If you really need to perform a command which starts with one of the prefix keys even when the region is active, you have three options:

  • press the prefix key twice very quickly (within 0.2 seconds),
  • press the prefix key and the following key within 0.2 seconds, or
  • use the SHIFT key with the prefix key, i.e. C-S-x or C-S-c.

45. Bookmarks mode

  • M-x list-bookmarks (C-x r l) – list your bookmarks
  • M-x bookmark-set or bookmark-set-no-overwrite (C-x r m) - bookmark a folder/file and a cursor postion
  • M-x bookmark-jump (C-x r b) - jump to a bookmark - you should bookmarked at least one file to go to that file
  • M-x bookmark-save - save to file ~/.emacs.d/bookmarks

bookmark-save

46. grip-mode

require grip command

pip grip install

  • grip==4.6.1 –hash=sha256:a5e6ac48cd253892f0fbd0aaef3f74fe8169d8ed3d94a2e9be6bf1540e008e9f
  • path-and-address==2.0.1 –hash=sha256:e96363d982b3a2de8531f4cd5f086b51d0248b58527227d43cf5014d045371b7

46.1. reqs

Requirement already satisfied: Flask>=0.10.1 in ./.local/lib/python3.8/site-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (1.1.4) Requirement already satisfied: Markdown>=2.5.1 in ./.local/lib/python3.8/site-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (3.3.4) Requirement already satisfied: Pygments>=1.6 in ./.local/lib/python3.8/site-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (2.8.1) Requirement already satisfied: Werkzeug>=0.7 in ./.local/lib/python3.8/site-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (1.0.1) Requirement already satisfied: docopt>=0.4.0 in usr/lib/python3/dist-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (0.6.2) Requirement already satisfied: requests>=2.4.1 in ..local/lib/python3.8/site-packages (from grip==4.6.1->-r req_grip.txt (line 1)) (2.25.1) Requirement already satisfied: Jinja2<3.0,>=2.10.1 in ./.local/lib/python3.8/site-packages (from Flask>=0.10.1->grip==4.6.1->-r req_grip.txt (line 1)) (2.11.3) Requirement already satisfied: click<8.0,>=5.1 in ./.local/lib/python3.8/site-packages (from Flask>=0.10.1->grip==4.6.1->-r req_grip.txt (line 1)) (7.1.2) Requirement already satisfied: itsdangerous<2.0,>=0.24 in ./.local/lib/python3.8/site-packages (from Flask>=0.10.1->grip==4.6.1->-r req_grip.txt (line 1)) (1.1.0) Requirement already satisfied: idna<3,>=2.5 in ./.local/lib/python3.8/site-packages (from requests>=2.4.1->grip==4.6.1->-r req_grip.txt (line 1)) (2.10) Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.local/lib/python3.8/site-packages (from requests>=2.4.1->grip==4.6.1->-r req_grip.txt (line 1)) (1.25.11) Requirement already satisfied: chardet<5,>=3.0.2 in usr/lib/python3/dist-packages (from requests>=2.4.1->grip==4.6.1->-r req_grip.txt (line 1)) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in ..local/lib/python3.8/site-packages (from requests>=2.4.1->grip==4.6.1->-r req_grip.txt (line 1)) (2020.12.5) Requirement already satisfied: MarkupSafe>=0.23 in ./.local/lib/python3.8/site-packages (from Jinja2<3.0,>=2.10.1->Flask>=0.10.1->grip==4.6.1->-r req_grip.txt (line 1)) (1.1.1)

47. image-mode

(setq auto-mode-alist
          (append auto-mode-alist
                  '(("\\.jpg\\'" . image-mode)
                    ("\\.png\\'" . image-mode)
                    ("\\.gif\\'" . image-mode))))

48. artistic mode (draw mode)

48.1. base

ditta to convert to image from org src blocks

  • C-c C-c artist-mode-off Exit artist mode.
  • C-c C-r draw rectangle
  • M-x describe-mode - to get help for artistic mode

narrowing is usefull:

  • C-x n e # narrow to an element
  • C-x n w # widen back to the whole page

steps:

  1. narrow to
    • C-x n b org-narrow-to-block
    • C-x n e org-narrow-to-element
    • C-x n s org-narrow-to-subtree
  2. select type of line: M-x artistic-select-op-line
  3. type RET(enter) to start or select direction of line
  4. type RET(enter) to finish or chararter to insert in direction
  5. C-u RET to stop drawing
  6. < or > to toggle arrows for last line
  7. C-x n w widen

useful:

  • artist-select-op-poly-line (C-c C-a p) - several peaces line
  • artist-select-op-straight-poly-line (C-c C-a P) - more beautiful several peaces line
  • artist-select-op-rectangle (C-c C-a r)
  • artist-select-op-ellipse (C-c C-a e)
                     C-c `
                      \   C-c ^ C-c '
                       \   |    /
                        \  |   /
                         \ |  /
                          \| /
           C-c < ----------/-------------C-c >
                          /|\
                         / | \
                        /  |  \
                       /   |   \
                      /    |    C-c \
                     /   C-c .
                 C-c /

48.2. draw shapes

  • C-c C-a f artist-select-op-flood-fill Select flood fill as the operation.
  • C-c C-a C-k artist-select-op-cut-rectangle Draw a rectangle around an area, then cut.
  • C-c C-a M-w artist-select-op-copy-rectangle Draw a rectangle around an area, then copy.
  • C-c C-a C-y artist-select-op-paste Paste what you copied wherever you click the mouse.
  • C-c C-a v artist-select-op-vaporize-line Erase a line you select (literal line; not a line in the file).
  • C-c C-a C-d artist-select-op-erase-char Set operation to erase (use the mouse as your eraser).
  • C-c C-a S artist-select-op-spray-can Set operation to spray can.
  • C-c C-a e artist-select-op-ellipse Draw ellipses.
  • C-c C-a p artist-select-op-poly-line Draws poly-lines
  • C-c C-a r artist-select-op-rectangle Draw rectangles.
  • C-c C-a l artist-select-op-line Draw lines.
  • C-c C-a C-r artist-toggle-rubber-banding If on (the default), show shape while stretching; if not, mark end-points.
  • C-c C-a C-l artist-select-line-char Select character to use when drawing lines (- is the default).
  • C-c C-a C-f artist-select-fill-char Select character to fill shapes with (Space is the default).

48.3. todo

  • create testing function that open new buffer and write lines
  • replace - with _ in artist-select-op-line

49. templating and expanding

Emacs already had two builtin templating modules: Skeleton and Tempo.

Tempo looked simpler

49.1. Tempo

  • Strings are inserted in the buffer.
  • The n symbol causes the insertion of a new line character
  • The > symbol tells Emacs to indent the current line according to the rules of the major mode of the buffer.
  • The p forms cause Tempo to ask the user for values to insert. Note that you need to set tempo-interative to t.

https://www.n16f.net/blog/templating-in-emacs-with-tempo/

49.2. skeleton and abbrev

Skeletons are feature, where various atoms directly perform either actions on the current buffer or rudimentary flow control mechanisms.

two ways:

  • use a key binding for every skeleton command
  • define an abbreviation that will expand into the skeleton (abbrev-mode must be activated)

steps:

  1. define skeleton - (difine-skeleton ) lisp atom
  2. define abbreviation
  3. activate abbreviation (idk why but they work with disabled mode)
  4. type abbreviation and expand it with key C-x '

Yasnippet - another third-party library for templates

may be saved to ~/.emacs.d/abbrev_defs

Abbrevs expansion only works for last word unles you set mark with M-'. So you should insert space before abbrev.

49.2.1. abbrev-mode

  • M-x list-abbrevs - saves to .emacs.d/abbrev_defs - good for testing
  1. links

49.2.2. key binded skeleton example

(define-skeleton hello-world-skeleton
  "Write a greeting"
  "Type name of user: "
  "hello, " str "!")

(global-set-key "\C-cl" 'hello-world-skeleton)
;; Instead of strings you can use Lisp expressions, whose return values will be used in the text.

49.2.3. abbrev skeletons

(define-abbrev fortran-mode-abbrev-table ";ife"
  "" fortran-skeleton-if-else-endif)

(define-skeleton fortran-skeleton-if-else-endif
  "Insert an if - else - end if region" nil
  > "if (" _ ") then" \n
  -3 "else" \n
  -3 "end if")

(setq skeleton-end-hook nil)

49.2.4. org-tempo replacement

  (define-skeleton example
    "Write a greetings exaple"
    ""
    "greetings!"
    )
  (define-skeleton org-tempo-src
    "org-tempo replacement"
    ""
    "#+begin_src"
    "\n\n"
    "#+end_src"
    )
  ;; skeleton
  (define-abbrev-table 'org-mode-abbrev-table
     '(
        ("greetings" "" example :count 1)
        ("1s" "" org-tempo-src :count 1)
        )
    )

49.2.5. company

company - text completion framework.

Sequence of applying abbreviations defined by company-backends from company-safe-backends

(setq company-backends
      '((company-files
         company-keywords
         company-capf
         company-yasnippet
        )
        (company-abbrev company-dabbrev)))

49.3. HippieExpand hippie-exp.el

Dynamic Abbrev – zero relation to Abbrevs.

Hippie Expand - looks at the word before point and tries expand-abbrev, dabbrev-expand or fixed list.

C-h v hippie-expand-try-functions-list

50. CSV

csv-mode: require install!

  • M-x csv-align-mode or M-x csv-align-filds
  • M-x csv-sort-fields
  • csv-separators, default: ("," " ")
  • keys: Tab, S-Tab - navigation by columns

useful:

  • M-x toggle-truncate-lines

native: Simple Emacs Spreadsheet ses-mode - uses .ses format. Require programming.

  • can input any tab-delimited data.

51. TODO DoomEmacs

52. TODO Spacemacs

extension of a popular text editor called Emacs

  • These projects bring approachability and integration to Emacs, and are in my view, along with LSP, Magit, and Org, the

biggest reasons drawing people to Emacs nowadays.

  • It is however clear from looking at their issue trackers just how difficult it is to provide this cohesive experience by combining parts from the ecosystem.

53. Rust Emacs

Remacs
DEAD https://github.com/remacs/remacs
(no term)
Emacs-ng A new approach to Emacs - Including TypeScript, Threading, Async I/O, and WebRender. https://github.com/emacs-ng/emacs-ng

54. 4coder

  • loosely based on Emacs

Data oriented programming

55. neovim

https://www.murilopereira.com/the-values-of-emacs-the-neovim-revolution-and-the-vscode-gorilla/ Apache License Version 2.0

  • testing, CI, agressive refactoring, reduce contributor friction
  • decouple code from UI, make possible to embed vim core into browsers or IDE
  • embedding a Lua runtime and providing concurrency primitives for plugins
  • bringing C code to modern standarts, libuv for IO code, automatic formatting
  • create scriptable terminal emulator
  • non-mailing list driven development, automation builds, public roadmap, recurrent funding, frequent stable, automated releases
  • Separate UI with API

ideas:

  • approachability -
  • editing efficiency
  • keyboard centrism - focus on keyboard interactions
  • Progressivenes - a measure of eagerness to make progress and leaverage modern technology
  • text centrism - text as universal interface
  • Velocity - short and focused release cycles, aligned personpower, leveraging the community effectively

56. VSCode

  • Approachability - mainly
  • Integration - Cohesive core and concerted third-party functionality
  • Maintainability
  • Progressiveness
  • Velocity

cons

  • It is somewhat extensible and very configurable
  • It can be mostly driven from a keyboard
  • It has a great extension language, TypeScript (which is in my opinion superior to Emacs Lisp in terms of maintainability for non-trivial projects)
  • It even has a libre variant

    It also shines in areas where Emacs doesn’t: if you’re a programmer working on typical contemporary projects, mostly just wanting to get stuff done, things usually… just work. You install VSCode, open a source code file, get asked to install the extension for that particular language, and that’s it.

57. .emacs

file in window title

  • file_name, mode, path (setq-default frame-title-format '("%b [%m] %f"))

window width

  • (setq initial-frame-alist '( (width . 125)))

backups dir

  • (setq backup-directory-alist '(("." . "~/.MyEmacsBackups")))

fill column

  • (setq-default fill-column 110)

default mode

  • (setq-default major-mode (quote org-mode))

org-mode

  • (setq-default org-src-fontify-natively t)

russian with Ctrl+\

  • (setq-default default-input-method "russian-computer")

math-symbols input activate

  • (global-xah-math-input-mode 1)

dired fast copy

  • (setq dired-dwim-target t)

58. email

58.1. links and overview

offlineimap deps:

notmuch - indexer and also emacs-based interfece to notmuch indexer

fetchmail, offlineimap, or mbsync, to receive the messages

58.2. isync + notmuch + emacs steps

  1. emerge net-mail/isync
  2. USE="emacs doc" emerge net-mail/notmuchk
  3. useradd -m email
  4. /etc/sudoers.d/email see 58.2
  5. chown email:current_user /home/email
  6. chmod g+rwxs /home/email see ref::sudoers.d/email
  7. configure isync .mbsyncrc. see nix#MissingReference
  8. # mkdir -P home/email.mail/yourmaildir
  9. # chown -R email:user home/email.mail
  10. # find home/email.mail/ -type d -exec chmod -R g+rxs {} \;
  11. # find home/email.mail/ -type f -exec chmod g+rw {} \;
  12. mbsync gmail or mbsync -aV
  13. notmuch setup # create home/email.notmuch-config
  14. notmuch new # create a database that indexes all of your mail
  15. cp home/email.notmuch-config home/user
  16. M-x package-install smtpmail-multi
  17. configure smtpmail-multi in .emacs, create "~/.authinfo" or "~/.authinfo.gpg" or "~/.netrc"
  18. $ emacs ; M-x notmuch
  19. email retriving: # mbsync -aV && notmuch new && notmuch tag –input=my.notmuch && find .mail/ -type f -exec chmod g+rw {} \;

download new emails:

  • proxychains mbsync -aV ; notmuch new ; notmuch tag –input=my.notmuch
  • find home/email.mail/ -type f -exec chmod g+rw {} \;
#!/bin/sh
# sudo -u email
# proxychains mbsync -aV
cd /home/email/
echo sudo -u email mbsync -c /home/email/.mbsyncrc -aV
sudo -u email mbsync -c /home/email/.mbsyncrc -aV
echo #--------------------------------------------------------
echo sudo /usr/local/bin/email_notmuch_perm.sh
sudo /usr/local/bin/email_notmuch_perm.sh
echo sudo -u email notmuch new
sudo -u email notmuch new
echo #--------------------------------------------------------
echo sudo -u email notmuch tag --input=/home/email/my.notmuch
sudo -u email notmuch tag --input=/home/email/my.notmuch
echo #--------------------------------------------------------
# . prev.sh # root required
+saved -- folder:SAVED
+sent -- folder:Sent
+spam -- folder:Spam
+bks -- folder:bks
+book -- folder:book
+pol -- folder:pol
# bks move from inbox to bks
+bks -inbox -- 'from:"/.*@bcs[.]ru/"'
# remove spam,draft,deleted,sent from inbox
-inbox -- tag:spam or tag:draft or tag:deleted or tag:sent
# remove spam,draft,deleted,sent from unread
-unread -- tag:spam or tag:draft or tag:deleted or tag:sent
#!/bin/sh
chown -R email:u /home/email/.mail
find /home/email/.mail/ -type d -exec chmod g+rxs {} \;
# not working if group is not owned
find /home/email/.mail/ -type f -exec chmod g+rw {} \; # root required

u ALL=(email) NOPASSWD: ALL
email ALL=(root) NOPASSWD: /usr/local/bin/email_notmuch_perm.sh
u ALL=(root) NOPASSWD: /usr/local/bin/email_notmuch_perm.sh

58.3. notmuch

58.3.1. keys:

  • q or x quit
  • C-m activate
  • tab/S-tab move to next/previous button
  • g or = or G update
  • s search
  • C-M-s regex search
  • z tree search
  • +,- Add or remove arbitrary tags from the current message.
  • k tagging menu
  • a/p next message

in message:

  • V raw message
  • r reply to the sender
  • R reply to the sender and all recipients of the current message.
  • f forward
  • Z show tree of messages
  • C-x C-s save as draft
  • C-c C-s send
  • C-c C-a attach file
  • n/p next/preview message in thread
  • M-n/p next/preview thread
  • . o open email in browser

in draft:

  • e notmuch-show-resume-message

58.3.2. block :

notmuch tag -inbox -unread +deleted -- tag:inbox and "from:/.*@.*[.]pinterest[.]com/"

58.3.3. delete

One choice is to maintain a tag of emails you wish to remove from your disk, for example, "killed". Then, you can combine the search for the tags with xargs to delete them permanently:

notmuch search --output=files --format=text0 tag:killed | xargs -r0 rm
notmuch search --output=files tag:deleted | tr '\n' '\0' | xargs -0 -L 1 rm  # if path has spaces
notmuch new

58.3.4. headers

not all headers are cached

  1. get all deaders from commandline
    notmuch show --body=false --entire-thread=false as
    cat filename
    
  2. get all headers from emacs

    keys c F notmuch-show-stash-filename

  3. to add headers:
    1. notmuch config set index.header.XSpamFlag X-Spam-Flag
    2. notmuch reindex '*'
    3. notmuch search AcceptLanguage:en-US AND XSpamFlag:NO

58.3.5. parts

  • notmuch-hello - M-x notmuch or M-x notmuch-hello
    • saved searches
    • Search Box
    • Known Tags
  • notmuch-show
  • notmuch-tree
  • notmuch-search

58.3.6. recreate

  • $ mv ~/.mail/.notmuch ~/.notmuch.bak
  • $ notmuch new
  • # chown -R email:user home/email.mail
  • # find .mail/ -type d -exec chmod -R g+rxs {} \;
  • # find .mail/ -type f -exec chmod g+rw {} \;

58.3.7. external viewer

  • . v notmuch-show-view-part

~/.mailcap:

text/html; . /home/u/fireflocal.sh %s; nametemplate=%s.html

https://emacs.stackexchange.com/questions/63436/is-there-some-way-to-view-the-html-part-of-an-email-in-an-external-browser-or-as

58.3.8. message display execution path

  • notmuch-show: notmuch-show-insert-part-/
  • notmuch-lib.el:
    • notmuch-mm-display-part-inline
    • notmuch-show
    • notmuch-show–build-buffer
    • notmuch-show-insert-forest
    • notmuch-show-insert-thread
    • notmuch-show-insert-tree
    • notmuch-show-insert-msg
    • notmuch-show-insert-body
    • notmuch-show-insert-bodypart
    • notmuch-show-insert-bodypart-internal
    • notmuch-show-handlers-for: notmuch-show-insert-part-text/html
    • notmuch-show-insert-part-/
    • notmuch-mm-display-part-inline
  • mm-decode.el:
    • mm-display-part
    • mm-display-inline
  • mm-view.el
    • mm-inline-text-html
    • mm-text-html-renderer
  • gnus-html.el
    • gnus-w3m . gnus-article-html
    • gnus-html-wash-tags
    • gnus-article-add-button

58.3.9. config exampls

  1. https://bostonenginerd.com/posts/notmuch-of-a-mail-setup-part-2-notmuch-and-emacs/
    ;Load up Notmuch
    (require 'notmuch)
    
    
    ; Setup some keybindings
    
    
    ; C-c m opens up Notmuch from any buffer
    (global-set-key (kbd "C-c m") `notmuch)
    
    ;Setup Names and Directories
    (setq user-mail-address "myemail@mydomain.tld"
      user-full-name "My Totally Real Name")
    
    ; stores postponed messages to the specified directory
    (setq message-directory "MailLocation/Drafts") ;
    
    ;set sent mail directory
    (setq notmuch-fcc-dirs "MailLocation/Sent")
    
    ;Settings for main screen
    (setq notmuch-hello-hide-tags (quote ("killed")))
    
    ;A few commonly used saved searches.
    (setq notmuch-saved-searches
    (quote
    ((:name "inbox" :query "tag:inbox AND -tag:work" :key "i" :sort-order oldest-first)
     (:name "flagged" :query "tag:flagged" :key "f") ;flagged messages
     (:name "sent" :query "tag:sent -tag:work" :key "t" :sort-order newest-first)
     (:name "drafts" :query "tag:draft" :key "d")
     (:name "mailinglist" :query "tag:lists/mailinglistID" :key "c")
     (:name "all mail" :query "*" :key "a" :sort-order newest-first))))
    
    
    ;Message composition and sending settings
    
    ;Setup User-Agent header
    (setq mail-user-agent 'message-user-agent)
    
    (setq message-kill-buffer-on-exit t) ; kill buffer after sending mail)
    (setq mail-specify-envelope-from t) ; Settings to work with msmtp
    
    (setq send-mail-function (quote sendmail-send-it))
    (setq sendmail-program "~/.local/bin/msmtp-enqueue.sh"
      mail-specify-envelope-from t
    ;; needed for debians message.el cf. README.Debian.gz
     message-sendmail-f-is-evil nil
      mail-envelope-from 'header
      message-sendmail-envelope-from 'header)
    
    ;Reading mail settings:
    
    (define-key notmuch-show-mode-map "S"
        (lambda ()
        "mark message as spam"
        (interactive)
    (notmuch-show-tag (list "+spam" "-inbox"))))
    
    (define-key notmuch-search-mode-map "S"
    (lambda ()
        "mark message as spam"
        (interactive)
        (notmuch-search-tag (list "-inbox" "+spam"))
        (next-line) ))
    
    (setq notmuch-crypto-process-mime t) ; Automatically check signatures
    
    
    ;Crypto Settings
    (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
    
    (setq epg-gpg-program "/usr/bin/gpg2")
    
    ;There was some problem with listing PGP keys in the Debian
    ;version of EPG. This magic from StackOverflow seems to resolve it.
    (defun epg--list-keys-1 (context name mode)
    (let ((args (append (if (epg-context-home-directory context)
              (list "--homedir"
                (epg-context-home-directory context)))
              '("--with-colons" "--no-greeting" "--batch"
            "--with-fingerprint" "--with-fingerprint")
              (unless (eq (epg-context-protocol context) 'CMS)
            '("--fixed-list-mode"))))
    (list-keys-option (if (memq mode '(t secret))
                  "--list-secret-keys"
                (if (memq mode '(nil public))
                "--list-keys"
                  "--list-sigs")))
    (coding-system-for-read 'binary)
    keys string field index)
    (if name
    (progn
      (unless (listp name)
        (setq name (list name)))
      (while name
        (setq args (append args (list list-keys-option (car name)))
          name (cdr name))))
      (setq args (append args (list list-keys-option))))
    (with-temp-buffer
      (apply #'call-process
         (epg-context-program context)
         nil (list t nil) nil args)
      (goto-char (point-min))
      (while (re-search-forward "^[a-z][a-z][a-z]:.*" nil t)
    (setq keys (cons (make-vector 15 nil) keys)
          string (match-string 0)
          index 0
          field 0)
    (while (and (< field (length (car keys)))
            (eq index
            (string-match "\\([^:]+\\)?:" string index)))
      (setq index (match-end 0))
      (aset (car keys) field (match-string 1 string))
      (setq field (1+ field))))
      (nreverse keys))))
    
    
  2. best https://mslw.github.io/posts/2022-11-20-emacs-notmuch/
    (require 'notmuch) ;; if always run on startup
    ;; -- load:
    (autoload 'notmuch "notmuch" "notmuch mail" t)
    (setq notmuch-search-oldest-first nil)
    (setq message-kill-buffer-on-exit t)
    
  3. TODO https://github.com/admiralakber/simplemacs/blob/master/modules/notmuch.org
    • State "TODO" from [2023-02-18 Sat 11:59]
  4. https://bostonenginerd.com/posts/notmuch-of-a-mail-setup-part-2-notmuch-and-emacs/
    ;Load up Notmuch
    (require 'notmuch)
    
    
    ; Setup some keybindings
    
    
    ; C-c m opens up Notmuch from any buffer
    (global-set-key (kbd "C-c m") `notmuch)
    
    ;Setup Names and Directories
    (setq user-mail-address "myemail@mydomain.tld"
      user-full-name "My Totally Real Name")
    
    ; stores postponed messages to the specified directory
    (setq message-directory "MailLocation/Drafts") ;
    
    ;set sent mail directory
    (setq notmuch-fcc-dirs "MailLocation/Sent")
    
    ;Settings for main screen
    (setq notmuch-hello-hide-tags (quote ("killed")))
    
    ;A few commonly used saved searches.
    (setq notmuch-saved-searches
    (quote
    ((:name "inbox" :query "tag:inbox AND -tag:work" :key "i" :sort-order oldest-first)
     (:name "flagged" :query "tag:flagged" :key "f") ;flagged messages
     (:name "sent" :query "tag:sent -tag:work" :key "t" :sort-order newest-first)
     (:name "drafts" :query "tag:draft" :key "d")
     (:name "mailinglist" :query "tag:lists/mailinglistID" :key "c")
     (:name "all mail" :query "*" :key "a" :sort-order newest-first))))
    
    
    ;Message composition and sending settings
    
    ;Setup User-Agent header
    (setq mail-user-agent 'message-user-agent)
    
    (setq message-kill-buffer-on-exit t) ; kill buffer after sending mail)
    (setq mail-specify-envelope-from t) ; Settings to work with msmtp
    
    (setq send-mail-function (quote sendmail-send-it))
    (setq sendmail-program "~/.local/bin/msmtp-enqueue.sh"
      mail-specify-envelope-from t
    ;; needed for debians message.el cf. README.Debian.gz
     message-sendmail-f-is-evil nil
      mail-envelope-from 'header
      message-sendmail-envelope-from 'header)
    
    ;Reading mail settings:
    
    (define-key notmuch-show-mode-map "S"
        (lambda ()
        "mark message as spam"
        (interactive)
    (notmuch-show-tag (list "+spam" "-inbox"))))
    
    (define-key notmuch-search-mode-map "S"
    (lambda ()
        "mark message as spam"
        (interactive)
        (notmuch-search-tag (list "-inbox" "+spam"))
        (next-line) ))
    
    (setq notmuch-crypto-process-mime t) ; Automatically check signatures
    
    
    ;Crypto Settings
    (add-hook 'message-setup-hook 'mml-secure-sign-pgpmime)
    
    (setq epg-gpg-program "/usr/bin/gpg2")
    
    ;There was some problem with listing PGP keys in the Debian
    ;version of EPG. This magic from StackOverflow seems to resolve it.
    (defun epg--list-keys-1 (context name mode)
    (let ((args (append (if (epg-context-home-directory context)
              (list "--homedir"
                (epg-context-home-directory context)))
              '("--with-colons" "--no-greeting" "--batch"
            "--with-fingerprint" "--with-fingerprint")
              (unless (eq (epg-context-protocol context) 'CMS)
            '("--fixed-list-mode"))))
    (list-keys-option (if (memq mode '(t secret))
                  "--list-secret-keys"
                (if (memq mode '(nil public))
                "--list-keys"
                  "--list-sigs")))
    (coding-system-for-read 'binary)
    keys string field index)
    (if name
    (progn
      (unless (listp name)
        (setq name (list name)))
      (while name
        (setq args (append args (list list-keys-option (car name)))
          name (cdr name))))
      (setq args (append args (list list-keys-option))))
    (with-temp-buffer
      (apply #'call-process
         (epg-context-program context)
         nil (list t nil) nil args)
      (goto-char (point-min))
      (while (re-search-forward "^[a-z][a-z][a-z]:.*" nil t)
    (setq keys (cons (make-vector 15 nil) keys)
          string (match-string 0)
          index 0
          field 0)
    (while (and (< field (length (car keys)))
            (eq index
            (string-match "\\([^:]+\\)?:" string index)))
      (setq index (match-end 0))
      (aset (car keys) field (match-string 1 string))
      (setq field (1+ field))))
      (nreverse keys))))
    
  5. https://github.com/vedang/emacs-up/blob/master/enhance/init-notmuch.el
  6. blacklist https://firminmartin.com/en/posts/2020/10/read_email_in_emacs_with_notmuch/

58.3.10. troubleshooting

fix permissions and ownerships:

sudo /usr/local/bin/email_notmuch_perm.sh
chown -R email:u /home/email/.mail # root required
find /home/email/.mail/ -type d -exec chmod g+rxs {} \; # not working if group is not owned
find /home/email/.mail/ -type f -exec chmod g+rw {} \;

58.4. email composer

  1. default C-x m compose-mail Message.el mode
  2. Message[Notmuch] mode defined in notmuch-mua.el

remplace default message mode with notmuch message mode:

(setq mail-user-agent 'notmuch-user-agent)

58.5. org-mode integration

(add-hook 'message-mode-hook #'turn-on-orgtbl)
(global-set-key (kbd "C-c f") 'org-footnote-action)

additional packages

  • M-x package-install RET orgalist RET - Org-like lists in non-Org buffers
  • M-x package-install RET outshine RET - bring the look & feel of Org-mode to the (GNUEmacs) world outside of the Org major-mode.

58.6. send email actually

Two variables to choose method:

  1. setq send-mail-function
    • 'mailclient-send-it - external client
    • 'smtpmail-send-it - smtp emacs
    • 'sendmail-query-once - ask which to use
  2. message-send-mail-function
    • MH Mail System
    • Gmail

smtpmail-multi

58.6.1. troubleshooting

certificate host does not match hostname

Careful, you may only continue if the displayed certificate fingerprint matches the certificate fingerprint you have received from your server administrator server hosting provider. Not verifying the fingerprint leaves you vulnerable to man-in-the-middle attacks.

59. TODO AutoEncryption

edit encrypted files from inside Emacs

https://www.emacswiki.org/emacs/AutoEncryption

60. TODO auto-composition-mode

61. quail - input method

61.1. debug-on-entry set-input-method

  • set-input-method("chinese-sisheng" t)
  • activate-input-method("chinese-sisheng")
  • (quail-use-package "chinese-sisheng" nil)
    • (quail-select-package "chinese-sisheng")
    • quail-activate()

61.2. create own

(require 'math-symbol-lists)
(quail-define-package "math" "UTF-8" "Ω" t) ; name, language, title, guidence echo area
(quail-define-rules ; add whatever extra rules you want to define here...
 ("\\from"    #X2190)
 ("\\to"      #X2192)
 ("\\lhd"     #X22B2)
 ("\\rhd"     #X22B3)
 ("\\unlhd"   #X22B4)
 ("\\unrhd"   #X22B5))
;; (mapc (lambda (x)
;;         (if (cddr x)
;;             (quail-defrule (cadr x) (car (cddr x)))))
;;       (append math-symbol-list-basic math-symbol-list-extended))

62. USECASES

62.1. how to add column or form table?

Kill a rectangle: kill-rectangle ‘C-x r k’ Yank the last killed rectangle: yank-rectangle ‘C-x r y’ Toggle Rectangle Mark mode C-x SPC

62.2. scroll two buffers two files together

M-x scroll-all-mode

62.3. line numbers at left

  • (setq linum-format " %d ")
  • (global-linum-mode t)

62.4. two files change windows split vertically and horizontally

(defun window-split-toggle ()
  "Toggle between horizontal and vertical split with two windows."
  (interactive)
  (if (> (length (window-list)) 2)
      (error "Can't toggle with more than 2 windows!")
    (let ((func (if (window-full-height-p)
                    #'split-window-vertically
                  #'split-window-horizontally)))
      (delete-other-windows)
      (funcall func)
      (save-selected-window
        (other-window 1)
        (switch-to-buffer (other-buffer))))))

62.5. how to edit several lines

  1. M-x occur that select line by regex
  2. rectangles C-x r
  3. M-% search and replace

63. emacsclient

  • emacs –daemon &
  • emacsclient -c -a "emacs"

64. Very Large Files

for logs:

  • tail -F
  • emacs M-x auto-revert-tail-mode
  • large-file-warning-threshold - emacs warning when open big file

65. Telega

It is unofficial Telegram client, lightweight and enhanced alternative to official massive "telegram-desktop".

65.1. keys

chat

  • M-g ! telega-chatbuf-next-unread-reaction
  • M-g m/@ telega-chatbuf-next-unread-mention
  • i get info at pointer
  • > telega-chatbuf-read-all
  • < telega-chatbuf-history-beginning
  • M-g r telega-chatbuf-read-all
  • M-g P/^ telega-chatbuf-goto-pinned-message
  • p/n - preview/next message
  • C-c C-f telega-chatbuf-attach-media
  • C-c C-a telega-chatbuf-attach
  • C-c /") 'telega-chatbuf-filter
  • M-p M-k telega-chatbuf-edit-prev
  • M-n 'telega-chatbuf-edit-next
  • telega-chatbuf-cancel-aux
    • C-c C-k C-c C-p
    • C-M-c
  • C-c /") 'telega-chatbuf-filter
  • C-x 4 0 kill-buffer-and-window

65.2. source code

  • telega.el - (defun telega (&optional arg) - entry
  • telega-core.el - Variables and runtime goodies for telega
  • telega-root.el
  • telega-chat.el
  • telega-server.el - Interface to `telega-server' process

Message format: telega-chat.el:

  • (defun telega-chatbuf–insert-messages (messages how)

65.3. requirement: TDLib

is fully open source, all code is available on GitHub. https://github.com/tdlib/td

Full dependencies: https://github.com/tdlib/td#dependencies

For stable version of Telega.el you should do 'git checkout v1.8.0' after 'git clone' https://github.com/tdlib/td

Steps:

  • # mkdir build
  • # cd build
  • # cmake -DCMAKE_BUILD_TYPE=Release ..
  • # cmake –build . (for newest version cmake –build . –target tdjson)
  • # make install
  • # xargs rm < install_manifest.txt # to remove

It should install itself to usr/local/include and library itself into /usr/local/lib and *.pc files to /usr/local/lib/pkgconfig

65.4. requirement: telega-server (server foder in https://github.com/zevlg/telega.el/)

Zaicev: Do $ make install in the telega.el/server/ dir, it will install telega-server into ~/.telega/ dir, telega will be able to find it there

Main dependency for server is 65.3 (Full dependencies: https://zevlg.github.io/telega.el/#dependencies)

Steps:

  • # ldconfig # it will update symlinks for TDLib
  • # export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ # path to *.pc installed files of TDLib
  • # make
  • # make install # just copy "telega-server" to ~/.telega/

Telega looks for "telega-server" executable in PATH environmental variable or in ~/.telega/

65.5. emacs configuration

Let's configure MELPA repository in Emacs configuration file. (from https://zevlg.github.io/telega.el/#installing-telega-from-melpa)

(add-to-list 'package-archives
           '("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-pinned-packages '(telega . "melpa-stable"))

Install 'telega' from MELPA repository:

  • M-x package-refresh-contents
  • M-x package-install telega

You need to specify folders and account names:

(setq telega-accounts
      '(("t1" telega-database-dir "/home/telega/.telega/t1")
        ("t2" telega-database-dir "/home/telega/.telega/t2")))

I have "t1" and "t2" named accounts and created "home/telega.telega/t1" and "home/telega.telega/t1" folders for them.

Now in Emacs: M-x telega RET. It should magically ask you which account to use "t1" or "t2", phone number and activation code for it.

65.6. troubleshooting

telega-server error: Valid api_id must be provided. Can be obtained at https://my.telegram.org

  • Zaicev: Старая телега и новая TDLib. update telega
  • check version with: M-x telega-version RET

Perhaps you should add the directory containing `tdjson.pc' to the PKG_CONFIG_PATH environment variable Package 'tdjson', required by 'virtual:world', not found

  • export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
  • or as Zaicev said: "If you intall TDLib into custom prefix (non system-wide), then specify this prefix via LIBS_PREFIX make variable, otherwise pkg-config will be used to detect the prefix."

telega-server: error while loading shared libraries: libtdjson.so.1.8.0: cannot open shared object file: No such file or directory

  • Zaicev: $ sudo ldconfig не забудь запустить перед линковкой telega-server, после того как задаунгрейдил TDLib

66. Youtube packages

empv 4.0.0 available melpa-stable A multimedia player/manager, YouTube interface

ytdious 20210228.2111 available melpa Query / Preview YouTube via Invidious

66.1. yeetube

YouTube Front End | Interface for yt-dlp | mpv control |

Project's Page: https://thanosapollo.org/projects/yeetube Upstream: https://git.thanosapollo.org/yeetube

Dependencies:

  • (require 'compat)
  • (require 'url)
  • (require 'tabulated-list)
  • (require 'cl-lib)
  • (require 'socks)
  • (require 'iimage)
  • (require 'yeetube-mpv) - own

67. proxy

67.1. url/url.el

'(url-proxy-services '(("socks" . "127.0.0.1:9050")))

67.1.1. config socks proxy

(setq socks-server '("Default server" "127.0.0.1" 8080 5)) ;; M-x
customize socks

(setq socks-password "")

;; To test:
(with-current-buffer
(url-retrieve-synchronously "http://ipinfo.io/ip")
(goto-char (point-min)) (re-search-forward "^$")
(delete-region (point) (point-min))
(buffer-string))

67.1.2. path url-retrieve-synchronously

  • url-do-setup
  • url-retrieve
    • url-retrieve-internal
    • url-find-proxy-for-url
    • url-http:
      • url-http.el:
      • url-retrieve (url callback &optional cbargs silent inhibit-cookies)
        • cbargs = (cons nil cbargs)
      • url-http-find-free-connection (url-host url) (url-port url) gateway-method) gateway-method=CBARGS

67.2. old tryes

  • State "TODO" from [2023-04-24 Mon 01:07]
(setq socks-override-functions 1) ;;  Set this before loading the library to make Emacs use Socks for all networking functions.
(setq socks-noproxy '("localhost")) ;; A list of domains to exclude from the proxy
(require 'socks) ;; Finally, load the socks library.
(setq socks-server '("Default server" "127.0.0.1" 1081 5))
(setq socks-noproxy '("127.0.0.1"))
(setq url-gateway-method 'socks)


(setq url-proxy-services
      '(("http"     . "http://proxy.example.com:8080")
        ("https"    . "http://proxy.example.com:8080")
            ("ftp"      . "proxy.example.com:8080")
            ("no_proxy" . "^.*example.com")))

-- test proxy:
(with-current-buffer
    (url-retrieve-synchronously "http://api.ipify.org/")
  (goto-char (point-min))
  (re-search-forward "^$")
  (delete-region (point) (point-min))
  (buffer-string))

(package-refresh-contents)


68. VoiceEmacs

69. EAF - browser, player, terminal

70. QUESTIONS:

  • what is Auto-Composition minor mode?

71. emacs keyboard layouts

72. ChatGPT, Google Bard

73. good modes for UI enhancement

74. keyboard problems:

  • space is too high for big shirt fingers
  • unable to use any key as modifier, detect that key is pressed

75. log keys, log commands, commands logging, key log

packages: command-log-mode

  • M-x command-log-mode - in current buffer only
  • M-x global-command-log-mode (optional. Turn on logging for any buffer)
  • M-x clm/open-command-log-buffer (show the key/command output buffer)

http://xahlee.info/emacs/emacs/emacs_show_key_and_command.html

76. bugs

abbrev.el: abbrev–before-point - skip-syntax-backward go beuound new line.

Footnotes:

1

пояснение в конце

Created: 2024-03-03 Sun 09:50

Validate