1. emacs config

1.1. .emacs

(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") ;; to fix problem with melpa

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


(require 'multiple-cursors)

(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)  
(global-unset-key (kbd "M-<down-mouse-1>"))
(global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click)
(global-set-key (kbd "C-c m") 'mc/mark-all-in-region)
;; or you can you C-SHIFT left mouse click
;; (global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
;; after that you can use multiplie cursor with ALT and left mouse click
;; with multiplie-cursors you need to use package region-bindings-mode. you can install it from melpa
(require 'region-bindings-mode)

(define-key region-bindings-mode-map "g" 'keyboard-quit)
(define-key region-bindings-mode-map "a" 'mc/mark-all-like-this)
(define-key region-bindings-mode-map "p" 'mc/mark-previous-like-this)
(define-key region-bindings-mode-map "n" 'mc/mark-next-like-this)
(define-key region-bindings-mode-map "m" 'mc/mark-more-like-this-extended)
(define-key region-bindings-mode-map "P" 'mc/unmark-previous-like-this)
(define-key region-bindings-mode-map "N" 'mc/unmark-next-like-this)
(define-key region-bindings-mode-map "[" 'mc/cycle-backward)
(define-key region-bindings-mode-map "]" 'mc/cycle-forward)
(define-key region-bindings-mode-map "h" 'mc-hide-unmatched-lines-mode)
(define-key region-bindings-mode-map "\\" 'mc/vertical-align-with-space)
(define-key region-bindings-mode-map "#" 'mc/insert-numbers) ; use num prefix to set the starting number
(define-key region-bindings-mode-map "^" 'mc/edit-beginnings-of-lines)
(define-key region-bindings-mode-map "$" 'mc/edit-ends-of-lines)
(define-key region-bindings-mode-map "r" 'mc/mark-all-in-region-regexp)

(setq inferior-lisp-program "sbcl --dynamic-space-size 8192") 


 '((emacs-lisp . t)
   (python . t)
   (shell . t)
   (sql . t)
   (dot . t)
   (gnuplot . t)    
   (ditaa . t)   
   (lisp . t)))

(setq org-babel-python-command "/usr/bin/python3")

(setq org-confirm-babel-evaluate nil)

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

(require 'helm-projectile)

(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)

(helm-mode 1)

(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)

(setq org-roam-v2-ack t)
(require 'info)
(setf org-roam-directory (file-truename "/home/archi/syncthing/roam/"))
(setf org-roam-db-location (file-truename "/home/archi/syncthing/roam/org-roam.db"))

(require 'org-roam)
(require 'org-roam-protocol)

(global-set-key "\C-cnl" 'org-roam-buffer-toggle)
(global-set-key "\C-cnf" 'org-roam-node-find)
(global-set-key "\C-cng" 'org-roam-graph)
(global-set-key "\C-cni" 'org-roam-node-insert)
(global-set-key "\C-cnc" 'org-roam-capture)
(global-set-key "\C-cnj" 'org-roam-dailies-capture-today)

(require 'which-key)


(global-set-key (kbd "C-x w") 'elfeed)
(global-set-key (kbd "C-c g") 'grep)




1.2. emacs orgmode hide begin src

(setq org-hide-block-startup t)

1.3. emacs themes

Хорошие темы:

Имя пакета тема
gruvbox gruvbox-dark-soft
twilight-bright twilight-bright
doom-themes doom-nord

2. org

2.1. org-babel examples

you can write code into orgmode files with code blocks. Several code blocks may be in one file and you can pass params between them. Orgmode is good thing for keep code and documentaion together. Also i want try to use orgmode files as user cockpit of executing sql and other code blocks in my work.

very good ref of use orgmode: https://github.com/dfeich/org-babel-examples


  '((python . t) 
    (sql . t)
    ;; other

(setf org-confirm-babel-evaluate nil) ;; to disable ask before execute code on C-c C-c                                                                     
src_python[:session zmy]{"hello world11"} {{{results(=hello world11=)}}}

src_python[:session zmy]{a} {{{results(==)}}}

very well https://org-babel.readthedocs.io/en/latest/eval/

#+name: sel                                                                                                     
#+header: :var x=4
#+begin_src sql :engine postgresql :database archi :dbuser archi
select $x as v
limit 100

#+RESULTS: sel
| v |
| 4 |

#+call: sel(x=5)                                                                                          

| v |
| 5 |

#+begin_src sql :engine postgresql :database archi :dbuser archi :var zz="tableowner='archi'"
  select *
  from pg_catalog.pg_tables
  where $zz
  limit 4

| schemaname | tablename        | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity |
| archi      | jobs_sync_moment | archi      |            | t          | f        | f           | f           |
| archi      | job_template     | archi      |            | t          | f        | t           | f           |
| archi      | jobs             | archi      |            | t          | f        | t           | f           |
| archi      | users_portfolios | archi      |            | t          | f        | t           | f           |

import org-table as ipython

#+tblname: fibonacciinputs
| 1 | 2 | 3 | 4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |

#+BEGIN_SRC python :session mysession :var f555=fibonacciinputs

| 1 | 2 | 3 | 4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |

pass org-table into elisp

#+tblname: transpose-example
| 1 | 2 | 3 | 1 | 66 |
| 4 | 5 | 6 | 5 | 77 |

#+begin_src emacs-lisp :var table=transpose-example
(print table)

| 1 | 2 | 3 | 1 | 66 |
| 4 | 5 | 6 | 5 | 77 |

#+name: zname111
#+header: :var whereclause='1=1'
#+begin_src sql :engine postgresql :database archi :dbuser archi
  select *
  from pg_catalog.pg_tables
  where $whereclause
  limit 4

#+RESULTS: zname111
| schemaname | tablename        | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity |
| pg_catalog | pg_statistic     | postgres   |            | t          | f        | f           | f           |
| archi      | jobs_sync_moment | archi      |            | t          | f        | f           | f           |
| pg_catalog | pg_foreign_table | postgres   |            | t          | f        | f           | f           |
| pg_catalog | pg_authid        | postgres   | pg_global  | t          | f        | f           | f           |

#+call: zname111(whereclause="tableowner='archi'")

| schemaname | tablename | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity |
| public     | zzz       | archi      |            | f          | f        | f           | f           |

you can pass quotes with double quote in var value. i don't know what to do if you need ' and " together

#+begin_src sql :engine postgresql :database archi :dbuser archi :var zz="tableowner='archi'"
  select *
  from pg_catalog.pg_tables
  where $zz
  limit 4

| schemaname | tablename        | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity |
| archi      | jobs_sync_moment | archi      |            | t          | f        | f           | f           |
| archi      | job_template     | archi      |            | t          | f        | t           | f           |
| archi      | jobs             | archi      |            | t          | f        | t           | f           |
| archi      | users_portfolios | archi      |            | t          | f        | t           | f           |

you can pass params into python program example for limit

#+name: sqlpython155556456
#+begin_src python :session mysession :results output :var x=5
  import psycopg2
  import pandas as pd

  dbh = psycopg2.connect(database="archi", user="archi", password="123", host="")
      zsql = f"""
      select schemaname, tablename 
      from pg_catalog.pg_tables
      limit {x}

      df1 = pd.read_sql(sql=zsql, con=dbh)
  except Exception as e:

#+RESULTS: sqlpython155556456
: schemaname         tablename
: 0  pg_catalog      pg_statistic
: 1       archi  jobs_sync_moment
: 2  pg_catalog  pg_foreign_table
: 3  pg_catalog         pg_authid
: 4       archi      job_template

#+call: sqlpython155556456(x=1)       

: schemaname     tablename
: 0  pg_catalog  pg_statistic

you can pass one results into another

#+name: xz111
#+begin_src python :session mysession
  import sys

#+RESULTS: xz111
: 3.7.3 (default, Jan 22 2021, 20:04:44) 
: [GCC 8.3.0]

#+name: xz112
#+begin_src python :results output :session mysession :var trtrtr='1'

#+RESULTS: xz112
: 1

#+call: xz112(trtrtr=xz111) 

: 3.7.3 (default, Jan 22 2021, 20:04:44) 
: [GCC 8.3.0]

here we launch two

#+name: xz113
#+begin_src python :results output :session mysession :var trtrtr=xz111

#+RESULTS: xz113
: 3.7.3 (default, Jan 22 2021, 20:04:44) 
: [GCC 8.3.0]

set python3 into org-babel

(setq org-babel-python-command "/usr/bin/python3")

2.3. emacs cua-mode

cua-mode allow C-c C-v, C-z

Мне не понравилось. Перебивает сочетания клавиш. Лучше не пользоваться.

2.4. emacs winner-mode

winner-mode (windmove-default-keybindings) S-left|right|down|up to change buffer

2.5. orgmode формула сумма

фоомула для суммирования данных в колонке

#+TBLFM: @>$2=vsum(@I..@II)

2.6. org-mode   orgmode

#+name: block-1
#+BEGIN_SRC emacs-lisp

#+RESULTS: block-1
: Sat Nov 16 11:51:40 2019

#+BEGIN_SRC emacs-lisp :var input=block-1
(format "We got %S in block-1" input)

: We got "Tue Jul 13 19:31:23 2021" in block-1
#+name: block-3
#+BEGIN_SRC emacs-lisp :cache yes :file block-3
(require 'json)
(json-encode `(("date" . ,(current-time-string))))

#+RESULTS[41f390211632508ef06a03fb39f991fd623066c6]: block-3

M-x linum-mode

3. taskjuggler

3.1. taskjuggler and ormode

<2020-07-09 Чт>

Taskjuggler - это утилита без GUI для управления проектами. Умеет выгржать в MS Project, а значит если вести в ней учёт - можно будет сделать выгрузку и поделиться с с людьми. Также есть возможность генерировать Web страницу с диаграмой ганта и другими фишками. Есть интеграция с orgmode. Фактически задачи можно вести в orgmode, а в taskjuggler смотреть планы по выполнению. Для выгрузки из orgmode в taskjuggler устаналиваем следующий пакет: https://gist.github.com/anoduck/4adf306252f6b8c8759a (ox-taskjuggler.el). Скачиваем файл в папку ~/.emacs.d/lisp/ox-taskjuggler.el и в ~/.emacs добавляем строку: (load "~/.emacs.d/lisp/ox-taskjuggler.el")

Свойства который вы возможно захотели бы использовать:

#+PROPERTY: allocate_ALL dev doc test
#+COLUMNS: %70ITEM(Task) %Effort %allocate

Свойства которые можно использовать в задачах типа ресурс:
:resource_id: - ресурс 

Свойства которые можно использовать в задачах:
:task_id: - ID задачи. используется для зависимостей и т.д. Нельзя чтобы начинался с цифры. Пример: ID1.
:allocate: - это resource_id т.е. тот кто делает задачу
:priority: - стандартный тэг приоритета из orgmode транслируется в тэг приоритета в juggler
:start: - дата начала выполнения задачи. записывается как дата без доп симоволов, например так: 2020-07-09. Если использовать дату из orgmode работать не будет.
:complete: - процент выполненности задачи. записывается как просто число. пример: 50.
:effort: - оценка. по мне так лучше указывать в часах т.к. если делать это в днях - то получим в одном дне 24 часа. пример: 4h.

у проекта можно поставить следующий тэг:
:VERSION: пример 1.1.

После загрузки - ведём задачи как обычно, на самом верхней задаче добавляем тэг

* project1 :taskjuggler_project:
** task 1

Для обозначения ресурсов используем тэг :taskjuggler_resource:

* Resources                                         :taskjuggler_resource:  

3.2. wkhtmltopdf

taskjuggler -> to html -> to pdf

wkhtmltopdf pathtohtml.html pathtopdf.pdf https://wkhtmltopdf.org/

wkhtmltopdf pathtohtml.html pathtopdf.pdf

4. emacs-tips

4.1. speed up emacs

чтобы убрать задержки отрисовки скобок - нужно применить эту опцию. Тогда emacs не будет отрисовывать скобки и вывод станет гораздо быстрее. (можно добавить опцию в конфигурационный файл .emacs

(setf blink-matching-paren nil)

4.2. emacs slime

как запустить swank через ssh

#+BEGIN_SRC bash
 screen -S sbcl
#+BEGIN_SRC lisp
 (require 'asdf)
 (asdf:oos 'asdf:load-op 'swank)
 (setq swank:*use-dedicated-output-stream* nil)
 (swank:create-server :coding-system "utf-8-unix" :dont-close t :port 4005)

#+BEGIN_SRC bash
ssh -2 -N -f -L 4005:localhost:4005 user@host.tld

M-x slime-connect

4.4. emacs

<2019-11-05 Вт> This is a classic "Wow, Emacs does that?" situation: I discovered `imenu` by accident this week. On the one hand, it's a great tool for finding definitions in code – but because my main use of Emacs is for writing and PIM, the thing that really excited me was `imenu-add-menubar-index`. In org files, it treats each heading as a part of the index – so by adding `imenu` to the menu bar, I have fly-out navigation for large org files. (I know people hate the menu bar, but I've found it handy). That's all well and good, but now add in the `imenu-list`package, and you have a little pop-up outline of your org file just one keypress away: it's like the bookmarks in a PDF, and has been really helpful already in getting around. Light, clean, easy. Customizing `org-imenu-depth` sets how deep into a nested hierarchy to index for either `imenu-list` or the menubar index.

4.5. swank

  • Install a Common Lisp implementation on the server. (E.g. sbcl, clisp, etc…)
  • Install quicklisp on the server.
  • Load SWANK with (ql:quickload :swank)
  • Start the server with (swank:create-server). The default port is 4005.
  • [On your local machine] Create a SSH tunnel with ssh -L4005: [remote machine]
  • Connect to the running remote swank server with M-x slime-connect. The host should be and the port 4005.

4.6. emacs chart

(require 'chart)
(chart-bar-quickie 'vertical "Favorite Type of Movie"
		   '("Comedy" "Action" "Romance" "Drama" "Sci-Fi") "Genre"
		   '(4 5 6 1 4) "People" ) 

4.7. org-brain settings


install package from melpa

add in .emacs

(require 'org-brain)
(setq org-brain-path "E:\\syncthinc\\brain")

then you can create files

4.8. editing with emacs ace-jump-mode

5. emacs-hotkeys

5.1. Emacs hotkeys

M-x speedbar Древовидное отображение данных, например папка в ФС.

M-x ecb-activate IDE для некоторых языков. Emacs code browser

M-x auto-fill-mode Режим автозаполнения строк(что бы это не значило)

C-h a apropos Поиск в справке по строке/регулярному выражению

C-x u undo Отменить последнюю операцию C-x r m bookmark-set Установить закладку. Полезно при поиске C-x r b bookmark-jump Перейти к закладке

C-s isearch-forward Поиск строки вперёд C-r isearch-backward Поиск строки в обратном направлении M-% query-replace Поиск и замена с запросом

C-x C-x exchange-point-and-mark Поменять местами точку и начало пометки

C-x x N copy-to-register Копировать отмеченный текст в регистр (N может быть буквой или цифрой, позволяя использовать множество регистров)

C-x g N insert-register Вставляет в точку содержимое регистра N

M-C-\ indent-region Выравнивание строк выделенного фрагмента

M-\ delete-horizontal-space Удалить все пробелы и знаки табуляции вокруг точки

C-q quoted-insert Вставка символа, соответствующего нажатой клавише или сочетанию, даже если это управляющая последовательность

M-q fill-paragraph Выравнивает текст в текущем параграфе

M-f перейти к следующему слову(спец символы делят слово) C-M-f перейти к следующему слову до пробела

5.2. emacs working with lines

working with newline to insert newline into replace command you can do this: C-q - insert code, C-j - newline with this command you can replace , with newline (select region) M-x query-replace RET , RET C-q C-j RET

with multiplie cursor you can do this with: (select ,) mc/mark-all-like-this RET C-q C-j

sort region to sort region you can select region and do M-x sort-lines

insert numbers to insert number (from 1 to numstr) you select multiplie rows and do M-x mc/insert-numbers

to replace , with newline do: M-x query-replace RET , RET C-q C-j RET !

to do same with multiplie cursor: select region with , and: M-x mc/mark-all-like-this RET C-q C-j

to sort lines by alphabet select region M-x sort-lines

to insert numbers from 0 to numstr: set multiplie cursor where you want to insert numbers and mc/insert-numbers

to delete duplicate lines: select region M-x delete-duplicate-lines

5.3. emacs lisp

Привязка вызова функции к сочетанию клавиш
(global-set-key "\C-c=" 'count-words-defun)

(defun find-file (filename)
  "Edit file FILENAME.
  Switch to a buffer visiting file FILENAME,
  creating one if none already exists."
  (interactive "FFind file: ")
  (switch-to-buffer (find-file-noselect filename)))
Посчитать количество файлов в директории с расширением
(length (directory-files "~/" t "\\.el$"))

;;; Привязка для `occur'
; Я часто использую команду occur, так что я связываю ее с клавишей:
(global-set-key "\C-co" 'occur)

;;; Переместить строку в начало окна;  
;;; заменяем трехступенчатую комбинацию  C-u 0 C-l
(defun line-to-top-of-window ()
  "Move the line point is on to top of window."
  (recenter 0))

M-! etags *.el

5.4. emacs

ido-mode Команды типа C-x b начинают предлагать удобный выбор буфера.

linum-mode - показывает номер строки

(windmove-default-keybindings) ;;enable shift-arrows switching between windows

5.5. emacs key binding

(global-set-key (quote [f7]) [?\C-x ?h ?\M-x ?q ?u ?e ?r tab return ?a return ?b return ?!])

чтобы получить макрос: f3 - записываем макрос, записываем действия. f4. M-x insert-kbd-macro получаем текст макроса Но есть один неприятный ньюанс - он тупо прогоняет нажатия на кнопки.

M-x where-is КОМАНДА показывает сочетание клавиш для вызова команды

Чтобы найти keyboard shortcut - пишем - C-h k и дальше клавиатурное сокращение.

Записать функцию на нажатие клавиши. (global-set-key (quote [f8]) (lambda() (interactive) (princ "Q8")))

(global-set-key (quote [f8]) (lambda() (interactive) (zzz1)))

(defun zzz1() (print "ZzzZz22"))

C-x n n - narrowning. Выделяешь регион. Потом C-x n n - остается видимым только этот регион. Работаешь с регионом - C-x n w - widening - возвращает всё обратно.

Если написать interactive - и дальше тип параметра на вход. То система позволяет данную функцию запускать через M-x mp7 (defun mp7 (number) (interactive "p") (message "The result is %d" (* 7 number)))


5.6. emacs follow link

to follow link inside org document you can: click with mouse or: C-c C-o

6. emacs-git

6.1. emacs git


vc-dir commands:

B c : Create a new branch (vc-create-tag). B s : Switch to a branch (vc-retrieve-tag). See Switching Branches.

The VC command to switch to another branch in the current directory is C-x v r branch-name <RET> (vc-retrieve-tag).

Once you have switched to a branch, VC commands will apply to that branch until you switch away;

Prior to pushing, you can use C-x v O (vc-log-outgoing) to view a log buffer of the changes to be sent. See VC Change Log. Prior to pulling, you can use C-x v I (vc-log-incoming) to view a log buffer of the changes to be applied. See VC Change Log.

C-x v m : On a decentralized version control system, merge changes from another branch into the current one.

The VC command to switch to another branch in the current directory is C-x v r branch-name <RET> (vc-retrieve-tag).

On Git, branches are normally co-located in the same directory, and switching between branches is done using the git checkout command, which changes the contents of the working tree to match the branch you switch to.

The VC command to switch to another branch in the current directory is C-x v r branch-name <RET> (vc-retrieve-tag).

6.2. emacs magit

7. emacs-crypt

7.1. orgmode crypt


How does the :crypt: tag work in org-mode? Hello, I would like to create an org file "private.org" to organize all my login informations, something like: * Login :crypt: * GMAIL :PROPERTIES: :USERNAME: :PASSWORD: :END * YAHOO and so on… If I use the crypt tag the file gets encoded when saving. I have these lines in init.el (require 'org-crypt) ;; Encrypt all entries before saving (org-crypt-use-before-save-magic) (setq org-tags-exclude-from-inheritance (quote ("crypt"))) ;; GPG key to use for encryption (setq org-crypt-key "007") When I decode or encode I need to provide that key "007" to Emacs. I will change the key to something more complex but if someone opens my init.el file or if I upload the init.el to Github he can see that "org-crypt-key" and decode the file, right? Isn't that wrong? I'm not exactly sure how does this :crypt: thing work.

8. elisp

8.1. emacs timer


run lambda after one second (run-at-time 1 ;; in one second nil ;; do NOT repeat (lambda () ;; this lambda is called (message "I ran!")))

8.2. org emacs scheduler




#+begin_src elisp
  ;; variable for the timer object
  (defvar idle-timer-cookbook-timer nil)

  ;; callback function 
  (defun idle-timer-cookbook-callback ()
    (message "I have been called (%s)" (current-time-string)))

  ;; start functions
  (defun idle-timer-cookbook-run-once ()
    (when (timerp idle-timer-cookbook-timer)
      (cancel-timer idle-timer-cookbook-timer))
    (setq idle-timer-cookbook-timer
	    (run-with-idle-timer 1 nil #'idle-timer-cookbook-callback)))

  (defun idle-timer-cookbook-start ()
    (when (timerp idle-timer-cookbook-timer)
      (cancel-timer idle-timer-cookbook-timer))
    (setq idle-timer-cookbook-timer
	    (run-with-timer 1 1 #'idle-timer-cookbook-callback)))

  ;; stop function
  (defun idle-timer-cookbook-stop ()
    (when (timerp idle-timer-cookbook-timer)
      (cancel-timer idle-timer-cookbook-timer))
    (setq idle-timer-cookbook-timer nil))

#+begin_src elisp
  ;; "asd" is buffer-name
  ;; dir is command
  (start-process-shell-command "cmd.exe" "asd2" "dir") 

8.3. elpy settings   python elpy settings

Мне не помогло то что ниже, но при этом я узнал что код: if name__=='__main': не работает в емакс при нажатии C-c C-c, но при этом вполне корректно работает при C-u C-c C-c


;; Make C-c C-c behave like C-u C-c C-c in Python mode
(require 'python)
(define-key python-mode-map (kbd "C-c C-c")
  (lambda () (interactive) (python-shell-send-buffer t)))

8.4. emacs lisp eval and replace

#+begin_src elisp
     (defun eval-and-replace ()
       "Replace the preceding sexp with its value."
       (condition-case nil
	   (prin1 (eval (read (current-kill 0)))
	 (error (message "Invalid expression")
	      (insert (current-kill 0)))))

8.5. emacs web server

General web server https://github.com/eschulte/emacs-web-server

org-to-web. https://github.com/eschulte/org-ehtml

To publish your org file (on fly convert org->html when web page open), you need to:

  • add melpa into emacs repo. ( see https://melpa.org/#/getting-started ).
  • install package org-ehtml from melpa (M-x package install RET org-ehtml)
  • create folder and set variables in .emacs:

(setq org-ehtml-docroot (expand-file-name "~/public_org")) (setq org-ehtml-everything-editable t)

  • add in .emacs and restart emacs. Web server started

(require 'org-ehtml) (ws-start org-ehtml-handler 8888)

  • Now you can open site. When you open it, you see folder. If there org files, when you open them, emacs will convert org->html and show it. If file changed, converting will repeat.


8.6. emacs repl

m-x ielm чтобы попасть в repl в emacs

8.6.1. Примеры работы с elisp

(setf x '( 1 2 23 4 5 6 7 8 ))

Это нужно выпонить и тогда данная переменная будет сохранена в глобальной области памяти. Встаём на последнюю скобку и нажимаем: C-x C-e

#+begin_src elisp :results output
  (print x)

: (1 2 23 4 5 6 7 8)
#+begin_src elisp
  (mapcar '1+ x)

 | 2 | 3 | 24 | 5 | 6 | 7 | 8 | 9 |
#+begin_src emacs-lisp :results value
  (format "%s" "dflgjdfklgjkdfg")
  (mapcar (lambda (z) (format "%s12 11 1 \n" z)) x) 

 | 112 11 1  |
 | 212 11 1  |
 | 2312 11 1 |
 | 412 11 1  |
 | 512 11 1  |
 | 612 11 1  |
 | 712 11 1  |
 | 812 11 1  |
this code will create file: file txt
#+begin_src emacs-lisp
  (setf x '(1 2 3))
  (append-to-file (mapconcat 'identity (mapcar (lambda (i) "dsad" (format "select %d from dual\n" i) ) x) " ") 2 "file.txt")

#+RESULTS: in file.txt
 select 1 from dual
 select 2 from dual
 select 3 from dual
#+begin_src emacs-lisp
  (setf x '(1 2 3))
  (mapconcat 'identity x " ")

| 1 | 2 | 3 |
#+begin_src emacs-lisp :results output
(setf q (let (res) (reverse (dotimes (i 4 res) (push i res)))))
(mapcar (lambda (iii) (princ (format "select %s from dual union all \n" iii)) ) q)
: select 0 from dual union all 
: select 1 from dual union all 
: select 2 from dual union all 
: select 3 from dual union all 

to clear ielm buffer C-x h then M-x comint-kill-region

Автор: Асриян Артур

Created: 2021-08-09 Пн 12:56