The Best Emacs Microfeature
https://borretti.me/article/the-best-emacs-microfeature
https://redd.it/1ekvf8l
@r_emacs
Note-taking profile
I never touched emacs but want to start using it as a note-taking tool. I used a lot of zim wiki, it's great but also very limiting and has all the cons of a retained-mode user interface.
My question is what "flavor" of emacs should i use that best fits my needs?
All i ask is rich text, image viewing support, linking to other notes/files, hierarchical notes and optionally a GUI.
I don't mind steep learning curves nor the specific type of rich text.
https://redd.it/1eknzl3
@r_emacs
Problems with bookmarks with consult and perspective
I use consult, vertico and perspective. When I setup perspective, I have found the problem: when I use `C-x b` in minibuffer I see all buffers from all perspectives. It fixes by next setting in consult:
(consult-customize consult--source-buffer :hidden t :default nil)
(add-to-list 'consult-buffer-sources persp-consult-source)
Everything is working fine, except bookmarks. When I use `C-x r b`, I see next message in minibuffer:
consult--read-1: Keyword argument :hidden not one of (:prompt :predicate :require-match :history :default :keymap :category :initial :narrow :add-history :annotate :state :preview-key :sort :lookup :group :inherit-input-method)
Here is my config of perspective and consult:
(use-package perspective
:ensure t
:bind (("C-x k" . persp-kill-buffer*))
:custom
(persp-mode-prefix-key (kbd "C-x x"))
:config
(setq persp-state-default-file "~/.emacs.d/session_pers")
:init
(persp-mode))
(use-package consult
:ensure t
;; Replace bindings. Lazily loaded due by `use-package'.
:bind (;; C-c bindings in `mode-specific-map'
("C-c M-x" . consult-mode-command)
("C-c h" . consult-history)
("C-c k" . consult-kmacro)
("C-c m" . consult-man)
("C-c i" . consult-info)
([remap Info-search] . consult-info)
;; C-x bindings in `ctl-x-map'
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
;; ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings in `goto-map'
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings in `search-map'
("M-s d" . consult-find) ;; Alternative: consult-fd
("M-s c" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" .
Different behavior between fill-paragraph and org-fill-paragraph
Hello fellow Emacs enthusiasts!
I've noticed an interesting behavior difference between fill-paragraph in text-mode and org-fill-paragraph in org-mode, particularly when working with selected regions.
Here's what I've observed:
- In text-mode, fill-paragraph respects the selected region and only operates within it.
- In org-mode, org-fill-paragraph doesn't seem to respect the selected region and operates on the entire paragraph.
I've created a GIF to illustrate this difference:
https://i.redd.it/7trbpcthrqgd1.gif
I initially thought this was a bug and submitted a report, but it was determined not to be one.
I'd like to open this up for community discussion to get your thoughts and insights.
In org-mode, the behavior remains the same whether a region is selected or not. When no region is selected, I believe this behavior is appropriate.
However, the issue arises when a user explicitly selects a region, expecting the fill operation to be limited to that selection.
I think org-fill-paragraph should respect the selected region, similar to how fill-paragraph works in text-mode.
What do you think about this behavior?
https://redd.it/1ekann9
@r_emacs
question about consult completion
Hi everyone, sorry I couldn't find a proper title for what I was looking for. what I want is a way for consult completion candidates to show a certain string when I'm selecting from the minibuffer but when the candidate is selected it should be the original form string.
for example:
;; I have this list of paths that I want to select from
(defvar paths '("/dir1/dir2/p1" "dir1/dir2/p2" "/dir1/dir2/p3"))
;; I want to parse those paths to only show the filename
;; in the minibuffer
(consult--read (--map (file-name-nondirectory it) paths))
;; the completion is supposed to be p1, p2, p3
;; but when when I select I want the original path to be selected
;; for example /dir1/dir2/p1
I would do it using a hashmap or alist to map between the candidates and the selection.
is there an easier way around this without using annotate function or marginalia ??
https://redd.it/1ek212y
@r_emacs
Your configuration of yasnippet and company for LaTeX and more
Can you describe, how you make yasnippet working with company-mode in LaTeX buffers or buffers with programming languages?
https://redd.it/1ejyhpc
@r_emacs
why do I need a space after #+title:
I'm using org-roam
if I have #+title: python:getting command in ubuntu
then org-roam-find-node can list it
if I have #+title:python:getting command in ubuntu
then org-roam-find-node cannot list it
Both ways, the python:getting command in ubuntu
are highlighted with org-document-title
face, so I think (I could be wrong) that org-mode parses both way alright(or is it font-lock and parser behave differently?). but the space will make that huge difference to org-roam-find-node
Why?
edit: additional test case
if I have #+title:python getting command in ubuntu
then org-roam-find-node can list it, and (org-list-keyword "title")
on the buffer gives (("TITLE" "python getting command in ubuntu"))
https://redd.it/1ej96kl
@r_emacs
Efficient Emacs configuration and startup with minimal-emacs.d
https://www.jamescherti.com/minimal-emacs-d/
https://redd.it/1ej8zxt
@r_emacs
Mouse Events on SVG Images in Emacs [2022]
https://www.leonrische.me/pages/mouse_events_on_images_in_emacs.html
https://redd.it/1ej1e33
@r_emacs
Org Roam Daily Reflection, a new package for viewing daily journal entries
https://github.com/emacsomancer/org-roam-daily-reflection
https://redd.it/1einc51
@r_emacs
Tamil text rendering in emacs is messed up
correct and pleasant
incorrect and unpleasant
Both images are snapshot of the same window, with one difference. The image on top is when I increase the text size where as the bottom one is default font size which is '(font . "Noto Sans Mono:style=medium:size=20").
why is this happening?
https://redd.it/1eicgoy
@r_emacs
Emacs-Wayland Arch AUR
Hey everyone,
recently I've had some trouble with Doom Emacs crashing unexpectedly and I've been trying to troubleshoot today with research and chatgpt.
I found on r/DoomEmacs a similar thread where an Arch user was experiencing the same thing while editing C++ files while mine was mostly happening when editing Rust files. I don't have much to go on but my assumption was that when the rust-analyzer was working or Rust LSP was communicating it was causing it to panic and crash but this was just an assumption and I was having trouble getting much out of --debug-init. This user was able to downgrade to version 29.3 and it solved their problems.
Recently I've completely uninstalled rust, emacs and doom emacs and found wayland-emacs on the aur which I didn't notice last time. I've reinstalled Rust and now I'm going to attempt to install this AUR package and go from there. Another issue I was having was opening Fish shell in Doom Emacs with Term which wasn't an issue before until installing Rust.
It's also important to note that I've had this Arch + Hyprland install for about 2 weeks and Doom Emacs hasn't given any issues what so ever until installing rust and rust-analyzer but also I upgraded around the same time and I know there was an upgrade 2 days ago. Thanks for reading, I wanted to try and be thorough so I apologize for the length of this.
P.S The user on Arch I was talking about with a similar issue was using X11
EDIT: solved, I use the pacaman package manager to uninstall emacs-wayland and installed emacs instead. So far rust hasn't crashed when editing or coding rs files in doom and rust-analayzer is working. Must install with rustup component add rust-analyzer though, not your package manager. and using vterm this time with no issues.. yet ;)
https://redd.it/1ehxpvq
@r_emacs
How to disable buffer groups in centaur tabs?
Most of the time, I have use tab-bar-mode for tabs, but when I find centaur-tabs package, I understand that it is better than standard tab-bar-mode. I like all in centaur-tabs except this logic of buffer groups. Can I disable this and make centaur-tabs working like tab-bar-mode?
Thank you before, for all helpful answers.
https://redd.it/1ei5b26
@r_emacs
(string= lang "shell"))
`(("src" ,(concat "{" language-icon "}"))))
;; REMOVE ADDING OF ADDITIONAL OPTIONS
;; (when caption-str
;; ;; caption-above-p means captionpos is t(op)
;; ;; else b(ottom)
;; `(("captionpos" ,(if caption-above-p "t" "b"))))
;; (cond ((assoc "numbers" lst-opt) nil)
;; ((not num-start) '(("numbers" "none")))
;; (t `(("firstnumber" ,(number-to-string (1+ num-start)))
;; ("numbers" "left"))))
;; EDITS END HERE
)
)
(let ((local-options (plist-get attributes :options)))
(and local-options (concat "," local-options))))
;; Source code.
(let* ((code-info (org-export-unravel-code src-block))
(max-width
(apply 'max
(mapcar 'string-width
(org-split-string (car code-info) "\n")))))
(org-export-format-code
(car code-info)
(lambda (loc _num ref)
(concat
loc
(when ref
;; Ensure references are flushed to the right,
;; separated with 6 spaces from the widest line of
;; code
(concat (make-string (+ (- max-width (length loc)) 6) ?\s)
(format "(%s)" ref)))))
nil (and retain-labels (cdr code-info))))))))
(advice-add 'org-latex-src-block--listings :override #'my/org-latex-src-block--listings)
#+end_src
#+begin_src emacs-lisp
(setq org-latex-listings 'listings)
#+end_src
The export preamble for terminals can be defined ([[https://tex.stackexchange.com/a/517985][source]])...
#+name: org-latex-terminal-export-preamble
#+begin_src latex :tangle no :exports code
\newtcblisting{ubuntu}{
colback=violet!50!black,
colupper=white,colframe=gray!65!black,
listing only,
listing options={
style=tcblatex,
language=sh,
escapeinside=``,},
title={\textcolor{orange}{\Huge{$\bullet$}}{\textcolor{gray}{\Huge{$\bullet\bullet$}}}},
every listing line={\MyUbuntuPrompt},enhanced,}
\pgfkeys{
/ubuntu/.cd,
user/.code={
\gdef\MyUbuntuUser{#1}},
user={},
host/.code={
\gdef\MyUbuntuHost{#1}},
host={},
color/.code={
\gdef\MyUbuntuColor{#1}},
color=white,
prompt char/.code={
\gdef\MyUbuntuPromptChar{#1}},
prompt char=\#,
root/.style={
user=root,
host=hostname,
color=lime,
prompt char=\#},
name/.style={
user=username,
host=remotehost,color=cyan},
ssh/.style={
user={
ssh\char`_user},
host=burrow,
color=magenta,
prompt char=\$}
}
\newcommand{\SU}[1]{\pgfkeys{/ubuntu/.cd,#1}%
\gdef\MyUbuntuPrompt{\textcolor{\MyUbuntuColor}{\small\ttfamily\bfseries \MyUbuntuUser@\MyUbuntuHost{\textcolor{white}:}\textcolor{cyan!60}{\url{~}}{\textcolor{white}\MyUbuntuPromptChar} }}}
\newcommand{\StartConsole}{\gdef\MyUbuntuPrompt{}}
\SU{user=username,host=remotehost,color=white}
#+end_src
#+begin_src emacs-lisp :noweb no-export :noweb-prefix no
(defvar org-src-export-preamble
(concat
<<src-contents-to-string(value=org-latex-code-export-preamble[])>>
<<src-contents-to-string(value=org-latex-algorithm-export-preamble[])>>
<<src-contents-to-string(value=org-latex-terminal-export-preamble[])>>)
"LaTeX options for styling code blocks")
#+end_src
Now it can be hooked into the preamble.
#+begin_src emacs-lisp
(org-export-update-features 'latex
(code
:condition "^[ \t]*#\\+begin_src\\|^[ \t]*#\\+BEGIN_SRC\\|src_\\|SRC_"
:snippet org-src-export-preamble
:requires (caption .etoolbox .color-box
a simplified and improved version of evil-replace-with-register
As is well known, evil automatically copies deleted text to the register. If you want to replace a piece of text without writing the deleted text to the register (in other words, you only want to delete the text, not cut it), so that you can continuously replace a piece of text in multiple places. If you don't want to use any plugins and want to solve this directly through vim commands, the method is to first select the text and then enter the command "ay
, which copies this text to the a
register. Then, for the text you want to replace, first select it and then enter "ap
, which replaces the selected text with the text in register a.
The above operation is obviously cumbersome. Previously, I used the evil-replace-with-register
plugin to solve this problem. This plugin provides a command bound to gr
, allowing for convenient operations similar to other common vim commands. For example, after copying a word with yiw
, you can continuously use griw
(which is also dot-repeatable) to replace the words you want to replace, without worrying about the deleted text being cut.
However, this command is not very ideal for visual block mode. Simply put, it can't handle the following scenario:
aa ee
bb gg
cc hh
aa aa
bb bb
cc cc
(evil-define-operator evil-replace-with-register (count beg end type register)
"Replacing an existing text with the contents of a register"
:move-point nil
(interactive "<vc><R><x>")
(setq count (or count 1))
(if (eq type 'block)
(evil-visual-paste count register)
(delete-region beg end)
(evil-paste-before count register)))
New to emacs
Recently I have started using emacs I'm literally in love with emacs.
I have looked into this reddit how to install helm and melpa not able to get it correct.
Can you guys give me steps to install melpa and add helm.
Thanks.
https://redd.it/1ekrtop
@r_emacs
consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Configure other variables and modes in the :config section,
;; after lazily loading the package.
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key "M-.")
;; (setq consult-preview-key '("S-<down>" "S-<up>"))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme :preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-file-register
consult--source-recent-file consult--source-project-recent-file
consult--source-buffer :hidden t :default nil
;; :preview-key "M-."
:preview-key '(:debounce 0.4 any))
(add-to-list 'consult-buffer-sources persp-consult-source)
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; "C-+"
;; Optionally make narrowing help available in the minibuffer.
;; You may want to use `embark-prefix-help-command' or which-key instead.
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
;; By default `consult-project-function' uses `project-root' from project.el.
;; Optionally configure a different project root function.
;;;; 1. project.el (the default)
;; (setq consult-project-function #'consult--default-project--function)
;;;; 2. vc.el (vc-root-dir)
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
;;;; 3. locate-dominating-file
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
;;;; 4. projectile.el (projectile-project-root)
;; (autoload 'projectile-project-root "projectile")
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
;;;; 5. No project support
;; (setq consult-project-function nil)
)
What I need to do?
https://redd.it/1ekjpgn
@r_emacs
How to read exported Google Contacts using Emacs?
I exported my Google Contacts manually (from https://contacts.google.com/) to csv and vcf.
How can I read them easily using Emacs?
By reading I mean being able to browse them on an org file (e.g. org-contact) or a contact manager (e.g. EBDB).
https://redd.it/1ekhqs8
@r_emacs
beancount-txn-elisp
https://sr.ht/~trs-80/beancount-txn-elisp/
https://redd.it/1ek0m5w
@r_emacs
Mg
what are your thoughts about mg https://linux.die.net/man/1/mg ?
I am tinkering with the github repo to make it a little bit more customized for my needs but other than that I praise its puristic and minimalistic ways. Its written in c and works smoothly over ssh (without tramp or sth.)
https://redd.it/1ek1ic2
@r_emacs
Rustic: Enhanced Org Babel integration
https://psibi.in/posts/2024-08-04-rustic-babel.html
https://redd.it/1ejqrfk
@r_emacs
Trouble with consult and maybe projectile in Emacs 27.1
I mostly run Emacs 29.4 (from source) but on some machines I run Emacs 28.2 (Debian 12) and Emacs 27.1 (Debian 11). I've recently started seeing errors on Emacs 27.1 with consult-buffer
and consult-ripgrep
among others in Git repositories:
No applicable method: project-roots, (projectile . "/full/path/to/git/root")
and the commands no longer work. I don't see these errors in newer Emacs versions.
Am I out of luck trying to run modern packages on Emacs 27 or is it possible that I've got something configured incorrectly?
Thanks.
projectile 20240212.1100
consult 20240725.508
consult-lsp 20240507.2105
https://redd.it/1ejc0uu
@r_emacs
Which notify package for org-mode agenda you can recommend
I want to have system notifications from my org-agenda, which can working without turn on emacs. Which package you can recommend for it?
https://redd.it/1ej5gaq
@r_emacs
Org-mode notifications when emacs works and doesn't work
I use org-agenda mostly for repeating tasks, which is scheduled. I want to have notifications for these tasks, but I don't run emacs always. I don't really sure that mostly of packages, which provides this feature, can working like daemon and sending me notifications, when emacs turn off. What I can do and which extension I must to use?
https://redd.it/1eizr1x
@r_emacs
Easily persist and restore your Emacs editing sessions with easysession.el
https://github.com/jamescherti/easysession.el
https://redd.it/1eilz20
@r_emacs
I'm having troubles with setting up LSP for haskell
Hi, so far I have written the following configuration for lsp, but emacs is telling me that `lsp-haskell-server-path` is a free variable, but when I try to manually install lsp-haskell with `(use-package lsp-haskell :ensure t :config lsp-haskell-server-path "<path to the wrapper>")` if I open a haskell file there's no error (I don't know how I solved a previous error in which lsp would tell me there's no server for the haskell major mode) except for an lsp-ui thing, but lsp doesn't seem to be working (there's no completion even for functions that are in the standard library/modules). Am I missing something?
;; use-package set up
(defmacro append-to-list (target suffix)Append SUFFIX to TARGET in place."
`(setq ,target (append ,target ,suffix)))
(require 'package)
(append-to-list package-archives '(("melpa" . "http://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t
use-package-expand-minimally t))
(eval-when-compile
(require 'use-package))
;; LSP
(use-package haskell-mode
:ensure t
:hook (haskell-mode . interactive-haskell-mode))
(use-package lsp-mode
:ensure t
:commands (lsp lsp-deferred)
:hook ((c++-mode . lsp-deferred)
(haskell-mode . lsp-deferred))
:config
(setq lsp-keymap-prefix "C-c l")
(setq lsp-prefer-flymake nil))
(use-package lsp-haskell
:ensure t
:config
(setq lsp-haskell-server-path "~/.ghcup/hls/2.7.0.0/bin/haskell-language-server-wrapper")
(setq lsp-haskell-server-args '()))
https://redd.it/1ei8f5s
@r_emacs
eglot and TRAMP language server config - looking for help
Trying to start pylsp for both local edits, and via TRAMP. The code below in init.el. Commenting out between each of the 3 options does this:
1. Successfully starts and connects to a remote pylsp when TRAMP editing a remote file.
2. Successfully starts and connects to a local pylsp when editing a local file.
3. Successfully starts and connects to a local pylsp when editing a local file - but is unsuccessful in starting a remote pylsp when TRAMPing a remote file. Exits with error: `(:message "Connection state changed" :change "exited abnormally with code 127\n")`
* Local machine is windows running putty - TRAMP connection /plink:server:/temp/test.py
* Remote machine is FreeBSD 13.2 running sshd and samba.
* "Local" editing (and pylsp) via samba share works, but with pylsp running on the local windows machine and [test.py](http://test.py) on the remote samba share editing is slow and is not optimal.
Any suggestions on having option 3. work for both local and remote pylsp?
Most of the below code comes from [https://www.gnu.org/software/emacs/manual/html\_node/eglot/Setting-Up-LSP-Servers.html](https://www.gnu.org/software/emacs/manual/html_node/eglot/Setting-Up-LSP-Servers.html)
(use-package eglot
:ensure t
:defer t
:hook (python-mode . eglot-ensure)
:config
;; 1.
;; (add-to-list 'eglot-server-programs
;; '(python-mode . ("/server/tracker/bin/pylsp")))
;; 2.
;; (add-to-list 'eglot-server-programs
;; '(python-mode . ("~/.emacs.d/env/bin/pylsp")))
;; 3.
`(python-mode . ,(eglot-alternatives
'(("/server/tracker/bin/pylsp")
("~/.emacs.d/env/bin/pylsp"))))
)
https://redd.it/1ei4hec
@r_emacs
fontawesome encircle)
:order 3
)
)
#+end_src
#+begin_src emacs-lisp
(defun org-export-insert-console-start (_backend)
(when (eq _backend 'latex)
(org-babel-map-src-blocks nil ; nil implies current buffer
(let (;; capture macro-defined variables
(lang lang)
(beg-body beg-body)
(end-body (copy-marker end-body))
;; other variables
(shell-langs '("sh" "shell"))
(suffix "`\\StartConsole`")
(is-contd-from-prev-line nil)) ; t if prev line ends in '\'; nil otherwise
(when (member lang shell-langs)
(goto-char beg-body)
(skip-chars-forward "\n\s" (marker-position end-body)) ; skip initial whitespace and newlines
(while (< (point) (marker-position end-body))
(end-of-line)
(cond
((and is-contd-from-prev-line
(setq is-contd-from-prev-line nil)))
((eq ?\\ (char-after (1- (point)))) ; `1- (point)` is equivalent to `(- (point) 1)`
(insert (concat " " suffix))
(setq is-contd-from-prev-line t))
((and (not is-contd-from-prev-line)
(not (eq (char-after (line-beginning-position)) ?:))) ; Correctly provide the position argument
(insert (concat " " suffix))))
(forward-line 1)
(skip-chars-forward "\n\s" (marker-position end-body))))))))
(add-hook 'org-export-before-parsing-hook #'org-export-insert-console-start)
#+end_src
And so far things transcode to...
\begin{ubuntu}
ls -la /usr/bin/python `\StartConsole`
\end{ubuntu}
\phantomsection
\label{}
\begin{verbatim}
lrwxrwxrwx 1 root root 7 Jun 6 23:33 /usr/bin/python -> python3
\end{verbatim}
when I'd like it to look like...
\begin{ubuntu}
ls -la /usr/bin/python `\StartConsole`
lrwxrwxrwx 1 root root 7 Jun 6 23:33 /usr/bin/python -> python3
\end{ubuntu}
https://redd.it/1ei0k5g
@r_emacs
Need help defining a latex export function that puts the results of evaluation inside the code block listing it came from for shell blocks
I have been messing around with the LaTeX export system and have been able to get my shell blocks to export to latex w/ [this](https://tex.stackexchange.com/a/517985) formatting, including automatically adding the `\StartConsole` command to any first line in a command. It would be nice to have the results and the shell commands joined in the output so that it looks exactly like a command and its output looks like in a terminal. I am not sure how to go about merging them in the latex output though and whether it should be done as pre- or post- processing. Any help figuring this out would be very appreciated. Thank you.
In case anybody is interested, I did this using the org-9.8pre version with its new export features and used the following relevant code...
#+begin_src emacs-lisp
(cl-defun my/org-latex-src-block--listings
(&key src-block info lang caption caption-above-p label num-start retain-labels attributes float &allow-other-keys)
"Transcode a SRC-BLOCK element from Org to LaTeX, using listings.
LANG, CAPTION, CAPTION-ABOVE-P, LABEL, NUM-START, RETAIN-LABELS, ATTRIBUTES
and FLOAT are extracted from SRC-BLOCK and INFO in `org-latex-src-block'."
(let* ((lst-lang
(or (cadr (assq (intern lang)
(plist-get info :latex-listings-langs)))
lang))
(caption-str
(when caption
(let ((main (org-export-get-caption src-block))
(secondary (org-export-get-caption src-block t)))
(if (not secondary)
(format "{%s}" (org-export-data main info))
(format "{[%s]%s}"
(org-export-data secondary info)
(org-export-data main info))))))
(lst-opt (plist-get info :latex-listings-options))
(lst-environment
(cond
((string= (intern lang) "shell")
"\n\\begin{ubuntu}%s\n%s\\end{ubuntu}")
((string= (intern lang) "pseudocode")
"\n\\begin{tcblstalgorithm}[%s]\n%s\\end{tcblstalgorithm}")
(t "\n\\begin{tcblstcode}[%s]\n%s\\end{tcblstcode}")))
(language-icon
(pcase lang
("latex" "\\LaTeX")
("python" "\\faPython")
("bash" "\\faLinux")
("emacs-lisp" "\\scalebox{0.7}{\\circled{$\\varepsilon$}}")
;; ("shell" "\\faLinux")
("js" "\\faJs")
("java" "\\faJava")
("css" "\\faCss3")
("R" "\\faRProject")
("sql" "\\faDatabase")
("sqlite" "\\faDatabase")
("markdown" "\\faMarkdown")
(_ "\\faFileCode"))) ; Default icon for other languages
)
(concat
(format
;; TODO - add more options here
;; "\\begin{lstlisting}[%s]\n%s\\end{lstlisting}"
lst-environment
;; Options.
(concat
(org-latex--make-option-string
(append
lst-opt
(cond
((and (not float) (plist-member attributes :float)) nil)
((string= "multicolumn" float) '(("float" "*")))
((and float (not (assoc "float" lst-opt)))
`(("float" ,(plist-get info :latex-default-figure-position)))))
(unless (or (plist-get info :latex-listings-src-omit-language) (string= lang "pseudocode") (string= lang "shell"))
`(("language" ,lst-lang)))
(when label
`(("label" ,(org-latex--label src-block info))))
(when caption-str
`(("caption" ,caption-str)))
(unless (or (string= lang "pseudocode")
Do you think Meow or Boon is better? Especially if you've used both.
https://redd.it/1ehtgxe
@r_emacs