id
stringlengths
8
14
url
stringlengths
40
58
title
stringlengths
2
150
date_created
stringdate
2008-09-06 22:17:14
2024-03-31 23:12:03
text
stringlengths
149
7.14M
thread-63601
https://emacs.stackexchange.com/questions/63601
slime-call-defun equivalent in sly?
2021-02-25T20:41:15.470
# Question Title: slime-call-defun equivalent in sly? `Slime` defines two commands: `slime-call-defun` and `slime-eval-last-expression-in-repl` which take the function name of where point is (or whatever) and copy it over to the REPL prompt and position point accordingly. Is there such a functionality for `Sly` and how do I use it? If not, is there some openly available elisp code, which I could use to achieve this? If there is no such functionality available, which workflow is intended? # Answer > 1 votes Since no one answered, I've done a naive implementation. This is a community wiki answer in hope, the implementation evolves over time. ``` (defun my-sly-copy-call-to-repl () "Copy name/symbol of toplevel sexp to sly-mREPL and select sly-mREPL." (interactive) (let (string replwin) (save-excursion (beginning-of-defun) (forward-thing 'symbol 2) (setq string (format "(%s )" (thing-at-point 'symbol 'no-props)))) (setq replwin (get-buffer-window (call-interactively #'sly-mrepl))) (with-selected-window replwin (insert string) (forward-char -1)))) ``` --- Tags: slime, sly ---
thread-63737
https://emacs.stackexchange.com/questions/63737
C-x C-f TAB TAB: Find file completion list: how to highlight subdirectories?
2021-03-04T18:29:49.437
# Question Title: C-x C-f TAB TAB: Find file completion list: how to highlight subdirectories? Often I'd like to open a file in a subdirectory. But poor me, I can't remember the name. So when typing `C-x C-f` and then `TAB TAB` for the completion list, the list of all files in this directory is listed, *including* the subdirectories, which are only marked by a `/` at the end. Any idea how to highlight the subdirectories in this buffer `*Completions*` or to sort the completion list `directories first`? # Answer > 1 votes If you use Icicles then: * Directory candidates are highlighted in `*Completions*`. * You can change the sort order for candidates any time during completion, using `C-,`. If you customize option `icicle-file-sort` to the function `icicle-dirs-first-p` then directory candidates are sorted first: `M-x customize-option RET icicle-file-sort`. --- Tags: completion, find-file, sorting, directories, icicles ---
thread-63661
https://emacs.stackexchange.com/questions/63661
Magit status section with recent checkouts / visited branches?
2021-03-01T10:56:55.470
# Question Title: Magit status section with recent checkouts / visited branches? In the same fashion magit can offer the list of recent commits in a section of status buffer. I'd like to have a list of recent checkout/visited branches to be able to quickly switch to it (`M-x``b``b`). One of current patterns I have is : * work on my topic branch * find a bug unrelated to my topic * switch to master and pull latest * create a spinoff branch from master (checkout -b ) * fix bug * push & pull-request * go back to my topic branch For last step I have to remember the name of my branch ; which is not handy for me. # Answer > 1 votes I experimented with this feature after digging through `magit` source code. **TO ENABLE** it, as @tarsius, magit maintainer, points out in the comment below, use the function `magit-add-section-hook`. add `exp-feat/magit-insert-recent-branches` to `magit-status-sections-hook` (preferably using `customize` interface since you would like to decide this section location in your `magit-status` buffer). Here it goes (copied lots of stuffs from `magit` source code ): ``` (defvar exp-feat/recent-branches (make-hash-table :test 'equal)) (defcustom exp-feat/recent-branches-limits 3 "Limits" :type 'integer :risky t) (defun exp-feat/magit-insert-recent-branches nil "Insert recent branches" (let* ((dir (magit-toplevel)) (curr-branch (magit-get-current-branch)) (prev-branch (magit-get-previous-branch)) (rbs (--> (gethash dir exp-feat/recent-branches) (nconc (list prev-branch curr-branch) it) (-distinct it) (-filter (lambda (a) (and a (not (equal a curr-branch)))) it)))) (when rbs (when (> (length rbs) exp-feat/recent-branches-limits) (--> (1- exp-feat/recent-branches-limits) (nthcdr it rbs) (setcdr it nil))) (puthash dir rbs exp-feat/recent-branches) (magit-insert-section (rb "rb") (magit-insert-heading "Recent branches") (dolist (it-branch rbs) (let ((output (magit-rev-format "%h %s" it-branch))) (string-match "^\\([^ ]+\\) \\(.*\\)" output) (magit-bind-match-strings (commit summary) output (when (and t (equal summary "")) (setq summary "(no commit message)")) (magit-insert-section (branch it-branch) (insert (propertize commit 'font-lock-face 'magit-hash) ?\s) (insert (propertize it-branch 'font-lock-face 'magit-branch-local) ?\s) (insert (funcall magit-log-format-message-function it-branch summary) ?\n))))))))) ``` --- Tags: magit, git ---
thread-16497
https://emacs.stackexchange.com/questions/16497
How to exclude files from Projectile?
2015-09-10T08:22:38.880
# Question Title: How to exclude files from Projectile? I am using the helm-projectile setup from prelude and it has been a huge improvement to my workflow. The only remaining issue are auto-generated files (e.g. generated by CMake) which show up during helm-grep and similar operations. **Question**: is there a way to exclude files in the projects folder tree from Projectile? # Answer > 50 votes Looking at projectile it seems to offer four customizations for ignoring files/directories globally. I am listing each of them below, with their documentation `projectile-globally-ignored-files` > A list of files globally ignored by projectile. `projectile-globally-ignored-directories` > A list of directories globally ignored by projectile. `projectile-globally-ignored-file-suffixes` > A list of file suffixes globally ignored by projectile. `projectile-globally-ignored-modes` > A list of regular expressions for major modes ignored by projectile. > > If a buffer is using a given major mode, projectile will ignore it for functions working with buffers. Please note that these are global options so for example a directory in `projectile-globally-ignored-directories` will be ignored irrespective of the project you are working with. To ignore a file/directory for a particular project you can add a `.projectile` file to the project's root and add the paths to ignore prefixed with `-` to it like following ``` -/CMake ``` See the documentation of `projectile-parse-dirconfig-file` (or projectile's docs) for more info > Parse project ignore file and return directories to ignore and keep. > > The return value will be a cons, the car being the list of directories to keep, and the cdr being the list of files or directories to ignore. > > Strings **starting with +** will be added to the list of **directories to keep**, and strings **starting with -** will be added to the list of **directories to ignore**. For backward compatibility, **without a** **prefix** the string will be **assumed to be an ignore string**. # Answer > 31 votes Yes, in your `.projectile` file, on each line specify similar to: each line looks like: ``` - /path/to/somefile ``` Each line contains one file path. See the official documentation on ignoring files # Answer > 9 votes Another solution would be to use `ag`(the\_silver\_searcher) or `rg` (ripgrep) to generate project files. Here's how you can do it with `rg`: ``` (setq projectile-enable-caching t) ;;; Default rg arguments ;; https://github.com/BurntSushi/ripgrep (when (executable-find "rg") (progn (defconst modi/rg-arguments `("--line-number" ; line numbers "--smart-case" "--follow" ; follow symlinks "--mmap") ; apply memory map optimization when possible "Default rg arguments used in the functions in `projectile' package.") (defun modi/advice-projectile-use-rg () "Always use `rg' for getting a list of all files in the project." (mapconcat 'identity (append '("\\rg") ; used unaliased version of `rg': \rg modi/rg-arguments '("--null" ; output null separated results, "--files")) ; get file names matching the regex '' (all files) " ")) (advice-add 'projectile-get-ext-command :override #'modi/advice-projectile-use-rg))) ``` In your project directory, specify the files you want to ignore in `.gitignore` and you're good to go :) Code is from kaushalmodi's emacs config. # Answer > 5 votes Check if the variable `projectile-indexing-method` is set to `alien`. If that's the case Projectile will ignore ignores/unignores/sorting provided in Projectile config: > The alien indexing method optimizes to the limit the speed of the hybrid indexing method. This means that Projectile will not do any processing of the files returned by the external commands and you’re going to get the maximum performance possible. This behaviour makes a lot of sense for most people, as they’d typically be putting ignores in their VCS config and won’t care about any additional ignores/unignores/sorting that Projectile might also provide. To solve it change this variable to `native` or `hybrid`. # Answer > 4 votes search that respects ignored dirs/files: 1. install `ack` (An alternative to grep. I install via homebrew.) 2. put `--ignore-case` in your `~.ackrc` file (assuming you want to ignore case) 3. bind `helm-projectile-ack` to a key. I do this in my emacs init via: ``` (use-package helm ... :bind (... ("C-c p s a" . helm-projectile-ack) ) ... ) ``` 4. create a `.projectile` file. E.g., ``` -.dot -.jcs -.svg -.txt ``` use ``` C-c p s a ;; search that respects .projectile ignore ``` or ``` C-c s p g ;; search everything ``` # Answer > 4 votes **A new solution with no speed compromise of `projectile`** Since `projetile-indexing-method` is default set to `alien`, both `projectile-globally-ignored-directories` and `projectile-globally-ignored-files` will not be used. However, choosing `native` indexing method compromises speed performance considerably, especially for large projects. Suppose we prefer `alien` for best performance, there is a way to get both satisfied. The idea is to set `projectile-generic-command` that is used for `alien` type indexing. Assume we use `ripgrep` (terminal command `rg`), we can add arguments to `rg` to ignore folders/files as you prefer, * ignoring folder by option `--glob` with folders read from `projectile-globally-ignored-directories` that you set; * ignoring files by option `--ignore-file`. However, this option specifies a file that lists all files to be ignored. The easy way is to create a global file (e.g., in `~/.emacs.d/`) and list there all files that you like to put to `projectile-globally-ignored-files`. For example, we set a file name `~/.emacs.d/rg_ignore`. The whole setup as an example is given below: ``` ;; Due to "alien" indexing method, globally ignore folders/files by ;; re-defining "rg" args (mapc (lambda (item) (add-to-list 'projectile-globally-ignored-directories item)) '("Backup" "backup" "auto" "archived")) ;; files to be ignored should be listed in "~/.emacs.d/rg_ignore" ;; Use the faster searcher to handle project files: ripgrep "rg" (when (and (not (executable-find "fd")) (executable-find "rg")) (setq projectile-generic-command (let ((rg-cmd "")) (dolist (dir projectile-globally-ignored-directories) (setq rg-cmd (format "%s --glob '!%s'" rg-cmd dir))) (setq rg-ignorefile (concat "--ignore-file" " " (expand-file-name "rg_ignore" user-emacs-directory))) (concat "rg -0 --files --color=never --hidden" rg-cmd " " rg-ignorefile)))) ``` --- Tags: projectile ---
thread-63718
https://emacs.stackexchange.com/questions/63718
orgmode - do not export example block
2021-03-03T22:20:13.760
# Question Title: orgmode - do not export example block I try to use a example block as input to babel block, I want to export babel results only, in below example, I try to add exports none to example block but it doesn't work, the example content exported to html page as well. How can I disable example block export? ``` * example #+name: input #+begin_example :exports none 5 1 3 2 0 #+end_example #+begin_src python :results output :eval yes :var x=input :exports results import matplotlib.pyplot as plt import numpy as np x = np.array(x.split()) x = x.astype(int) fig,ax = plt.subplots() ax.plot(x) plt.savefig("test.png") #+end_src #+RESULTS: [[./test.png]] ``` # Answer > 3 votes You could put the example in a separate section and tag it `noexport`: ``` * example input :noexport: #+name: input #+begin_example 5 1 3 2 0 #+end_example * example code #+begin_src python :results output :eval yes :var x=input :exports results import matplotlib.pyplot as plt import numpy as np x = np.array(x.split()) x = x.astype(int) fig,ax = plt.subplots() ax.plot(x) plt.savefig("./test.png") #+end_src #+RESULTS: [[file:./test.png]] ``` BTW, the way that you have your headers does not really work to produce a result: the code block produces no output on its stdout so `:results output` makes it produce an empty result. The output file is a *side effect* of the code block execution, so Org mode (and babel) don't know anything about it. Did you add the result by hand? A better way to do that is to use the following header line instead: ``` #+begin_src python :results file link :file test.png :eval yes :var x=input :exports results ... ``` That tells babel to produce a link to a file named `test.png`, but babel does not create the file: it expects the code block to produce it. See e.g. this Emacs SE question for more details. # Answer > 3 votes What I do for cases like this, where I do not want the input to some src block exported, is put the input (the example block in your case) in a drawer and set the option d:nil so as to not export drawers. ``` * example :input: #+name: input #+begin_example 5 1 3 2 0 #+end_example :end: ``` # Answer > 1 votes I don't think org offers any way to exclude example blocks from exporting. A possible work-around: if you don't want the example to show up in your export, does it need to be an example? You could make it a bash code block instead: ``` * example #+name: input #+begin_src bash :exports none echo 5 1 3 2 0 #+end_src #+begin_src python :results output :eval yes :var x=input :exports results import matplotlib.pyplot as plt import numpy as np x = np.array(x.split()) x = x.astype(int) fig,ax = plt.subplots() ax.plot(x) plt.savefig("test.png") #+end_src ``` --- Tags: org-mode, org-export, org-babel ---
thread-63746
https://emacs.stackexchange.com/questions/63746
How to make emacs shell the same as system terminal experience?
2021-03-05T13:52:18.743
# Question Title: How to make emacs shell the same as system terminal experience? On macOS, using iTerm2. It looks like In Emacs For Mac OS X, it looks like I copied system's **~/.zshrc** file to **~/.profile** and **~/.bash\_profile**, but doesn't they read configrations when start emacs? # Answer One possibility is to use term.el > M-x term `term` is a full-featured terminal emulator, within which you can run your OS preferred shell, meaning that terminal escape characters will be handled in input and output generally (including your prompt). The main complication is that some keybindings conflict with emacs bindings, and so there are two modes of input depending on whether you want keys to behave more like a terminal ("char mode") or more like Emacs ("line mode"). See the manual for more about this: * `C-h``i``g` `(emacs)Terminal emulator` * `C-h``i``g` `(emacs)Term Mode` > 1 votes --- Tags: shell, fonts, doom, environment, icons ---
thread-63650
https://emacs.stackexchange.com/questions/63650
Calendar holidays errors
2021-02-28T22:51:28.307
# Question Title: Calendar holidays errors After updating all the packages and switched to Emacs HEAD the holidays config I used to use now generate errors on Emacs start. Config: ``` (setq general-holidays '((holiday-fixed 1 1 "New Year's Day") (holiday-fixed 2 14 "Valentine's Day") (holiday-fixed 3 8 "International Women's Day") (holiday-fixed 3 17 "St. Patrick's Day") (holiday-fixed 4 1 "April Fools' Day") (holiday-float 5 0 2 "Mother's Day") (holiday-fixed 10 31 "Halloween") (holiday-float 11 4 4 "Thanksgiving")) polish-holidays '((holiday-fixed 1 21 "Dzień Babci") (holiday-fixed 1 22 "Dzień Diadka") (holiday-fixed 2 22 "Ofiarowanie Pańskie (Matki Boskiej Gromnicznej)") (holiday-fixed 2 8 "Tłusty Czwartek") (holiday-fixed 2 10 "Ostatnia Sobota Karnawału") (holiday-fixed 2 13 "Ostatki") (holiday-fixed 3 1 "Narodowy Dzień Pamięci Żołnierzy Wyklętych") (holiday-fixed 3 10 "Dzień Mężczyzn") (holiday-fixed 3 20 "Początek Astronomicznej Wiosny") (holiday-fixed 3 25 "Zmiana czasu z zimowego na letni") (holiday-fixed 3 25 "Niedziela Palmowa") (holiday-fixed 3 29 "Wielki Czwartek") (holiday-fixed 3 30 "Wielki Piątek") (holiday-fixed 3 31 "Wielka Sobota") (holiday-fixed 4 2 "(bank) Poniedziałek Wielkanocny") (holiday-fixed 4 8 "Święto Bożego Miłosierdzia") (holiday-fixed 4 22 "Międzynarodowy Dzień Ziemi") (holiday-fixed 5 1 "(bank) Międzynarodowe Święto Pracy") (holiday-fixed 5 2 "Dzień Flagi Rzeczypospolitej Polskiej") (holiday-fixed 5 3 "(bank) Święto Konstytucji 3 Maja") (holiday-fixed 5 13 "Wniebowstąpienie") (holiday-fixed 5 20 "(bank) Zesłanie Ducha Świętego (Zielone Świątki)") (holiday-fixed 5 26 "Dzień Matki") (holiday-fixed 5 31 "(bank) Boże Ciało") (holiday-fixed 6 1 "Międzynarodowy Dzień Dziecka") (holiday-fixed 6 21 "Pierwszy Dzień Lata (najdłuższy dzień roku)") (holiday-fixed 6 23 "Dzień Ojca") (holiday-fixed 8 1 "Narodowy Dzień Pamięci Powstania Warszawskiego") (holiday-fixed 8 15 "(bank) Święto Wojska Polskiego") (holiday-fixed 8 15 "Wniebowzięcie Najświętrzej Maryi Panny") (holiday-fixed 8 31 "Dzień Solidarności i Wolności") (holiday-fixed 9 23 "Początek Astronomicznej Jesieni") (holiday-fixed 9 30 "Dzień Chłopaka") (holiday-fixed 10 14 "Dzień Nauczyciela (Dzień Edukacji Narodowej)") (holiday-fixed 10 28 "Zmiana czasu z letniego na zimowy") (holiday-fixed 11 1 "(bank) Wszystkich Świętych") (holiday-fixed 11 2 "Dzień Zaduszny") (holiday-fixed 11 11 "(bank) Narodowe Święto Niepodległości") (holiday-fixed 11 29 "Andrzejki") (holiday-fixed 12 4 "Barbórka (Dzień górnika, naftowca i gazownika)") (holiday-fixed 12 6 "Dzień św. Mikołaja") (holiday-fixed 12 21 "Początek Astronomicznej Zimy") (holiday-fixed 12 24 "Wigilia Bożego Narodzenia") (holiday-fixed 12 25 "(bank) Boże Narodzenie (1 dzień)") (holiday-fixed 12 26 "(bank) Boże Narodzenie (2 dzień)")) english-holidays '((holiday-fixed 3 30 "(bank) Good Friday") (holiday-fixed 4 10 "(bank) Good Friday (England, Wales)") (holiday-fixed 4 13 "(bank) Easter Monday (England, Wales)") (holiday-fixed 5 8 "(bank) Early May bank holiday (England, Wales)") (holiday-fixed 5 7 "(bank) Spring bank holiday (England, Wales)") (holiday-fixed 8 27 "(bank) Spring bank holiday") (holiday-fixed 9 31 "(bank) Summer bank holiday") (holiday-fixed 12 25 "(bank) Christmas Day") (holiday-fixed 12 28 "(bank) Boxing Day")) christian-holidays '((holiday-fixed 1 6 "Epiphany") (holiday-fixed 2 2 "Candlemas") (holiday-easter-etc -47 "Mardi Gras") (holiday-easter-etc 0 "Easter Day") (holiday-easter-etc 1 "Easter Monday") (holiday-easter-etc 39 "Ascension") (holiday-easter-etc 49 "Pentecost") (holiday-fixed 8 15 "Assumption") (holiday-fixed 11 1 "All Saints' Day") (holiday-fixed 11 2 "Day of the Dead") (holiday-fixed 11 22 "Saint Cecilia's Day") (holiday-fixed 12 1 "Saint Eloi's Day") (holiday-fixed 12 4 "Saint Barbara") (holiday-fixed 12 6 "Saint Nicholas Day") (holiday-fixed 12 25 "Christmas Day"))) (use-package japanese-holidays) (setq holiday-local-holidays nil calendar-christian-all-holidays-flag t calendar-holidays (list japanese-holidays polish-holidays english-holidays general-holidays holiday-christian-holidays holiday-solar-holidays) calendar-week-start-day 1 calendar-date-style 'european)) ``` Errors: ``` Error (holidays): Bad holiday list item: ((japanese-holiday-range (holiday-fixed 1 3 元始祭) '(10 14 1873) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 1 5 新年宴会) '(10 14 1873) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 1 30 孝明天皇祭) '(10 14 1873) '(9 3 1912)) (japanese-holiday-range (holiday-fixed 2 11 紀元節) '(10 14 1873) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 4 3 神武天皇祭) '(10 14 1873) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 9 17 神嘗祭) '(10 14 1873) '(7 5 1879)) (japanese-holiday-range (holiday-fixed 11 3 天長節) '(10 14 1873) '(9 3 1912)) (japanese-holiday-range (holiday-fixed 11 23 新嘗祭) '(10 14 1873) '(7 20 1948)) (let* ((equinox (solar-equinoxes/solstices 0 displayed-year)) (m (calendar-extract-month equinox)) (d (truncate (calendar-extract-day equinox)))) (japanese-holiday-range (holiday-fixed m d 春季皇霊祭) '(6 5 1878) '(7 20 1948))) (let* ((equinox (solar-equinoxes/solstices 2 displayed-year)) (m (calendar-extract-month equinox)) (d (truncate (calendar-extract-day equinox)))) (japanese-holiday-range (holiday-fixed m d 秋季皇霊祭) '(6 5 1878) '(7 20 1948))) (japanese-holiday-range (holiday-fixed 10 17 神嘗祭) '(7 5 1879) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 7 30 明治天皇祭) '(9 3 1912) '(3 3 1927)) (japanese-holiday-range (holiday-fixed 8 31 天長節) '(9 3 1912) '(3 3 1927)) (japanese-holiday-range (holiday-fixed 10 31 天長節祝日) '(10 31 1913) '(3 3 1927)) (japanese-holiday-range (holiday-fixed 4 29 天長節) '(3 3 1927) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 11 3 明治節) '(3 3 1927) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 12 25 大正天皇祭) '(3 3 1927) '(7 20 1948)) (japanese-holiday-national (japanese-holiday-substitute (nconc (japanese-holiday-range (holiday-fixed 1 1 元日) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 1 15 成人の日) '(7 20 1947) '(1 1 2000)) (let* ((equinox (solar-equinoxes/solstices 0 displayed-year)) (m (calendar-extract-month equinox)) (d (truncate (calendar-extract-day equinox)))) (japanese-holiday-range (holiday-fixed m d 春分の日) '(7 20 1948))) (japanese-holiday-range (holiday-fixed 4 29 天皇誕生日) '(7 20 1948) '(2 17 1989)) (japanese-holiday-range (holiday-fixed 5 3 憲法記念日) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 5 5 こどもの日) '(7 20 1948)) (let* ((equinox (solar-equinoxes/solstices 2 displayed-year)) (m (calendar-extract-month equinox)) (d (truncate (calendar-extract-day equinox)))) (japanese-holiday-range (holiday-fixed m d 秋分の日) '(7 20 1948))) (japanese-holiday-range (holiday-fixed 11 3 文化の日) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 11 23 勤労感謝の日) '(7 20 1948)) (japanese-holiday-range (holiday-fixed 2 11 建国記念の日) '(6 25 1966)) (japanese-holiday-range (holiday-fixed 9 15 敬老の日) '(6 25 1966) '(1 1 2003)) (japanese-holiday-range (holiday-fixed 10 10 体育の日) '(6 25 1966) '(1 1 2000)) (japanese-holiday-range (holiday-fixed 4 29 みどりの日) '(2 17 1989) '(1 1 2007)) (japanese-holiday-range (holiday-fixed 12 23 天皇誕生日) '(2 17 1989) '(5 1 2019)) (japanese-holiday-range (holiday-fixed 7 20 海の日) '(1 1 1996) '(1 1 2003)) (japanese-holiday-range (holiday-float 1 1 2 成人の日) '(1 1 2000)) (japanese-holiday-range (holiday-float 10 1 2 体育の日) '(1 1 2000) '(1 1 2020)) (japanese-holiday-range (holiday-float 7 1 3 海の日) '(1 1 2003) '(1 1 2020)) (japanese-holiday-range (holiday-float 7 1 3 海の日) '(1 1 2022)) (japanese-holiday-range (holiday-float 9 1 3 敬老の日) '(1 1 2003)) (japanese-holiday-range (holiday-fixed 4 29 昭和の日) '(1 1 2007)) (japanese-holiday-range (holiday-fixed 5 4 みどりの日) '(1 1 2007)) (japanese-holiday-range (holiday-fixed 8 11 山の日) '(1 1 2016) '(1 1 2020)) (japanese-holiday-range (holiday-fixed 8 11 山の日) '(1 1 2022)) (japanese-holiday-range (holiday-fixed 2 23 天皇誕生日) '(5 1 2019)) (japanese-holiday-range (holiday-fixed 5 1 即位の日) '(12 14 2018) '(1 1 2020)) (japanese-holiday-range (holiday-fixed 10 22 即位礼正殿の儀) '(12 14 2018) '(1 1 2020)) (japanese-holiday-range (holiday-fixed 7 23 海の日) '(1 1 2020) '(1 1 2021)) (japanese-holiday-range (holiday-fixed 7 24 スポーツの日) '(1 1 2020) '(1 1 2021)) (japanese-holiday-range (holiday-fixed 8 10 山の日) '(1 1 2020) '(1 1 2021)) (japanese-holiday-range (holiday-float 10 1 2 スポーツの日) '(1 1 2022)) (japanese-holiday-range (holiday-fixed 7 22 海の日) '(1 1 2021) '(1 1 2022)) (japanese-holiday-range (holiday-fixed 7 23 スポーツの日) '(1 1 2021) '(1 1 2022)) (japanese-holiday-range (holiday-fixed 8 8 山の日) '(1 1 2021) '(1 1 2022))))) (holiday-filter-visible-calendar '(((4 10 1959) 明仁親王の結婚の儀) ((2 24 1989) 昭和天皇の大喪の礼) ((11 12 1990) 即位礼正殿の儀) ((6 9 1993) 徳仁親王の結婚の儀)))) Error: (invalid-function (japanese-holiday-range (holiday-fixed 1 3 元始祭) '(10 14 1873) '(7 20 1948))) Disable showing Disable logging Error (holidays): Bad holiday list item: ((holiday-fixed 1 21 Dzień Babci) (holiday-fixed 1 22 Dzień Diadka) (holiday-fixed 2 22 Ofiarowanie Pańskie (Matki Boskiej Gromnicznej)) (holiday-fixed 2 8 Tłusty Czwartek) (holiday-fixed 2 10 Ostatnia Sobota Karnawału) (holiday-fixed 2 13 Ostatki) (holiday-fixed 3 1 Narodowy Dzień Pamięci Żołnierzy Wyklętych) (holiday-fixed 3 10 Dzień Mężczyzn) (holiday-fixed 3 20 Początek Astronomicznej Wiosny) (holiday-fixed 3 25 Zmiana czasu z zimowego na letni) (holiday-fixed 3 25 Niedziela Palmowa) (holiday-fixed 3 29 Wielki Czwartek) (holiday-fixed 3 30 Wielki Piątek) (holiday-fixed 3 31 Wielka Sobota) (holiday-fixed 4 2 (bank) Poniedziałek Wielkanocny) (holiday-fixed 4 8 Święto Bożego Miłosierdzia) (holiday-fixed 4 22 Międzynarodowy Dzień Ziemi) (holiday-fixed 5 1 (bank) Międzynarodowe Święto Pracy) (holiday-fixed 5 2 Dzień Flagi Rzeczypospolitej Polskiej) (holiday-fixed 5 3 (bank) Święto Konstytucji 3 Maja) (holiday-fixed 5 13 Wniebowstąpienie) (holiday-fixed 5 20 (bank) Zesłanie Ducha Świętego (Zielone Świątki)) (holiday-fixed 5 26 Dzień Matki) (holiday-fixed 5 31 (bank) Boże Ciało) (holiday-fixed 6 1 Międzynarodowy Dzień Dziecka) (holiday-fixed 6 21 Pierwszy Dzień Lata (najdłuższy dzień roku)) (holiday-fixed 6 23 Dzień Ojca) (holiday-fixed 8 1 Narodowy Dzień Pamięci Powstania Warszawskiego) (holiday-fixed 8 15 (bank) Święto Wojska Polskiego) (holiday-fixed 8 15 Wniebowzięcie Najświętrzej Maryi Panny) (holiday-fixed 8 31 Dzień Solidarności i Wolności) (holiday-fixed 9 23 Początek Astronomicznej Jesieni) (holiday-fixed 9 30 Dzień Chłopaka) (holiday-fixed 10 14 Dzień Nauczyciela (Dzień Edukacji Narodowej)) (holiday-fixed 10 28 Zmiana czasu z letniego na zimowy) (holiday-fixed 11 1 (bank) Wszystkich Świętych) (holiday-fixed 11 2 Dzień Zaduszny) (holiday-fixed 11 11 (bank) Narodowe Święto Niepodległości) (holiday-fixed 11 29 Andrzejki) (holiday-fixed 12 4 Barbórka (Dzień górnika, naftowca i gazownika)) (holiday-fixed 12 6 Dzień św. Mikołaja) (holiday-fixed 12 21 Początek Astronomicznej Zimy) (holiday-fixed 12 24 Wigilia Bożego Narodzenia) (holiday-fixed 12 25 (bank) Boże Narodzenie (1 dzień)) (holiday-fixed 12 26 (bank) Boże Narodzenie (2 dzień))) Error: (invalid-function (holiday-fixed 1 21 Dzień Babci)) Disable showing Disable logging Error (holidays): Bad holiday list item: ((holiday-fixed 3 30 (bank) Good Friday) (holiday-fixed 4 10 (bank) Good Friday (England, Wales)) (holiday-fixed 4 13 (bank) Easter Monday (England, Wales)) (holiday-fixed 5 8 (bank) Early May bank holiday (England, Wales)) (holiday-fixed 5 7 (bank) Spring bank holiday (England, Wales)) (holiday-fixed 8 27 (bank) Spring bank holiday) (holiday-fixed 9 31 (bank) Summer bank holiday) (holiday-fixed 12 25 (bank) Christmas Day) (holiday-fixed 12 28 (bank) Boxing Day)) Error: (invalid-function (holiday-fixed 3 30 (bank) Good Friday)) Disable showing Disable logging Error (holidays): Bad holiday list item: ((holiday-fixed 1 1 New Year's Day) (holiday-fixed 2 14 Valentine's Day) (holiday-fixed 3 8 International Women's Day) (holiday-fixed 3 17 St. Patrick's Day) (holiday-fixed 4 1 April Fools' Day) (holiday-float 5 0 2 Mother's Day) (holiday-fixed 10 31 Halloween) (holiday-float 11 4 4 Thanksgiving)) Error: (invalid-function (holiday-fixed 1 1 New Year's Day)) Disable showing Disable logging Error (holidays): Bad holiday list item: ((holiday-easter-etc) (holiday-fixed 12 25 Christmas) (if calendar-christian-all-holidays-flag (append (holiday-fixed 1 6 Epiphany) (holiday-julian 12 25 Christmas (Julian calendar)) (holiday-greek-orthodox-easter) (holiday-fixed 8 15 Assumption) (holiday-advent 0 Advent)))) Error: (invalid-function (holiday-easter-etc)) Disable showing Disable logging Error (holidays): Bad holiday list item: ((solar-equinoxes-solstices) (holiday-sexp calendar-daylight-savings-starts (format Daylight Saving Time Begins %s (solar-time-string (/ calendar-daylight-savings-starts-time (float 60)) calendar-standard-time-zone-name))) (holiday-sexp calendar-daylight-savings-ends (format Daylight Saving Time Ends %s (solar-time-string (/ calendar-daylight-savings-ends-time (float 60)) calendar-daylight-time-zone-name)))) Error: (invalid-function (solar-equinoxes-solstices)) Disable showing Disable logging ``` Any ideas? # Answer > 0 votes The issue was sorted thanks to the amazing Emacs support. The problem lies in the way `calendar-holidays` was set. The correct way should be: ``` (setq calendar-holidays (append calendar-holidays japanese-holidays polish-holidays english-holidays general-holidays holiday-christian-holidays holiday-solar-holidays)) ``` --- Tags: calendar ---
thread-14781
https://emacs.stackexchange.com/questions/14781
How can I replicate Vim's code folding?
2015-08-15T20:43:13.517
# Question Title: How can I replicate Vim's code folding? # Code folding in Emacs Sometimes I want to fold a block of text. In Vim you have easy folding without fuzz. Without to add any special characters like "markers" or specific regex like `{{{`. I would like to select a region and fold it, without messing with the structure. When looking around, it seems there were already questions about code folding in Emacs. Someone said that there was "no perfect solution". For example, I created a clip of simple codefolding in Vim: ## Vim plain folding **\+ Fairly simple, select a region and fold it.<br>\+ It's persistent. When you kill the buffer/close Vim. And reopen the file, the folds are still there.<br>\+ You get a highlight bar, to easily see what's folded.** There are many other folding configurations for Vim. I'm happy with Emacs, but this is one thing that I miss. Other alternatives that I tried, for example HideShow: ## HideShow Evil's alternative with `hide-show minor mode`. I found it unusable: **\- I'm not able to select a region and folding it. It folds on code blocks.** **\- There's no higlihgting bar or something, to attend you it's folded. You could easily miss it.** **\- It's not persistent. If you reopen the file, the folds are gone.** There is another package, Fold this: ## Fold this **\- It's a pretty alternative. However, it mess with the indentation, because the text under the fold gets placed next to the fold... (?).** **\- It's able to just visually select the region and fold it. But it breaks the indendation, so the overview gets messed up. Not very handy.** **\- There is no higlihgting bar or something, to attend you it's folded. You could easily miss it.** ## What's the issue? I would like to replicate how Vim does folding. But when I searched around, it seems it's very hard to do that in Emacs. So I wonder if there something in emacs or its architecture that makes it difficult to replicate this? What are the limits? # Answer Try out `vimish-fold`. ## Features * batteries included: activate minor mode, bind a couple of commands and everything will just work; * it works on regions you select; * it's persistent: when you close file your folds don't disappear; * in addition to being persistent, it scales well, you can work on hundreds of files with lots of folds without adverse effects; * it's obvious which parts of text are folded; * it doesn't break indentation or something; * it can refold just unfolded folds (oh, my); * for fans of `avy` package: you can use `avy` to fold text with minimal number of key strokes! ## Usage Create binding for some of/all these functions: * `vimish-fold` — basic folding of selected region; * `vimish-fold-unfold` — you don't really need to bind this, just use `C-g` when point is placed on header representing folded text; * `vimish-fold-unfold-all` — nevertheless this may be useful; * `vimish-fold-refold` — yes, you can fold it back; * `vimish-fold-avy` — use `avy` to fold your text! You can turn `vimish-fold-mode` selectively for modes where you want to have persistent folding, or simply activate it everywhere: ``` (vimish-fold-global-mode 1) ``` > 20 votes # Answer I like and use `vimish-fold` with `evil-vimish-fold` (and `avy`): ``` ;; Optional use of avy (use-package avy :bind ("C-c J" . avy-goto-line) :commands avy-goto-line :init (setq-default ;; the unpredictability of this (when enabled) makes it a poor default avy-single-candidate-jump nil avy-background nil avy-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l) avy-style 'at-full)) ;; This does the heavy lifting (use-package vimish-fold :after evil) ;; This gives us evil integration, i.e., key bindings (use-package evil-vimish-fold :after evil vimish-fold :init (setq evil-vimish-fold-target-modes '(prog-mode markdown-mode conf-mode text-mode)) :config (evil-vimish-fold-mode 1)) ``` If you use `package.el` to get your packages then you can add an ``` :ensure ``` form to the `use-package` form. Adjust the `evil-vimish-fold-target-modes` to include any that you wish to use folding in. Note that `prog-mode` is the parent mode of most programming modes, so it is sort of a catch all. Note that this will give you many of the usual vim folding key bindings. Here are some that I use often: `z f` Create a fold after first highlighting a region (or use a prefix count like vim). `z o` Open existing fold at point. `z d` Delete an existing fold. `z R` Open all folds in the buffer. `z c` Close existing fold at point. `z j` Next fold. `z k` Previous fold. Etc. As Mark Karpov, the creator of `vimish-fold`, mentioned in his answer, you can use `M-x vimish-fold-avy` which will fold everything between point and the location you choose via the `avy` interface that it presents. An example of using a count prefix would be: `4 z f f` to create a fold from point to 4 lines down. > 2 votes # Answer I wrote foldout.el years ago, so if your file can be “outlined” then it can be folded without needing additional markers. > 1 votes --- Tags: code-folding ---
thread-33946
https://emacs.stackexchange.com/questions/33946
macOS tab feature breaks Emacs new frame behavior; a simple fix?
2017-07-04T07:00:07.683
# Question Title: macOS tab feature breaks Emacs new frame behavior; a simple fix? Prior to macOS Sierra I would use `C-x 5 2` to create a separate frame which was created in an OS X window so that there were now two windows. This is using the latest EmacsForOSX version straight out of the box. Life was good. I recently switched to macOS Sierra and discovered there is now a different behavior: after `C-x 5 2` the new window is turned into a tab inside the original Emacs frame (macOS window). An invisible frame at that if you are using macOS fullscreen mode. That sort of sucks. Edit: Note that this behavior only exists in full screen mode so if you exit full screen mode C-x 5 2 does the right thing. After playing around with the new macOS tab features I discovered that I could exit fullscreen mode to reveal the tabs and drag a tab out to create a separate Emacs frame. Life is better, however this is a rather clumsy way to get separate frames, for example, placed in each monitor on a dual monitor setup. Is there an easier way to achieve the pre-Sierra Emacs frame behavior in a post-Sierra world? It strikes me that macOS Sierra breaks the legacy Emacs design decision that an Emacs frame can be modeled as an OS X/macOS window, therefore requiring code changes in Emacs to support the new macOS tab feature. Is anyone aware of Emacs development efforts to accept and deal with this? # Answer > 7 votes Matthew Bauer (from the Emacs team provided this answer) > Prior to macOS Sierra, in full screen mode, C-x 5 2 would create the new Emacs frame in a new OS X window. This is actually configurable within macOS settings. To accomplish this go to the menu bar:  → System Preferences... → Dock → Prefer tabs when opening documents and select "Manually". Of course this will change the behavior in other apps when in full screen. fwiw, the Emacs developers are wrestling with a different solution but whatever that may be will not likely be available for months. # Answer > 1 votes Since does not always make sense for the default behavior of Preview and Emacs to match, the following lines in `~/.emacs.d/init.el` will prevent tabs from being created. ``` (setq mac-frame-tabbing nil) ``` There are also `mac-move-tab-to-new-frame` and other `mac-...` functions that deal with native tabs. --- Tags: osx, frames ---
thread-63751
https://emacs.stackexchange.com/questions/63751
I can't get the most basic calc-mode gnuplot example to work
2021-03-05T17:59:56.673
# Question Title: I can't get the most basic calc-mode gnuplot example to work I would like to graph functions and datasets from calc-mode. (That's a reasonable thing to do in 2021, right?) Following the directions at Basic Graphics and Vectors as Lists, I started calc-mode, created two vectors, and typed `g f`: ``` --- Emacs Calculator Mode --- 2: [0, 1, 2, 3] 1: [0, 1, 3, 9] . g f ``` No graph is produced. In the `*Gnuplot Trail*` buffer that is created, I can see that I've got gnuplot v5.4 installed. (BTW, TIL that the 'gnu' in 'gnuplot' has nothing to do with 'GNU', How did it come about and why is it called gnuplot?) Also in the trail buffer, there are these error messages: ``` Terminal type is now 'qt' gnuplot> Terminal type is now 'unknown' ^ unknown or ambiguous terminal type; type just 'set terminal' for a list gnuplot> gnuplot> gnuplot> set notime ^ "/var/folders/cj/hmr0n_q91kd7lg4jsqb8w9100000gn/T/calcAkJV7MZ" line 23: Unrecognized option. See 'help unset'. ``` This makes me think I am using too new a version of gnuplot for the version of Calc I have installed. I am running vanilla Emacs 27.1. I couldn't figure out how to get Calc to tell me what version of calc-mode I have installed (including reading the source). Searching `site:emacs.stackexchange.com calc-mode gnuplot` produced nothing of relevance. I have once gotten the contents of various buffers like `*Gnuplot Temp*`, `*Gnuplot Temp-2*`, and `*Gnuplot Commands*`, saved them into independent local files, and run `gnuplot` from the command line and gotten a chart created, but I would like to figure out how to get things to work the normal way. What should I do next? # Answer I've got the same issue here (emacs 27.1 and gnuplot 5.4). Calc is issuing an option which is unknown to gnuplot: `set notime`. This seems to be a bug in calc. Calc is also issuing multiple deprecated commands (it should use `unset` instead of `set no...`), but these only trigger warnings. To work around the unknown option, locate file `calc-graph.el` and edit it. In this file search for the string `set notime\n` and replace it with `set notimestamp\n`. It is at line 354: ``` "set notime\nset border\nset ztics\nset zeroaxis\n" ``` this line needs to state: ``` "set notimestamp\nset border\nset ztics\nset zeroaxis\n" ``` Save the file (maybe compile it) and restart Emacs. Afterwards plotting is working again. **Edit**. this is already fixed in recent version at github.com/emacs-mirror. **Edit2:** NickD posted the link to the fixing commit > 5 votes --- Tags: calc ---
thread-35394
https://emacs.stackexchange.com/questions/35394
disable search in home folder with projectile
2017-09-09T13:27:55.613
# Question Title: disable search in home folder with projectile Sometimes I use dired to navigate in the home folder. If in that moment I press `projectile-find-file`, emacs will freeze and will take about 15 seconds to be ready to use projectile with the home folder. How can I tell projectile not to search in the home folder, even if I accidentally call `projectile-find-file` when I am in? # Answer See a detailed solution in my blog article: https://oracleyue.github.io/post/fix-issues-projectile/ If you like to quickly see how to exclude files/folder from your projectile-find-file, a short version here: https://emacs.stackexchange.com/a/63744/9262 > 2 votes --- Tags: projectile ---
thread-63759
https://emacs.stackexchange.com/questions/63759
void-variable battery-status-function
2021-03-06T05:31:13.423
# Question Title: void-variable battery-status-function I'm trying to set up a custom battery indicator in the mode line and I'd like to use the battery-status-function variable defined in battery.el, which is a part of emacs. However, I cannot use it in any elisp config. I have to search for it using the describe-variable function first before the value is available. For right now, I've gotten around this by setting up a timer that runs 30 seconds after I load emacs (and once a minute afterwards) to use the battery-status-function variable. That gives me 30 seconds to search for it using describe-variable, then the battery indicator shows up in the mode line. The problem exists even in quiet mode and both emacs 26 and 27. 26 is from the official Ubuntu package and 27 is built from source. I'm using Ubuntu 20.04 on an HP Pavillion laptop. I can reproduce this by using eval-expression (M-:) and trying to just evaluate the battery-status-function variable. Before I look it up using describe-variable, it results in an error: ``` Debugger entered--Lisp error: (void-variable battery-status-function) eval(battery-status-function nil) eval-expression(battery-status-function nil nil 127) funcall-interactively(eval-expression battery-status-function nil nil 127) call-interactively(eval-expression nil nil) command-execute(eval-expression) ``` After looking it up, it returns 'battery-linux-sysfs' Has anyone run into a similar problem? What could be causing this? The variable is void until I look up the documentation on it. It's like quantum mechanics. You might be thinking, 'just hard code "battery-linux-sysfs" into the elisp config,' but, of course, the same behavior exists for the battery-linux-sysfs function: ``` Debugger entered--Lisp error: (void-function battery-linux-sysfs) (battery-linux-sysfs) eval((battery-linux-sysfs) nil) eval-expression((battery-linux-sysfs) nil nil 127) funcall-interactively(eval-expression (battery-linux-sysfs) nil nil 127) call-interactively(eval-expression nil nil) command-execute(eval-expression) ``` After looking up documentation on battery-linux-sysfs, evaluating it again returns the information about the battery as expected. # Answer > 0 votes I'm guessing you are missing something very fundamental here. These lines works for me. Please let me know if it works for you. ``` (require 'battery) (funcall battery-status-function) (funcall 'battery-linux-sysfs) ``` **NOTICE** Notice the two `funcall`s here, the argument is with/without `'`, which makes a big difference. Should one delete the `'` in the last line, one would get `void-variable` error like this: ``` Debugger entered--Lisp error: (void-variable battery-linux-sysfs) (funcall battery-linux-sysfs) elisp--eval-last-sexp(nil) #<subr eval-last-sexp>(nil) #f(compiled-function (&rest _it) #<bytecode 0x1f5e73ebdca2>)() eval-sexp-fu-flash-doit-simple(#f(compiled-function (&rest _it) #<bytecode 0x1f5e73ebdca2>) #f(compiled-function (&rest args2) #<bytecode -0x1f1ff2225cb0df3e>) #f(compiled-function (&rest args2) #<bytecode -0x1fdd06e42681df3e>)) eval-sexp-fu-flash-doit(#f(compiled-function (&rest _it) #<bytecode 0x1f5e73ebdca2>) #f(compiled-function (&rest args2) #<bytecode -0x1f1ff2225cb0df3e>) #f(compiled-function (&rest args2) #<bytecode -0x1fdd06e42681df3e>)) esf-flash-doit(#f(compiled-function (&rest _it) #<bytecode 0x1f5e73ebdca2>) #f(compiled-function (&rest args2) #<bytecode -0x1f1ff2225cb0df3e>) #f(compiled-function (&rest args2) #<bytecode -0x1fdd06e42681df3e>) #f(compiled-function (&rest args2) #<bytecode 0xc9c23271d2480c3>)) ad-Advice-eval-last-sexp(#<subr eval-last-sexp> nil) apply(ad-Advice-eval-last-sexp #<subr eval-last-sexp> nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) command-execute(eval-last-sexp) ``` When without quote, the symbol `battery-linux-sysfs` will first be evaluated as a variable (not a function), which is void. This is related to the fact that: an elisp symbol can hold a variable and a function at the same time. Refer to info for more details. --- Tags: debugging ---
thread-63726
https://emacs.stackexchange.com/questions/63726
How to debug Emacs to find out why Emacs doesn't open external browser?
2021-03-04T09:14:43.063
# Question Title: How to debug Emacs to find out why Emacs doesn't open external browser? In Emacs (27.1) on the orgmode when I RET on HTTP link, Emacs doesn't open it on any browser (chromium, firefox, ...). I've set these variable in my spacemacs user config: ``` (setq browse-url-browser-function 'browse-url-default-browser browse-url-generic-program "chromium-browser") (setq org-return-follows-link t) ``` I tried this function, but it didn't work for me: ``` (browse-url "http://www.google.com") ``` How can I debug Emacs to diagnose the problem? # Answer > 2 votes Finally, I found that the call-process doesn't work due to the corrupted .spacemacs.env file. after deletion of this file, it works properly. --- Tags: spacemacs, web-browser ---
thread-63763
https://emacs.stackexchange.com/questions/63763
PSGML conflicts with built-in `sgml-mode`
2021-03-06T10:57:18.117
# Question Title: PSGML conflicts with built-in `sgml-mode` I’ve installed psgml 1.4.0-9 and psgml-html-mode for DTD-aware editing of HTML.\* But the built-in `sgml-mode`/`html-mode` seems to be causing some problems: some tags are highlighted in `font-lock-function-name-face` (as the built-in `sgml-mode` does), some in `font-lock-type-face` (as PSGML does), and they get recoloured depending on what I do (scrolling generally causes `font-lock-type-face` to take over, but the initial screen full of code is in `font-lock-function-name-face`). Most annoyingly, aiui PSGML is supposed to offer SGML-correct indenting taking account of omitted close tags, but afaict `sgml-mode` is taking control of indentation, meaning when I `indent-region` etc, what happens is not DTD-aware. I also have two SGML entries in my menu bar: the first (the one on the left) is from PSGML, the second from `sgml-mode`. Given that `sgml-mode.elc` and `sgml-mode.el.gz` are inside my system Emacs installation (which I am reluctant to go hacking around inside by deleting or changing files), how can I completely disable all their behaviour and everything that they’re loading? * Yes, I’m aware that HTML is not technically an SGML application any more, but the syntax is close enough, and no other HTML editing mode I’m aware of (including `html-mode`, `html-helper-mode`, and the HTML server for `lsp-mode`) is properly aware of implicit close tags in HTML — they think `<p>hello <p>world` creates two nested `p` elements, rather than two consecutive ones. PSGML gets it right. **Edit:** My setup for PSGML etc, if it helps, is here. Everything else needed should also be in the same repo. # Answer `nxml-mode`, which implicitly loads the built-in `sgml-mode` for a small number of things, is loaded before PSGML. This means a number of names get clobbered before PSGML loads and it can’t properly claim them. Loading PSGML before `nxml-mode` fixes the problem since Emacs will think `sgml-mode` is already there when `nxml-mode` loads, but `nxml-mode` will no longer work since the definitions it needs from the built-in `sgml-mode` are no longer there. Solution: Load `sgml-mode-fix`, which defines the features and variables from `sgml-mode` which `nxml-mode` depends on, but no others. Since none of these names clash with PSGML, there should be no problem with using PSGML for HTML/other non-XML SGML files and nXML for XML files. ``` (require 'sgml-mode-fix) (require 'nxml-mode) ;; configure nxml-mode here … ``` > 1 votes --- Tags: indentation, faces, major-mode, html ---
thread-63761
https://emacs.stackexchange.com/questions/63761
org-babel SQL How to use SELECT result single result without data cleanup?
2021-03-06T06:40:37.927
# Question Title: org-babel SQL How to use SELECT result single result without data cleanup? I have quite a few SQL org-babel functions for fetching various(single record) IDs from the database. The snippet below works, but is there any way to skip that middle function that converts SQL result to a simple string? My goal here is to DRY this org-mode/org-babel file. ``` #+name: raw-sql-token #+BEGIN_SRC sql :results value SELECT 123 AS token #+END_SRC #+name: sql-token #+BEGIN_SRC sql :var input=raw-sql-token :results value (print (nth 0(nth 0 input))) #+END_SRC #+HEADER: :var id=sql-token #+BEGIN_SRC http :pretty GET http://localhost:3000/api/items/${id} #+END_SRC ``` # Answer > 1 votes You can use indexing on the result table to select the cell you want: ``` #+HEADER: :var id=raw-sql-token[2,0] #+BEGIN_SRC http :pretty GET http://localhost:3000/api/items/${id} #+END_SRC ``` --- Tags: org-mode, org-babel ---
thread-63742
https://emacs.stackexchange.com/questions/63742
Emacs invokes default system email client when trying to send via MSMTP
2021-03-05T05:33:23.833
# Question Title: Emacs invokes default system email client when trying to send via MSMTP I'm using notmuch message mode in emacs and I'm trying to send a message using msmtp. When I try to send a mail from within emacs it suddenly opens my default system email client, Evolution, and creates the new mail in that, complete with the text that I'd just entered into emacs-notmuch. I want it to just send the mail from within emacs. I know this isn't a problem with msmtp because I can send emails via msmtp from the command line. And when I check my msmtp logs, the attempts to send from emacs aren't there. It isn't getting that far. I wonder if this is a permissions issue of some kind, because in /usr/bin, msmtp shows up with a GID bit set. I am new to GID settings but it seems to be the only file that has it. Can anyone point me in the right direction? Here is the relevant bit of my emacs config: ``` (setq send-mail-function 'sendmail-send-it sendmail-program "/usr/bin/msmtp" mail-specify-envelope-from t mail-envelope-from 'header message-sendmail-envelope-from 'header) ``` # Answer Emacs wasn't talking to msmtp because of an incorrect sendmail definition. Change the correct variable definition on the first line to: ``` (setq message-send-mail-function 'message-send-mail-with-sendmail ``` > 1 votes --- Tags: email, notmuch ---
thread-29546
https://emacs.stackexchange.com/questions/29546
how to get persistent ERC sessions?
2016-12-24T08:58:42.643
# Question Title: how to get persistent ERC sessions? I've a small problem with ERC, if I go away from keyboard for a while, it automatically disconnects the channels I've logged into and when I reopen emacs, it reconnects to the channels automatically. But I do not want this to happen. I want the erc channels to be kept alive even if I'm, away for any period of time. How can I achieve this? ps. I'm on macOS Sierra # Answer As an alternative solution you can use BNC proxy like ZNC. It's a service in the middle between IRC client and networks. It will keep your connection alive so you can connect to it, read the channel history and many other features. You can install it at home or on VPS. I use ZNC and I think it's awesome, and support is great. > 1 votes --- Tags: erc ---
thread-63511
https://emacs.stackexchange.com/questions/63511
Get different RefTeX references for Eq. vs. Equation, Fig. vs. Figure
2021-02-21T17:06:59.230
# Question Title: Get different RefTeX references for Eq. vs. Equation, Fig. vs. Figure When invoking RefTeX to generate LaTeX code for a reference (to an equation, figure) I need a short unbreakable space (LaTeX: `\,`) when the abbreviation is used (`Eq.\,\ref{}, Fig.\,\ref{}`) and a long space (`~`) when the full word is used (`Equation~\ref{}, Figure~\ref{}`). I thought I understood the `reftex-label-alist` and added to my `init.el`: ``` (add-to-list 'reftex-label-alist '("equation" ?e "eq:" "~\\ref{%s}" t (regexp "equations?"))) (add-to-list 'reftex-label-alist '("eq" ?e "eq:" "\\,\\ref{%s}" t (regexp "eqs?\\." "eqn\\."))) ``` i.e. the first line matching "equation(s)" and the second matching "eq(s)", but this always results in a short space. Is there a way to do this, or am I asking for something impossible? # Answer > 1 votes The relevant piece when you make a reference (`\ref`) to a label is the type-indicator, in this case `?e`. You can't have multiple setups around a single type-indicator. In your case, you want to set the value of `reftex-format-ref-function`. The docstring says: > Function which produces the string to insert as a reference. Normally should be nil, because the format to insert a reference can already be specified in `reftex-label-alist`. > > This hook also is used by the special commands to insert e.g. `\vref` and `\fref` references, so even if you set this, your setting will be ignored by the special commands. > > The function will be called with three arguments, the `LABEL`, the `DEFAULT FORMAT`, which normally is `~\ref{%s}` and the `REFERENCE STYLE`. The function should return the string to insert into the buffer. Something like this in your init file should do the job: ``` (setq reftex-format-ref-function (lambda (label fmt ref-style) (let ((fmt (if (= (char-before) ?.) (replace-regexp-in-string "~" "\\," fmt nil t) fmt))) (format fmt label ref-style)))) ``` --- Tags: reftex-mode ---
thread-5529
https://emacs.stackexchange.com/questions/5529
How to right align some items in the modeline?
2014-12-18T16:33:26.443
# Question Title: How to right align some items in the modeline? Given the following modeline configuration: ``` (setq-default mode-line-format (list ;; Current buffer name "%b " ;; Major mode "[%m] " ;; Modified status "[%*] " ;; Cursor position "Line: %l/%i Column: %c")) ``` I would like for the last item to appear right-aligned. # Answer > 13 votes Like the answer in the comments, you can do this yourself by writing code to return a nicely spaced string. Here is a simple way that supports only left and right aligned text applied to your specifications. ``` ;; write a function to do the spacing (defun simple-mode-line-render (left right) "Return a string of `window-width' length containing LEFT, and RIGHT aligned respectively." (let* ((available-width (- (window-width) (length left) 2))) (format (format " %%s %%%ds " available-width) left right))) ;; use the function in conjunction with :eval and format-mode-line in your mode-line-format (setq mode-line-format '((:eval (simple-mode-line-render ;; left (format-mode-line "%b [%m] [%*]") ;; right (format-mode-line "Line: %l/%i Column: %c"))))) ``` it ends up looking like this: Also note, I used your mode-line-format args as you specified, but I believe your are using %i incorrectly, which prints the byte size of the buffer, not the number of lines. You can use something like `(line-number-at-pos (point-max))` to get the number of lines in your buffer. # Answer > 5 votes To expand on @jordon-biondo's answer and resolve a bug showing `%`. This example shows how mode mode line variables can be used with alignment - which took me a while to figure out. ``` (defun simple-mode-line-render (left right) "Return a string of `window-width' length. Containing LEFT, and RIGHT aligned respectively." (let ((available-width (- (window-total-width) (+ (length (format-mode-line left)) (length (format-mode-line right)))))) (append left (list (format (format "%%%ds" available-width) "")) right))) (setq-default mode-line-format '((:eval (simple-mode-line-render ;; Left. (quote ("%e " mode-line-buffer-identification " %l : %c" evil-mode-line-tag "[%*]")) ;; Right. (quote ("%p " mode-line-frame-identification mode-line-modes mode-line-misc-info))))))) ``` Example output: `init.el 1 : 0 <N> [-] Top -F1 (Emacs-Lisp WK ivy drag AC GitGutter)` # Answer > 4 votes Building off of @ideasman42's answer, you can determine the required number of characters to pad the right items by using `format-mode-line`. For example, you can put the items you want to align to the right in the `mode-line-end-spaces` variable: ``` (setq mode-line-end-spaces '("" display-time-string battery-mode-line-string)) ``` Then create the function to determine the correct padding from this variable: ``` (defun my-mode-line/padding () (let ((r-length (length (format-mode-line mode-line-end-spaces)))) (propertize " " 'display `(space :align-to (- right ,r-length))))) ``` The `format-mode-line` function determines the expected output of `mode-line-end-spaces` on the mode line. Then the length of that string is subtracted from the right edge of the window. Then use both in the last lines of your mode line format ``` (setq-default mode-line-format '("%e " "%b " "[%m] " (:eval (my-mode-line/padding)) mode-line-end-spaces)) ``` # Answer > 1 votes While it's possible to do 'correct' left/right alignment adding an alternative method because fully evaluating the left and right just for alignment is a bit heavy, when there is a simpler alternative. If you know you only need a fixed amount of space on the right, you can fill in all but *N* characters, this works as long as the right size is a fixed length. String formatting `%12s` and similar can be used to ensure the string doesn't resize. ``` (defun mode-line-fill (reserve) "Return empty space using FACE and leaving RESERVE space on the right." (when (and window-system (eq 'right (get-scroll-bar-mode))) (setq reserve (- reserve 3))) (propertize " " 'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve))))) (setq-default mode-line-format (list ;; left align "%e %b [%*]" ;; right align (mode-line-fill 18) "%6l, %4c, %8p"))) ``` Eg: `CMakeLists.txt [-] 1590, 0, 94%` *Note that this only works well if you want to display a few items on the right hand side, as with this example - line/column/percentage. Showing all minor modes for eg wouldn't work well.* # Answer > 0 votes This isn't supported out-of-the-box but the `smart-mode-line` package does support this. You could either use that package, or if it does more than what you want, extract just the bits that implement the feature you are asking for. --- Tags: mode-line ---
thread-63777
https://emacs.stackexchange.com/questions/63777
Define and load a local keymap without defining a minor mode
2021-03-07T01:06:53.867
# Question Title: Define and load a local keymap without defining a minor mode Can I define and load a local keymap without defining a minor mode? I need to define some keybinding in `latex-mode` and access/list them with ``` (describe-variable 'mycustom-map) ``` but I don't want to define a minor mode. # Answer I'm not sure I understand the question, but the obvious cases are: 1. You *always* want your key bindings active in latex-mode 2. You *sometimes* want your key bindings active in latex-mode If it's option 1, you can bind your keys in the major mode's map instead of using a minor mode. If it's option 2, then just use a minor mode -- that *is* the canonical solution; but if for some reason it's very important to you not to define a minor mode, then you can still use the same underlying keymap mechanism without the actual minor mode: ``` (defun foo () "foo" (interactive) (message "foo")) (defvar foo-map (let ((map (make-sparse-keymap))) (define-key map (kbd "<f6>") #'foo) map) "foo map") (add-to-list 'minor-mode-map-alist (cons 'foo foo-map)) (defvar-local foo nil "Enable or disable `foo-map'.") (defun foo-enable () "Enable `foo-map' for the current buffer." (setq foo t)) (add-hook 'latex-mode-hook #'foo-enable) ``` > 1 votes --- Tags: key-bindings, keymap ---
thread-63741
https://emacs.stackexchange.com/questions/63741
orgmode - latex new line in tikz node not work
2021-03-05T04:33:33.373
# Question Title: orgmode - latex new line in tikz node not work Below code works fine if copy the tikzpicture to tex file. but in orgmode, looks like the new line not take effect! ``` #+header: :imagemagick yes :iminoptions -density 300 -opaque white -flatten -geometry 800 :fit yes :noweb yes :headers '("\\usepackage{tikz}") :border 0 :results raw #+begin_src latex :eval yes :file debug.png ;; https://blog.codecentric.de/en/2018/04/android-zygote-boot-process/ \usetikzlibrary{chains} \begin{tikzpicture}[start chain] \def\desc{ Description1:\\ - line one\\ - line two\\ - line three , Description2:\\ - line one\\ - line two\\ - line three } \foreach \d[count=\i] in \desc { \node[on chain] (P\i) {\d}; } \end{tikzpicture} #+end_src ``` I try to use \\ also but not work either! # Answer I suggest two ways to obtain the expected result: 1. Fixed width: use a \parbox to enclose the paragraphs: `\parbox{2cm}{ Description1:\\ - line one\\ - line two\\ - line three}` 2. Variable width: use a \tabular to structure the paragraphs: `\begin{tabular}{l} Description1:\\ - line one\\ - line two\\ - line three \end{tabular}` > 1 votes --- Tags: org-mode, org-babel, preview-latex ---
thread-63785
https://emacs.stackexchange.com/questions/63785
Activate a minor mode switching off the other ones in a set of minor modes
2021-03-07T22:37:51.023
# Question Title: Activate a minor mode switching off the other ones in a set of minor modes I'm developing a set of minor modes that I use in my LaTeX copy-editing work. I have, e.g.. a list of three minor modes stored in a variable: ``` (defvar latex-editing-mode '(preamble-editing-mode biblio-editing-mode proofs-editing-mode)) ``` I need them to be active **one at a time**. E.g. when I turn-on `biblio-editing-mode` the other two modes must be turned-off. I'm trying to write a function: ``` (defun activate-mode-in-list (MINOR_MODE MINOR_MODE_LIST) (interactive) (let ((MINOR_MODE_LIST (delete MINOR_MODE MINOR_MODE_LIST))) (mapcar (lambda (mode) (setq mode nil)) MINOR_MODE_LIST) (setq MINOR_MODE t))) ``` I need to use it this way: ``` (activate-mode-in-list biblio-editing-mode latex-editing-mode) ``` because I want to use it to write a set of functions to be called with dedicated and consistent keybindings. Eg. ``` (defun activate-biblio-editing-mode () "Activate `biblio-editing-mode` and deactivate the other ones setted in the `latex-editing-mode` variable" (interactive) (activate-mode-in-list biblio-editing-mode latex-editing-mode)) ``` And then: ``` (require 'preamble-editing-mode) (global-set-key (kbd "<C-M-kp-0>") 'activate-preamble-editing-mode) (require 'biblio-editing-mode) (global-set-key (kbd "<C-M-kp-1>") 'activate-biblio-editing-mode) ;; ... (require 'proofs-editing-mode) (global-set-key (kbd "<C-M-kp-9>") 'activate-proofs-editing-mode) ``` But my `activate-mode-in-list` function doesn't work as I wrote it. I guess I'm getting lost in quoting stuff because evaluating: ``` (setq preamble-editing-mode nil) (setq biblio-editing-mode t) ``` works as expected. 1. Where am I doing wrong? 2. Is there a better way to achieve my goal? All I need is a function that activates a specific minor-mode and deactivate some other minor modes. I can store this set of minor modes in a variable.. In my workflow, "in most cases", only one minor mode of this set of minor modes should be active at a time (but in some cases I would have more then one active at the same time. In this case I'd open them in the standard way). # Answer Compare this. The essential difference is using `set` instead of `setq`. ``` (defun activate-mode-in-list (minor-mode minor-mode-list) (dolist (mm minor-mode-list) (set mm (eq mm minor-mode)))) ``` Your feeling that *"I'm getting lost in quoting stuff because evaluating"* was not far off. You don't want to set the values of the *local* variables `mode` (bound by `lambda`) and `minor-mode` (bound by `let`). You want to set the *values of the variables* that those local variables are bound to. The code I show here uses `set` to set the value of the value of local variable `mm`, which is one of your minor-mode variables, to `t` or `nil`, depending on whether that minor-mode variable is the input value, `minor-mode`. E.g., for input `minor-mode` = `proofs-editing-mode`, during iteration, when `mm` is `proofs-editing-mode` we `set` the value of the symbol that is the value of `mm`, that is, `proofs-editing-mode`, to `t` (which is `(eq proofs-editing-mode proofs-editing-mode)`). Then when `mm` is, say, `biblio-editing-mode`, we `set` the value of `mm`, that is, `biblio-editing-mode`, to `nil` (which is `(eq biblio-editing-mode proofs-editing-mode)`). > 2 votes --- Tags: variables, quote, setq ---
thread-63769
https://emacs.stackexchange.com/questions/63769
How to remove second row of menu entries (or is it a toolbar)?
2021-03-06T16:36:57.667
# Question Title: How to remove second row of menu entries (or is it a toolbar)? I have installed OpenSuse Tumbleweed and later Emacs. If I start Emacs from the shell, ``` $ emacs -Q ``` I have a double row of menu entries ``` File - Edit - Options - ... - Help New File - Open - Open Directory - ... - Search ``` In a sense, the buttons in the second row are not menus, because they directly invoke simple commands… I'd like to get rid of the second menu row, maintaining the first one. I checked the `~/.emacs` that was automatically installed, apparently nothing relevant, and I've also tried `emacs -q`, to no avail. # Answer Oops, what I mistakenly assumed to be a second menubar was indeed the toolbar in disguise! Here it is how I realized my mistake. --- In OpenSuse, `/usr/bin/emacs` is a lengthy shell script that eventually starts either `/usr/bin/emacs-gtk` or `/usr/bin/emacs-x11`. When I tried `emacs-gtk -Q` I had the same results as using the system script, so I tried also `emacs-x11 -Q` and Emacs opened a window with the menu and an iconic toolbar. I had a moment of enlightenment noticing that the toolbar entries had a perfect match with the "menu" in the second row... So I used `Options → Toolbar → None` and voila, the second row disappeared. For some reason GTK rendered the toolbar buttons using text only, in a format that was virtually indistinguishable from the menu entries of the first row... and I needed to start `emacs-x11` to be enlightened because I'm not used to using the toolbar. > 1 votes # Answer You can add this to your `.emacs`: ``` (tool-bar-mode -1) ``` > 0 votes --- Tags: init-file, start-up, menu-bar ---
thread-10277
https://emacs.stackexchange.com/questions/10277
Make emacs automatically open binary files in hexl-mode
2015-03-24T20:01:27.317
# Question Title: Make emacs automatically open binary files in hexl-mode How can I make emacs automatically open binary files in hexl-mode? It's probably sufficient to define "binary" as "contains a null byte" (I suppose https://github.com/audreyr/binaryornot could be used if that ends up being an insufficient heuristic). # Answer > 5 votes If you know the file extensions are working with, the best solution is to just use the auto-mode-alist to startup hexl-mode. If not, and you take what you have said literally: ``` It's probably sufficient to define "binary" as "contains a null byte" ``` You can do this by adding a function that turns on hexl-mode if a file contain a null byte to the `find-file-hooks`. Here is a implementation: ``` (defun buffer-binary-p (&optional buffer) "Return whether BUFFER or the current buffer is binary. A binary buffer is defined as containing at least on null byte. Returns either nil, or the position of the first null byte." (with-current-buffer (or buffer (current-buffer)) (save-excursion (goto-char (point-min)) (search-forward (string ?\x00) nil t 1)))) (defun hexl-if-binary () "If `hexl-mode' is not already active, and the current buffer is binary, activate `hexl-mode'." (interactive) (unless (eq major-mode 'hexl-mode) (when (buffer-binary-p) (hexl-mode)))) (add-hook 'find-file-hooks 'hexl-if-binary) ``` # Answer > 2 votes I've tried Jordon's answer and it works well, however I'd like to recommend replacing `hexl-if-binary` (and the `(add-hook)`) with this: ``` (add-to-list 'magic-fallback-mode-alist '(buffer-binary-p . hexl-mode) t) ``` This way it only uses Hexl mode as a last resort if no other mode recognises the file. I prefer this because otherwise, image files open in Hexl mode rather than Image mode. --- Tags: hexl-mode, binary ---
thread-63796
https://emacs.stackexchange.com/questions/63796
Checking whether an org headline or any of its parents is done
2021-03-08T21:52:26.753
# Question Title: Checking whether an org headline or any of its parents is done One can use `org-entry-is-done-p` to check whether a headline is *locally* done: ``` (defun org-entry-is-done-p () (member (org-get-todo-state) org-done-keywords)) ``` So for example `Task B` is considered "done" using this methodology: ``` * Task A ** COMPLETE Task B CLOSED: [2021-03-08 Mon 15:51] *** Task C ``` **Question:** How can one modify this function that it will consider `Task C` also done? That is, how can one make a function that checks whether the current headline or any of its parents is done? # Answer > 2 votes You can use `(outline-up-heading 1)` to step up through the subtree headings, checking each one as you go. You are done when you've checked the top level of the subtree. Here's an implementation: ``` #+begin_src elisp (defun ndk/org-entry-is-hierarchically-done-p () (catch 'exit (save-excursion (while t ;; if this is a DONE entry, return t (when (org-entry-is-done-p) (throw 'exit t)) ;; if we are at top level, return nil (when (= (org-outline-level) 1) (throw 'exit nil)) ;; if we cannot go up any further, return nil (when (not (outline-up-heading 1)) (throw 'exit nil)))))) #+end_src ``` We loop over all the levels. At each level, starting from the lowest and going up, we check if the state is `DONE`: if so, we break out of the loop immediately returning `t`. If not, we check whether we are at the top level and if so, break out of the loop returning `nil`. Otherwise we check whether we can go up a level: if not, we return `nil`; if yes, we try again at the new level. --- Tags: org-mode ---
thread-63800
https://emacs.stackexchange.com/questions/63800
Return buffer from buffers list. For example, get the 5th buffer in the list, or check the name of every buffer in the list and return a match
2021-03-09T06:18:37.777
# Question Title: Return buffer from buffers list. For example, get the 5th buffer in the list, or check the name of every buffer in the list and return a match A bit of a silly question here, but you know emacs is a lot of library. Is anyone familiar with extracting buffers by number from the buffers list? In javascript or php this kind of thing is easy, just put an index next to the array. In emacs however, the lists have sometimes objects and sometimes strings, and getting the strings out of the objects seems sometimes a bit esoteric, given the sprawling and somewhat fragmented nature of the knowledge base. Of course, this is really easy and I'm missing something obvious, but nonetheless, help me out if you know the answer! To reiterate, I'd like to dolist the buffers list and extract a matching name if there or return the second, third, or fourth buffer from the list, as the case may be. # Answer The function `buffer-list` returns a list of buffer objects. This list isn't special; it's just an ordinary list. As such you can access an element of the list with `nth`, which is documented in chapter 5.3 Accessing Elements of Lists of the Emacs Lisp Manual. (You can also read this manual without leaving Emacs with `C-h i`.) Like this: ``` (nth 5 (buffer-list)) ``` You can access the name of a buffer with the accessor method `buffer-name`: ``` (buffer-name (nth 5 (buffer-list))) ``` Therefore you can get a list of the names of all of the buffers with `mapcar`: ``` (mapcar #'buffer-name (buffer-list)) ``` If you want more information about any of these functions, use `C-h f`. This prompts you for a function name (the default for the prompt will be the name of the function at point, if any), and then tells you everything it knows about it. There will be a description, as well a link to both the manual and the source code. > 1 votes --- Tags: buffer-list ---
thread-63802
https://emacs.stackexchange.com/questions/63802
Cannot use `pbpaste` in Emacs to paste Chinese characters
2021-03-09T06:56:03.817
# Question Title: Cannot use `pbpaste` in Emacs to paste Chinese characters I'm using macOS. I tried using the following command to paste from clipboard in Emacs(started with `emacs -Q`) ``` (call-process "/usr/bin/pbpaste" nil t nil) ``` It works fine for English characters, but not for Chinese characters. For example, if I copy the following Chinese characters in web browser ``` 中文测试 ``` Then run the `call-process` command above in Emacs, the result would be ``` ???? ``` My system encoding is UTF-8 and I checked Emacs' encoding system was UTF-8 too(By checking the value of `buffer-file-coding-system` in Emacs, which was `'utf-8`). How to sovle the problem? # Answer Finally, I found the answer, just add the following line to your Emacs config file: ``` (setenv "LANG" "en_US.UTF-8") ``` The reason is that `pbpaste` uses the encoding set by the environment variable `LANG`, by default Emacs don't set this variable, so you need to set it manually. Check this stackoverflow answer for more details. > 1 votes --- Tags: process, character-encoding, clipboard ---
thread-63805
https://emacs.stackexchange.com/questions/63805
How can I have the lighter of a minor mode be colored /propertized)?
2021-03-09T08:09:27.703
# Question Title: How can I have the lighter of a minor mode be colored /propertized)? How can I colorize/propertize the lighter of a minor mode in the mode line? # Answer > 2 votes Refer to the manual: `C-h``i``g` `(elisp)Properties in Mode` Or in the online manual (which is always for the most recent stable release of Emacs): https://www.gnu.org/software/emacs/manual/html\_node/elisp/Properties-in-Mode.html I think there's no point in quoting an excerpt here -- you need to read the whole page. --- Tags: mode-line, minor-mode, text-properties ---
thread-9433
https://emacs.stackexchange.com/questions/9433
How to make org prompt for a timestamp, when changing state of a TODO?
2015-02-20T10:34:29.277
# Question Title: How to make org prompt for a timestamp, when changing state of a TODO? I have so many tasks I do far away from my computer with emacs. Now, when I change state of a TODO, it just logs the current time into the drawer. But the difference with actual time of the event may be many hours, if not days. Is there a way to make it prompt for a timestamp I'd like it to log? # Answer I've wanted the exact same "I did this yesterday" behavior for a while and never got around to trying to implement it. But now if I can get points for it .... This behavior seems to be hard-coded into `org-todo`. The line in `org.el` that sets the CLOSED timestamp is `(org-add-planning-info 'closed (org-current-effective-time))` and the LOGBOOK notes are added by `org-add-log-setup`, which in turn calls `org-effective-current-time`. `org-effective-current-time` does what it sounds like and returns the effective time. The obvious solution is to temporarily change `org-effective-current-time` to something that prompts for a date. But then we get prompted for the date multiple times with every call, which is annoying. I don't know a good way to avoid it, but you can just save off the user inputed value and keep that around until the end of the function. This code seems to work and only prompts once when a state change would be logged. ``` (defun org-todo-with-date (&optional arg) (interactive "P") (cl-letf* ((org-read-date-prefer-future nil) (my-current-time (org-read-date t t nil "when:" nil nil nil)) ((symbol-function #'org-current-effective-time) #'(lambda () my-current-time))) (org-todo arg) )) ``` > 7 votes # Answer You can layer more hacks on top the first answer to address the problem with scheduling repeaters not updating correctly as so. Note that if `LAST_REPEAT` is set, it will be set to the actual date, not the chosen one. I wish Org would add this as a first-class feature; the actual date leaks into `org-todo` in many places; I'm sure this answer still misses some: ``` (defun org-todo-with-date (&optional arg) (interactive "P") (cl-letf* ((org-read-date-prefer-future nil) (my-current-time (org-read-date t t nil "when:" nil nil nil)) ((symbol-function #'current-time) #'(lambda () my-current-time)) ((symbol-function #'org-today) #'(lambda () (time-to-days my-current-time))) ((symbol-function #'org-current-effective-time) #'(lambda () my-current-time))) (org-todo arg))) ``` > 3 votes # Answer The following code works with org 20210308 and it handles `CLOSED`, `LOGBOOK`, `SCHEDULED`/`DEADLINE` as well `LAST_REPEAT` correctly for me. ``` (defun org-todo-with-date (&optional arg) (interactive "P") (cl-letf* ((org-read-date-prefer-future nil) (my-current-time (org-read-date t t nil "when:" nil nil nil)) ((symbol-function 'current-time) #'(lambda () my-current-time)) ((symbol-function 'org-today) #'(lambda () (time-to-days my-current-time))) ((symbol-function 'org-current-effective-time) #'(lambda () my-current-time)) (super-org-entry-put (symbol-function 'org-entry-put)) ((symbol-function 'org-entry-put) #'(lambda (pom property value) (print property) (if (equal property "LAST_REPEAT") (let ((my-value (format-time-string (org-time-stamp-format t t) my-current-time))) (funcall super-org-entry-put pom property my-value)) (funcall super-org-entry-put pom property value) )))) (if (eq major-mode 'org-agenda-mode) (org-agenda-todo arg) (org-todo arg)))) ``` This an alternative to the answer of Nosferatu, which is in turn based on the answers by erikstokes and Alex). It redefines `format-time-string` only when setting `LAST_REPEAT` and thereby ensures that `SCHEDULED`/`DEADLINE` are not effected by the redefinition. Moreover, this variant calls `org-agenda-todo` instead of `org-todo` in agenda mode. > 3 votes # Answer And here is another layer to fix LAST\_REPEAT case: ``` (defun org-todo-with-date (&optional arg) (interactive "P") (cl-letf* ((org-read-date-prefer-future nil) (my-current-time (org-read-date t t nil "when:" nil nil nil)) ((symbol-function 'current-time) #'(lambda () my-current-time)) ((symbol-function 'org-today) #'(lambda () (time-to-days my-current-time))) ((symbol-function 'org-current-effective-time) #'(lambda () my-current-time)) (super (symbol-function 'format-time-string)) ((symbol-function 'format-time-string) #'(lambda (fmt &optional time time-zone) (funcall super fmt my-current-time time-zone)))) (org-todo arg))) ``` hopefully `format-time-string` is only called from `org-auto-repeat-maybe` in `org-todo` context and only for `LAST_REPEAT` insertion. Anyway you can always copy the `org-todo` defun to your *emacs.el init file* and modify it there instead of cherry-pickifying functions with `cl-letf` (althought it's kind of cool to do it) > 2 votes --- Tags: org-mode ---
thread-63807
https://emacs.stackexchange.com/questions/63807
is there a way to get two separate next-error lists so I can bind them to two different keys
2021-03-09T11:39:04.877
# Question Title: is there a way to get two separate next-error lists so I can bind them to two different keys I often have grep (technically rgrep) in a buffer/window and another buffer/window with a "compilation" of my active project in it. I would like to bind two different keys (e.g. f2 and f3) to next-error and next-grep-hit and have them be independent. Is there a package that does that? # Answer Doing all the preparation to be able to do that is going to be more work than it is worth: you have to write special functions to use the buffer(s) of interest and then bind them to keys. I think it would be simpler to `rename-uniquely` the various grep/compile/etc buffers you create (so you would have `*grep*<2>`, `*grep*<3>` etc buffers, one for each different grep command you did). Then switching to the appropriate `*grep*` buffer and doing `C-x `` would use that buffer. In fact, that's what the doc of `next-error` says: > To specify use of a particular buffer for error messages, type C-x \` in that buffer. You can also use the command ‘next-error-select-buffer’ to select the buffer to use for the subsequent invocation of ‘next-error’. The `next-error-select-buffer` method works, but unfortunately the simple "switch to the appropriate grep buffer and do `next-error`" does not. I believe that is a bug in `next-error-find-buffer`: it prefers to use the last-used grep buffer, rather than using the current buffer. It needs to do things in the other order: use the current buffer if that buffer is usable for `next-error`, and fall back to the last-used buffer if not. You can probably implement that behavior by setting the variable `next-error-find-buffer-function` to a modified function that does things in the "right" order, but the contradiction between the doc and the implementation needs to be addressed. I'm going to suggest the following patch as a fix, but for the time being if you want things to work that way, you will have to patch the source code in `simple.el`. Here's the patch: ``` diff --git a/lisp/simple.el b/lisp/simple.el index f8050091d5..8796b612cc 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -298,15 +298,15 @@ next-error-find-buffer (funcall next-error-find-buffer-function avoid-current extra-test-inclusive extra-test-exclusive) - ;; 2. If next-error-last-buffer is an acceptable buffer, use that. + ;; 2. If the current buffer is acceptable, choose it. + (if (next-error-buffer-p (current-buffer) avoid-current + extra-test-inclusive extra-test-exclusive) + (current-buffer)) + ;; 3. If next-error-last-buffer is an acceptable buffer, use that. (if (and next-error-last-buffer (next-error-buffer-p next-error-last-buffer avoid-current extra-test-inclusive extra-test-exclusive)) next-error-last-buffer) - ;; 3. If the current buffer is acceptable, choose it. - (if (next-error-buffer-p (current-buffer) avoid-current - extra-test-inclusive extra-test-exclusive) - (current-buffer)) ;; 4. Look for any acceptable buffer. (let ((buffers (buffer-list))) (while (and buffers ``` With that, the workflow is as follows: * `M-x grep`, switch to the `*grep*` buffer and `M-x rename-uniquely` (bound to `C-x x u`). * Repeat for a different search. * You now have two buffers `*grep*<2>` and `*grep*<3>`. * Switch to the `<2>` buffer and do `C-x `` \- that will take you to the next hit for the search associated with that buffer. * Switch to the `<3>` buffer and do `C-x `` \- that will take you to the next hit associated with *that* buffer. If you switch to some unrelated buffer, you will continue using the last `grep` buffer you used (the `<3>` buffer in the above scenario), until you switch again. EDIT: Here's the bug report \- stay tuned. > 2 votes --- Tags: compilation-mode, rgrep, next-error ---
thread-19493
https://emacs.stackexchange.com/questions/19493
How to change Org-mode Babel lisp source code block from SLIME to SLY?
2016-01-13T04:00:47.840
# Question Title: How to change Org-mode Babel lisp source code block from SLIME to SLY? I found `ob-lisp.el` use SLIME by default to evaluate lisp code. I want to use SLY to evaluate lisp code. How to change it? I found the file `ob-lisp.el` is short. I tried to change `slime` to `sly`. But it is not customizable. I hope to define a `defcustom` for it. So that user can customize it. But I don't know how to apply this into code. For example, I define a custom like this: ``` (defcustom org-babel-lisp-default-implement "slime") ((defcustom org-babel-lisp-implements '("slime" "sly") "A list of Lisp implements." :group 'org-babel :version "24.1" ;; FIXME: reference code example. :type listp)) ``` Then in file `ob-lisp.el`. Has some places use `slime`. I want to make them adapt to upper `defcustom` value. like concate string from value or something else. ``` (declare-function slime-eval "ext:slime" (sexp &optional package)) (defun org-babel-execute:lisp (body params) "Execute a block of Common Lisp code with Babel." (require 'slime) (org-babel-reassemble-table (let ((result (funcall (if (member "output" (cdr (assoc :result-params params))) #'car #'cadr) (with-temp-buffer (insert (org-babel-expand-body:lisp body params)) (slime-eval `(swank:eval-and-grab-output .... ``` # Answer The easiest way is to parametrize the call `slime-eval`, using funcall and a `defvar`/`defcustom` and take advantage use of sly's retro contrib, which allows the user to refer to the slynk pacage by the name of swank. Besides the replacing `(slime-eval ...)` with `(funcall org-babel-lisp-eval-fn ...)` the other thing we must do is to require slime or sly when appropiate. I'm using pcase but there may be a more appropriate string-case in emacs lisp. ``` (defcustom org-babel-lisp-eval-fn '("slime-eval" "sly-eval") "The function to be called to evaluate code on the lisp side." :group 'org-babel :version "24.1" :type listp) (defun org-babel-execute:lisp (body params) "Execute a block of Common Lisp code with Babel." (pcase org-babel-lisp-eval-fn ("slime-eval" (require 'slime)) ("sly-eval" (require 'sly))) (org-babel-reassemble-table (let ((result (funcall (if (member "output" (cdr (assoc :result-params params))) #'car #'cadr) (with-temp-buffer (insert (org-babel-expand-body:lisp body params)) (funcall org-babel-lisp-eval-fn `(swank:eval-and-grab-output ,(let ((dir (if (assoc :dir params) (cdr (assoc :dir params)) default-directory))) (format (if dir (format org-babel-lisp-dir-fmt dir) "(progn %s\n)") (buffer-substring-no-properties (point-min) (point-max))))) (cdr (assoc :package params))))))) (org-babel-result-cond (cdr (assoc :result-params params)) result (condition-case nil (read (org-babel-lisp-vector-to-list result)) (error result)))) (org-babel-pick-name (cdr (assoc :colname-names params)) (cdr (assoc :colnames params))) (org-babel-pick-name (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))) ``` > 2 votes # Answer Please note that if you have a modern enough version of org mode you can just simply do ``` (setq org-babel-lisp-eval-fn #'sly-eval) ``` > 1 votes --- Tags: org-mode, org-babel, slime, common-lisp ---
thread-63815
https://emacs.stackexchange.com/questions/63815
pipe result of elisp function to a shell command
2021-03-10T02:36:24.983
# Question Title: pipe result of elisp function to a shell command I wanna pipe the output of an elisp function (`emacs-version`) to a shell command (`xclip`). How can I do this? I accept vanilla emacs and evil solutions. # Answer > 3 votes Something like this should work: ``` (with-temp-buffer (emacs-version t) (call-process-region (point-min) (point-max) "foo")) ``` It creates a temp buffer, inserts the output of `emacs-version` into the temp buffer (the `t` argument of `emacs-version`) and then calls the script `foo` passing it the contents of the buffer on its `stdin`. You may have to season to taste. To call `foo` with arguments, you need to read the doc string of `call-process-region` (do `C-h f call-process-region RET`). It takes a bunch of optional arguments that it interprets followed by any number of optional string arguments that it passes to the script as *its* arguments: > (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &rest ARGS) > > ... > > Send text from START to END to a synchronous process running PROGRAM. > > ... > > Remaining arguments ARGS are passed to PROGRAM at startup as command-line arguments. So you need to change the above like this: ``` (with-temp-buffer (emacs-version t) (call-process-region (point-min) (point-max) "foo" nil nil nil "-i" "-h")) ``` And again, depending on your needs, you may have to season to taste. # Answer > 1 votes Is this what you want(?): ``` ❯ emacs --batch --eval '(prin1 (emacs-version))' | xclip ``` How about this: ``` (async-shell-command (format "echo '%s' | xclip" (emacs-version))) ;;; The following freezes don't know why... (shell-command-to-string (format "echo '%s' | xclip" (emacs-version))) ``` --- Tags: evil, shell ---
thread-56287
https://emacs.stackexchange.com/questions/56287
Org mode tag column setting is ignored
2020-03-22T10:53:28.123
# Question Title: Org mode tag column setting is ignored Running Doom Emacs v 2.0.9. My `~/.doom.d/init.el` contains: ``` (custom-set-variables '(org-tags-column -80) ) ``` When I add tags using `counsel-org-tag`, the tag alignment in the current headline is destroyed. When I try to realign them using `SPC-u C-C C-C`, all tags become left aligned! When I `customize-variables` org-tag-column, it shows 'changed outside customize'. When I set up the value again and go back to the buffer to `SPC-u C-C C-C` all works as expected. I thought with that setting in init.el, all these steps should be unnecessary. How do I get the alignment behavior as expected? # Answer Doom is meant to be configured via `~/.doom.d/config.el`. Try setting the `org-tags-column` in that file. E.g.: ``` ;; in ~/.doom.d/config.el (after! org (setq org-tags-column -80) ;; ... other org configuration here ) ``` You may need to restart emacs for these changes to be applied, and then `SPC-u C-c C-c` should properly align the tags. > 3 votes --- Tags: org-mode, align, org-tags, doom ---
thread-63821
https://emacs.stackexchange.com/questions/63821
Is it possible to suppress `LSP :: Connected to [pyls:N].` message on minibuffer?
2021-03-10T08:46:35.157
# Question Title: Is it possible to suppress `LSP :: Connected to [pyls:N].` message on minibuffer? When I open a Python file I keep seeing `LSP :: Connected to [pyls:N]` message in the minibuffer. How can I suppress it? Since I know I have enabled `lsp`, I don't want to see that message always whenever I open a new file. I have looked into https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off but I couldn't find an option to disable it. *my configuration*: ``` (require 'lsp-mode) (add-hook 'python-mode-hook 'lsp) (add-hook 'python-mode-hook #'lsp-deferred) (setq lsp-enable-symbol-highlighting nil) (setq lsp-ui-doc-enable nil) (setq lsp-lens-enable nil) (setq lsp-headerline-breadcrumb-enable nil) (setq lsp-ui-sideline-enable nil) (setq lsp-diagnostics-provider :none) ``` # Answer > 3 votes ``` (defun disable-lsp-conn-msg-advice (func &rest r) (unless (string-prefix-p "Connected to" (car r)) (apply func r))) (advice-add 'lsp--info :around #'disable-lsp-conn-msg-advice) ``` --- Tags: message, lsp, inhibit-message ---
thread-63823
https://emacs.stackexchange.com/questions/63823
Follow org links in current buffer with ivy
2021-03-10T11:03:35.977
# Question Title: Follow org links in current buffer with ivy How can I follow org links in the current buffer using ivy? This is similar functionality to `m` (`M-x Info-menu`) in info with ivy/counsel installed. The command should list with ivy everything that org considers a link in the current buffer, and when a link is selected, it should navigate there. Primarily I want to use this for internal navigation in org-roam, not for browsing to web links. I'm aware that org-roam has its own link navigation functions that uses the org-roam sqlite database, but I want a shorter list of candidates: just those in the current file. When I have something like this, I imagine tweaking it to work for the org-roam backlinks buffer also, but the focus of this question is the general question for org, not org-roam in particular. # Answer > 1 votes You might leverage what org-roam does and write a function with a more limited query that gets the current buffer-file-name and limits result by that. Alternatively, here is an independent approach that might work for you. ``` (defun follow-buffer-link () (interactive) (ivy-read "Link: " (org-element-map (org-element-parse-buffer) 'link (lambda (lnk) (list (org-element-property :raw-link lnk) lnk))) :action (lambda (candidate) (save-excursion (goto-char (org-element-property :begin (second candidate))) (org-open-at-point))))) ``` --- Tags: org-mode, ivy, counsel, org-roam ---
thread-63833
https://emacs.stackexchange.com/questions/63833
How to disable confirmation for large files
2021-03-10T18:05:58.777
# Question Title: How to disable confirmation for large files When you recursively copy a large remote directory through Tramp, it will ask for confirmation for large files. Because of that, you can't leave the copy in the background, since the confirmation pauses the copy. And the "large file" size is something ridiculous, like 10MB. How do I disable this? It really slows down the copy process. # Answer > 2 votes This is controlled with `large-file-warning-threshold` variable. Do `C-h v large-file-warning-threshold RET`. Then hit `customize`. Then hit `Value Menu`. Then choose `"Never request confirmation"`. However, setting it globally affects more than just tramp copy (open large file, for instance). So you may wanna limit its usage with finer control. --- Tags: dired, tramp ---
thread-63839
https://emacs.stackexchange.com/questions/63839
With incremental compilation and changed files `compilation-goto-error` moves to wrong line
2021-03-11T08:32:24.573
# Question Title: With incremental compilation and changed files `compilation-goto-error` moves to wrong line I work on a typescript project that I compile with `webpack serve`, using `projectile-run-project`. My `*compilation` buffer shows the webpack output, which includes typescript errors. After some webpack hacking, I managed to get the errors into a `compilation` mode compatible format. When I select an error (which runs `compilation-goto-error` on this error), emacs opens the respective file in another buffer and jumps to the correct line. This works well so far. When I change files, `webpack serve` immediately recompiles the project, and echos new error messages into `*compilation*`. When I now edit a file, emacs seems to memorise error locations *at the start* of the compilation. Meaning: * I start compilation * I edit file `index.ts` to add a new line after line 4 * webpack reports an error at `index.ts:6` * `compile-goto-error` goes to `index.ts:7` I assume that this happens because `compilation` mode knows that line 6 in `index.ts` at the start of the compilation is now at line 7. However, I don't need that memoization, as the compilation reports current (correct) lines. How can I make `compilation-goto-error` use current lines, not cached onces? # Answer So, as I was just finishing writing my answer I found what I think might be a solution. I had a look at `compile.el`, and I found several messages relating to `omake -P`, which probably has a similar re-compilation behaviour. An entry into `compilation-error-regexp-alist-alist` omake calls `compilation--flush-file-structure` for the respective file, so that the memoisation is cleared prior to navigating there: ``` (omake ;; "omake -P" reports "file foo changed" ;; (useful if you do "cvs up" and want to see what has changed) "^\\*\\*\\* omake: file \\(.*\\) changed" 1 nil nil nil nil ;; FIXME-omake: This tries to prevent reusing pre-existing markers ;; for subsequent messages, since those messages's line numbers ;; are about another version of the file. (0 (progn (compilation--flush-file-structure (match-string 1)) nil))) ``` I adopted this for the `compilation-error-regexp-alist-alist` entries for typescript, using a bit from `typescript-mode.el`: ``` ;; handle plain compiler-errors like the following when doing M-x compile<ret>tsc<ret> ;; ;; greeter.ts(24,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ;; greeter.ts(30,12): error TS2339: Property 'indexOf' does not exist on type 'number'. (defconst typescript-tsc-error-regexp (concat "^[[:blank:]]*" "\\([^(\r\n)]+\\)(\\([0-9]+\\),\\([0-9]+\\)):[[:blank:]]+" "error [[:alnum:]]+: [^\r\n]+$") "Regexp to match errors generated by tsc.") ``` I add the result to `compilation-error-regexp-alist-alist`, overiding the regular `typescript-mode` entries: ``` (dolist (regexp `((typescript-tsc ,typescript-tsc-error-regexp 1 2 3 2 ;; for flushing the marker cache of this file nil (0 (progn (compilation--flush-file-structure (match-string 1)) nil))) (typescript-tsc-pretty ,typescript-tsc-pretty-error-regexp 1 2 3 2 ;; for flushing the marker cache of this file nil (0 (progn (compilation--flush-file-structure (match-string 1)) nil))))) (add-to-list 'compilation-error-regexp-alist-alist regexp) (add-to-list 'compilation-error-regexp-alist (car regexp))) ``` That feels *really* hackish, but so far seems to work. > 0 votes --- Tags: compilation ---
thread-63820
https://emacs.stackexchange.com/questions/63820
How to let line numbers count from 1 in org subtree?
2021-03-10T06:55:42.833
# Question Title: How to let line numbers count from 1 in org subtree? When I narrow an org mode header into a subtree(using command org-narrow-to-subtree) in vanilla Emacs, the line number counts from 1 in the subtree, but when I create a subtree in Doom Emacs, the line number counts from the original line number(e.g. if the header is on the 8000th line in the original file, the header in the subtree still starts from 8000, instead of 1). How can I make it count from 1 in the subtree? # Answer Put this in an appropriate place in your emacs configuration (not sure what file that is for doom): ``` (custom-set-variables '(display-line-numbers-widen nil)) ``` I think you could use `setq-default` instead if you like, but I hear there are some subtleties that make `custom-set-variables` a better choice for customize-able variables -- it's OK to use `custom-set-variables` in your ordinary emacs config however you like -- just don't edit by hand the special customize call that is commented with `;; custom-set-variables was added by Custom.` unless you know what you're doing. Alternatively, you can use `M-x customize-variable <RET> display-line-numbers-widen <RET>`. > 1 votes --- Tags: org-mode, doom, line-numbers ---
thread-28854
https://emacs.stackexchange.com/questions/28854
Command history not saved while using GDB from Emacs
2016-11-23T08:02:31.990
# Question Title: Command history not saved while using GDB from Emacs I usually debug in console `gdb` and now I'm trying to move to Emacs. In my `~/.gdbinit` I have the following lines setting up history: ``` # save history of unlimited size, write always to ~/.gdb_history set history save on set history size unlimited set history filename ~/.gdb_history ``` And in console `gdb` history works perfectly. `show history` result there: ``` (gdb) show history +show history expansion: History expansion on command input is off. filename: The filename in which to record the command history is "/home/ars/. gdb_history". save: Saving of the history record on exit is on. size: The size of the command history is 10000000. ``` If you wonder, history size is 10000000 instead of `unlimited` because I have $HISTSIZE=10000000. In Emacs, I successfully search for old commands from `~/.gdb_history` with `comint-history-isearch-backward-regexp`. However, the problem is that commands entered while debugging from Emacs are not appended to `~/.gdb_history`. I can still search through them in the current session, i.e. they are saved somewhere in memory, but they will not be written to the file and as a consequence I don't see them in the following sessions. While GDB starts inside Emacs, I see that the config is read: ``` ... +set history save on +set history size unlimited +set history filename ~/.gdb_history ... ``` And `show history` output there is exactly the same like in console GDB: ``` show history +show history expansion: History expansion on command input is off. filename: The filename in which to record the command history is "/home/ars/.gdb_history". save: Saving of the history record on exit is on. size: The size of the command history is 10000000. (gdb) +info break ``` I start `gdb` with command like `(gdb "gdb -i=mi $PROGTODEBUG")` and finish debugging with `quit`, typed manually or via `C-d`. Then I kill the buffer with `kill-this-buffer` and exit Emacs. GNU Emacs version is 25.1. # Answer > 1 votes Try: ``` (add-hook 'kill-buffer-hook 'comint-write-input-ring) ``` For some reason gdb, as one of the comint modes, does not do this by default. **Note:** gdb *gud* buffer has to be killed. By default tt is not enough to just 'quit' from gdb session. You really need to kill comint (gdb) buffer. You can correct this behavior so, when you quit gdb session ('q' or 'quit'), then gud session buffer will be closed and windows configuration will be restored, by using: ``` (setq gdb-restore-window-configuration-after-quit t) ``` --- Tags: gdb ---
thread-63841
https://emacs.stackexchange.com/questions/63841
How do I specify how tags in headers are exported to HTML in org-mode?
2021-03-11T09:00:20.843
# Question Title: How do I specify how tags in headers are exported to HTML in org-mode? I would like tags in headers (specifically) to export to html as links to a file of the same name, something like: ``` * My first post is about dogs :DOGS: ``` where `:DOGS:` then exports as ``` <span class="tag"> <a href="./dogs.html">DOGS</a> </span> ``` instead of what it currently exports as which is ``` <span class="tag"> <span class="DOGS">DOGS</span> </span> ``` I assume another issue I'll have to work through is that I'd need to specify that *some tags* get exported (like ones in headers), while others don't (like ones in bodies). # Answer Write a modified `org-html-format-headline-function` that calls a modified `org-html--tags` function and hook it into the standard HTML exporter by redefining/customizing the variable `org-html-format-headline-function`. Here's a possible implementation: ``` #+begin_src elisp (defun ndk/org-html-format-headline-function (todo _todo-type priority text tags info) "Default format function for a headline. See `org-html-format-headline-function' for details." (let ((todo (org-html--todo todo info)) (priority (org-html--priority priority info)) (tags (ndk/org-html--tags tags info))) (concat todo (and todo " ") priority (and priority " ") text tags))) (defun ndk/org-html--tags (tags info) "Format TAGS into HTML. INFO is a plist containing export options." (when tags (format "<span class=\"tag\">%s</span>" (mapconcat (lambda (tag) (format "<a href=\"%s\">%s</a>" (format "./%s.html" (downcase tag)) tag)) tags "&#xa0;")))) ;; (setq org-html-format-headline-function #'org-html-format-headline-default-function) (setq org-html-format-headline-function #'ndk/org-html-format-headline-function) #+end_src ``` If you compare the two functions above with the standard ones in `ox-html.el`, you should be able to see clearly the small differences between them (and how to modify them further if needed). For testing, the two `setq` forms at the end are convenient: comment one or the other out to get either the default or the modified behavior. When you are satisfied with the functions, you should probably customize the variable `org-html-format-headline-function` to set the whole thing in stone. > 1 votes --- Tags: org-mode, org-export, html ---
thread-63811
https://emacs.stackexchange.com/questions/63811
AUCteX and LaTeX3 optional arguments
2021-03-09T18:09:17.323
# Question Title: AUCteX and LaTeX3 optional arguments LaTeX3 allows for some flexibility in specifying optional arguments to create commands and environments. For example you could specify `\NewDocumentCommand{\foo}{d<>m}{...}` and this would be used as `\foo<something optional>{something required}` -- `d<>` specifies an optional argument surrounded by angle brackets. What I would like to be able to do is to color the optional argument in AUCTeX in the same way that occurs with `\section[something optional]{something mandatory}`. Is this possible, and, if so, how accomplished? Thanks. # Answer > 3 votes You can add fontification support for your `\foo` like other macros: 1. Customize one of the variables `font-latex-match-function-keywords`, `font-latex-match-reference-keywords` etc. as described in the manual. This way, the fontification will be available for `\foo` in all your documents. Note that in this case, customize means use the customize interface and don't `setq` it in your init file. The docstring says: > \[...\] Setting this variable directly does not take effect; restart Emacs. Customize has some code to run `(font-latex-match-reference-make)` in this particular case, hence `setq`-ing it doesn't work. 2. In your .tex file, add an entry to the file local variables which can look like this: ``` \documentclass{article} \usepackage{xparse} \NewDocumentCommand\foo{d<>m}{...} \begin{document} \foo<optional>{mandatory} \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% eval: (font-latex-add-keywords '(("foo" "<{")) 'reference) %%% End: ``` It looks like this for me: 3. Finally, if you have your definition in a .sty file and load it via `\usepackage`, you have to write an AUCTeX style file and put some lisp code there. --- Tags: auctex ---
thread-63647
https://emacs.stackexchange.com/questions/63647
How can I jump back after `rope-goto-definition`?
2021-02-28T20:49:20.257
# Question Title: How can I jump back after `rope-goto-definition`? I am using `rope-goto-definition` to jump into a module's definition, link. But I cannot jump back to where I was. `xref-pop-marker-stack` says `Marker stack is empty`. Is it possible to jump back after running `rope-goto-definition`? Similiar behavior is done using `jedi:goto-definition-pop-marker`. --- My setup: ``` (require 'pymacs) (pymacs-load "ropemacs" "rope-") (setq ropemacs-enable-autoimport 't) (setq ropemacs-autoimport-modules '("os" "shutil")) (defun goto-def-or-jedi () "Go to definition of thing at point or do an rgrep in project if that fails" (interactive) (condition-case nil (rope-goto-definition) (error (rope-goto-definition (thing-at-point 'symbol))))) ``` --- Note: On there github its said that: `ropemacs is completely unmaintained and abandoned.` link. So there is no hope to have support from developers. Maybe before jump, the location can be pushed into the stack? # Answer you can put a mark at `rope-goto-definition` with https://www.emacswiki.org/emacs/auto-mark.el ``` (require 'auto-mark) (setq auto-mark-command-class-alist '((anything . anything) (rope-goto-definition . jump) (indent-for-tab-command . ignore) (undo . ignore))) (setq auto-mark-command-classifiers (list (lambda (command) (if (and (eq command 'self-insert-command) (eq last-command-event ? )) 'ignore)))) (global-auto-mark-mode 1) ``` Then you can use `pop-global-mark` or `pop-local-mark` depending on whether there is a change of buffer or not. unfortunately with this solution it is up to the user to manage when to use local or global marks. > 1 votes --- Tags: python, motion ---
thread-63850
https://emacs.stackexchange.com/questions/63850
Doom-emacs - How to align chinese characters in org-tables
2021-03-11T15:52:23.510
# Question Title: Doom-emacs - How to align chinese characters in org-tables I'm trying out doom emacs for the first time (previously was using spacemacs). I've run into an issue where chinese characters are not aligned in org mode tables. For example: ``` | Character | Pingyin | Meaning | |-----------+-------------+--------------------------| | 好 | hao | good | | 早上 | zaoshang | morning | | 晚上 | wanshang | evning | | 对不起 | dui bu qi | to be sorry | | 没关系 | mei guan xi | that's ok/doesn't matter | | 不 | bu | no | | 不客气 | bu ke qi | you're welcome | | 在见 | zaijian | see you around | | | | | ``` I've read online that this can be resolved by setting the width of chinese characters to double the width of asci characters, but I'm not sure how to do this. In spacemacs the issue is fixed with the following line in config: ``` (spacemacs//set-monospaced-font "Source Code Pro" "Hiragino Sans GB" 15 18) ``` I'm trying to do something similar in doom: ``` (setq doom-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal) doom-big-font (font-spec :family "Source Code Pro" :size 26)) (dolist (charset '(kana han cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) charset (font-spec :family "Source Code Pro" :size 18))) ``` But, it's not working. Would appreciate any help! # Answer Just use `Hiragino Sans GB` font! ``` (setq doom-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal) doom-variable-pitch-font (font-spec :family "Source Code Pro" :size 15 :weight 'normal :width 'normal) doom-big-font (font-spec :family "Source Code Pro" :size 26)) ;; Set font for chinese characters ;; Font should be twice the width of asci chars so that org tables align ;; This will break if run in terminal mode, so use conditional to only run for GUI. (if (display-graphic-p) (dolist (charset '(kana han cjk-misc bopomofo)) (set-fontset-font (frame-parameter nil 'font) charset (font-spec :family "Hiragino Sans GB" :size 18)))) ``` Note - reload your `config.el` after doom starts to activate these changes. > 2 votes --- Tags: fonts, doom, align ---
thread-63829
https://emacs.stackexchange.com/questions/63829
Annoying "error in process filter: Overlapping strings detected"
2021-03-10T15:49:58.560
# Question Title: Annoying "error in process filter: Overlapping strings detected" When editing python code with elpy, if I type a single or double quote while writing a new line of code (i.e. adding or changing a line in existing code), the UI freezes momentarily, make the bell sound, and the minibuffer shows "error in process filter: Overlapping strings detected". It's extremely annoying and unhelpful. What can I do (besides disabling elpy)? EDIT: Additional details: * disabling elpy-mode makes it stop * doesn't seem to happen with small files (e.g. 62 lines), but does happen with larger files (e.g. 524 lines) * elpy version 1.34.0 EDIT (by NickD): I was able to reproduce this independently. The backtrace I got is: ``` Debugger entered--Lisp error: (cl-assertion-failed ((>= string-start last-string-end) "Overlapping strings detected (start=%d, last-end=%..." 12628 12629)) cl--assertion-failed((>= string-start last-string-end) "Overlapping strings detected (start=%d, last-end=%..." (12628 12629) nil) python-nav-end-of-statement() python-nav-end-of-defun() python-info-current-defun() #f(compiled-function (info) #<bytecode -0xf329f5f70555bd7>)(nil) elpy-promise-resolve([*elpy-promise* #f(compiled-function (info) #<bytecode -0xf329f5f70555bd7>) elpy-rpc--default-error-callback #<buffer models.py> nil] nil) elpy-rpc--handle-json(((result) (id . 8))) elpy-rpc--filter(#<process *elpy-rpc [project:/usr/lib/python3.9/site-packages/ environment:/usr]*<1>> "{\"result\": null, \"id\": 8}\n") ``` # Answer There's a workaround suggested in https://github.com/jorgenschaefer/elpy/issues/1381#issuecomment-434313600 Adding `(setq elpy-eldoc-show-current-function nil)` to my emacs init file makes it stop happening for me. Good enough! > 5 votes --- Tags: python, elpy ---
thread-63854
https://emacs.stackexchange.com/questions/63854
Default argument for interactive function?
2021-03-11T17:44:59.573
# Question Title: Default argument for interactive function? Using ``` (interactive "sPROMPT: ") ``` one can set a prompt for, e.g., a string function. **Question:** Is it possible to also supplement a default argument to the function? Say ``` (interactive "sPROMPT: default") ``` so that the users can supply "default" as the default argument to the function, unless they change it manually? # Answer > 8 votes ``` (defun hello (st) (interactive (list (read-string "Your name: " "toto"))) (message "Hello Mr %s" st)) ``` where "toto" is the initial-input. --- Tags: interactive ---
thread-63856
https://emacs.stackexchange.com/questions/63856
Regex to match one tag and not the other in image-dired
2021-03-11T18:38:02.790
# Question Title: Regex to match one tag and not the other in image-dired In image-dired I use `M-x` `image-dired-mark-tagged-files` to mark files containing a tag using regexp. e.g. `oil`. What regex do I need to mark `oil` but *not* `wip` (work in progress). Input: ``` /foo/IMG_2022.JPG;art;oil;wip /foo/IMG_2023.JPG;oil;art; ``` Output needed: ``` /foo/IMG_2023.JPG;oil;art; ``` ## `M-x` image-dired-mark-tagged-files image-dired-mark-tagged-files is an autoloaded interactive compiled Lisp function in ‘image-dired.el’. (image-dired-mark-tagged-files) Use regexp to mark files with matching tag. A ‘tag’ is a keyword, a piece of meta data, associated with an image file and stored in image-dired’s database file. This command lets you input a regexp and this will be matched against all tags on all image files in the database file. The files that have a matching tag will be marked in the dired buffer. # Answer An Elisp regexp can't express this, AFAIK. (Some regexp dialects can.) --- But you can do it in two steps: 1. Mark `oil` matches, which will include some `wip` matches. 2. **UN**mark `wip` matches. --- There seems to be no command `image-dired-unmark-tagged-files`. But you can define one, just by binding `dired-marker-char` to a space char and "marking" with that. Like this (untested): ``` (defun my-image-dired-unmark-tagged-files () "Use regexp to unmark files with matching tag. See `image-dired-mark-tagged-files'." (interactive) (let ((dired-marker-char ?\ )) (image-dired-mark-tagged-files))) ``` --- Alternatively, after marking the `oil` files you can: 1. Use `* c * Q`, to change all `*` marks to `Q` (or any other char). 2. Use `image-dired-mark-tagged-files` to mark the `wip` files. 3. Use `M-DEL *` to remove all `*` marks, unmarking the `wip` files. In Dired, you can mark lines with any char, and you can change marks easily. And a line that is "unmarked" is just a line that's marked with a space-char mark. > 2 votes --- Tags: regular-expressions, image-dired ---
thread-63858
https://emacs.stackexchange.com/questions/63858
Regex to handle unicode strings in evil mode
2021-03-11T22:11:13.073
# Question Title: Regex to handle unicode strings in evil mode I'm using evil mode on Emacs2 27.1 on OSX. My goal is to search and replace some text containing unicode strings using either of emacs' replace-regex or vim's search/replace functionality. To begin with, let me showcase the example in vim **without** the use of unicode characters: My text file has plenty of markers (let's say the unicode char i.e U2404) and I need to wrap the marker along with its preceding word into `\mbox{}` E.g input text ``` This is a string। This is another (string) । One more example string here । ``` This regex does the job for me in vim: `%s/\((\?\w*)\?\)\s*।/\\mbox{\1 ।}/g` Output ``` This is a \mbox{string ।} This is another \mbox{(string) ।} One more example string \mbox{here ।} ``` Now, onto solving the real problem with unicode chars. Sample text: ``` This is a नमस्ते। This is another (नमस्ते) । One more example string नमस्ते । ``` The above vim regex does not work because `\w` does not match unicode chars. However, I can use `\S`, which denotes any non-space character, in the regex to apply the search/replace with pattern `%s/\((\?\S*)\?\)\s*।/\\mbox{\1 ।}/gc` This regex does **not** work in emacs' evilmode. Is there such a thing as `\S` in emacs' regex repertoire? I glanced through emacs' regex syntax and couldn't find anything. What's the regex to use to obtain the same results as with the vim command `%s/\((\?\S*)\?\)\s*।/\\mbox{\1 ।}/gc`? # Answer > 3 votes I don't use evil mode, so I've no idea if its regexes are different from ordinary Emacs regexes or not. But if you use `M-x re-builder`, you'll see that `"\\((?\\w*)?\\) *।"` is a perfectly fine regex that matches all of your examples, with the group matching exactly what you want. --- Tags: evil, regular-expressions ---
thread-63863
https://emacs.stackexchange.com/questions/63863
Is there an efficient way to tell which parts of my startup of Emacs take the longest to load?
2021-03-11T22:52:22.147
# Question Title: Is there an efficient way to tell which parts of my startup of Emacs take the longest to load? I have been trying to make the start-up times better. Almost all of my init.el is broken into use-package declarations like this: ``` (use-package x ...) (use-package y ...) (use-package z ...) ``` I want to start optimising those parts of the init.el that take the longest. Is there a way to do something like, ``` (use-package x ...) ; print load time for x (use-package y ...) ; print load time for y (use-package z ...) ; print load time for z ``` I know for the entire file you can do something like this `(message (time-subtract after-init-time before-init-time))` # Answer > 6 votes This does it: ``` (setq use-package-verbose t use-package-minimum-reported-time 0) ``` We get in `*Messages*`: ``` Loading package x...done (0.021s) Configuring package x...done (0.020s) Loading package y...done (0.025s) Configuring package y...done (0.020s) Loading package z...done (0.041s) Configuring package z...done (0.020s) ``` --- Tags: init-file, start-up, performance, profiler ---
thread-63865
https://emacs.stackexchange.com/questions/63865
Combine two lists elementwise
2021-03-12T03:32:37.220
# Question Title: Combine two lists elementwise I need to combine two lists elementwise. Given two lists that look something like, ``` (setq qux '("foo" "bar" "baz")) (setq quux '("xyzzy" "thud" "blat")) ``` I need to use each corresponding element to form a new list, ``` ("foo:xyzzy" "bar:thud" "baz:blat") ``` I could create a function that defines each element of the desired list, ``` (defun combiner (a b) (format "%s:%s" a b)) ``` but then its not clear how I would pass the base lists in. Another approach might be to combine the base lists into one, maybe an alist, and then pass that into a combiner function via mapcar. The trouble is, I'm not sure how to combine the two lists elementwise. Thoughts? # Answer > 5 votes See `seq-mapn`. ``` (setq qux '("foo" "bar" "baz")) (setq quux '("xyzzy" "thud" "blat")) (seq-mapn #'(lambda (a b) (format "%s:%s" a b)) qux quux) ``` Resulting in: ``` ("foo:xyzzy" "bar:thud" "baz:blat") ``` --- If you prefer to use common-lisp: ``` (cl-mapcar #'(lambda (a b) (format "%s:%s" a b)) qux quux) ``` # Answer > 2 votes The solution given by @ideasman42 must obviously be preferred, but just a remark about that part: > I could create a function that defines each element of the desired list, but then its not clear how I would pass the base lists in. Actually, if you have only two lists, and if you are sure that they have the same length (you should check that either before calling the function, or inside the function), some (ugly) homemade elisp code like that will work, using your `combiner` function: ``` (defun combine-listwise (x y) (let (result) (while (and x y) (push (combiner (pop x) (pop y)) result)) (nreverse result))) (combine-listwise qux quux) ``` That's not very elegant, but I think you had a good idea when you started with this `combiner` function, and it seems interesting to show how you could use it. :) # Answer > 2 votes Another approach is to use cl-loop like this ``` (cl-loop for e1 in qux for e2 in quux collect (format "%s:%s" e1 e2)) ``` related to `cl-map` given by @ideasman42 is a little shorter version with `cl-mapcar`. ``` (cl-mapcar (lambda (x y) (format "%s:%s" x y)) qux quux) ``` # Answer > 1 votes dash.el provides some useful functions: `-zip`, `-zip-lists`, `-zip-with` etc E.g. ``` (setq qux '("foo" "bar" "baz")) (setq quux '("xyzzy" "thud" "blat")) (-zip qux quux) -> (("foo" . "xyzzy") ("bar" . "thud") ("baz" . "blat")) (-zip-lists qux quux) -> (("foo" "xyzzy") ("bar" "thud") ("baz" "blat")) (-zip-with (lambda (s1 s2) (format "%s:%s" s1 s2)) qux quux) -> ("foo:xyzzy" "bar:thud" "baz:blat") ``` --- Tags: list, mapping ---
thread-63875
https://emacs.stackexchange.com/questions/63875
Emacs org mode shortcut to create code block
2021-03-12T16:18:50.080
# Question Title: Emacs org mode shortcut to create code block When using org mode, how can I map a specific keybinding (ex. `C-c s`) to create an org code snippet that looks like this: ``` #+BEGIN_SRC python #+END_SRC ``` # Answer You can always write a function that inserts a string and then bind it to a key: ``` (defun insert-python-src-block () (interactive) (insert "#+BEGIN_SRC python\n\n#+END_SRC")) (define-key org-mode-map (kbd "C-c s") #'insert-python-src-block) ``` But key bindings are scarce commodities; they also tend to be hard to remember when they proliferate. So most people prefer a templating mechanism for this. Org mode provides one based on the variable `org-structure-template-alists`. You get extensibility, but you don't get to choose an arbitrary keybinding for it. Here's how that works - you add this to your init file: ``` (with-eval-after-load 'org (add-to-list 'org-structure-template-alist '("p" . "src python"))) ``` Then you invoke *any* of the templates with `C-c C-,` (bound to `org-insert-structure-template`) which gives you a menu of possibilities: choosing `p` inserts the new template you added. For details, do `C-h v org-structure-template-alist RET` to read the doc string of the variable, do `C-h f org-insert-structure-template` to read the doc string of the function, and read the Structure templates section of the manual either online, or locally with `C-h i g(org)Structure templates RET` which also describes the backward-compatible `org-tempo` based method as well. There are other templating mechanisms: `yasnippets` seems to be the most popular, but I don't know enough about it to describe it here. > 5 votes --- Tags: org-mode, key-bindings ---
thread-63842
https://emacs.stackexchange.com/questions/63842
Standard Mac/Windows Keybindings for Italics, Bold, and Underline in Org-Mode
2021-03-11T11:19:41.497
# Question Title: Standard Mac/Windows Keybindings for Italics, Bold, and Underline in Org-Mode Is there a simple way to get command-i, command-b, and command-u to operate in emacs org-mode on Mac in exactly the way that they operate in a typical word processor on Mac (for example, Microsoft Word for Mac)? --- **\[Edit (Mar 14 '21)\]:** To be more precise, I think I want typing 'command-i', for example, to do something like the following: For every chunk of selected text (counting a cursor with no text selected as a selection with zero length): * Adding emphasis markers: + If no '/' immediately precedes the selection and no '/' begins the selection, then add a '/' immediately before the selection; + If no '/' immediately follows the selection and no '/' ends the selection, then add a '/' immediately after the selection; * Deleting emphasis markers: + Deleting emphasis markers at the start of the selection: - If a '/' immediately precedes the selection if and only if no '/' begins the selection, then delete the '/' that precedes or begins the selection; - If a '/' immediately precedes the selection and a '/' begins the selection, then delete the '/' that begins the selection; + Deleting emphasis markers at the end of the selection: - If a '/' immediately follows the selection if and only if no '/' ends the selection, then delete the '/' that follows or ends the selection; - If a '/' immediately follows the selection and a '/' ends the selection, then delete the '/' that ends the selection. --- I’m a writer/academic, and I’ve been looking for a new text editor. It looks like it should be possible to set up emacs org-mode in a way that meets almost all of my requirements, so I'm thinking of making the switch from writing markdown in Visual Studio Code. My main concern regards the keybindings. I would like to be able to keep as many of the standard Mac/Windows keybindings as possible so that I’m not constantly getting tripped up whenever I switch between different applications and computers, which I will need to do regularly. I’m aware that there’s a mode called ‘cua-mode’ which allows the use of C-c, C-x, C-v, and C-z for copy, cut, paste, undo, etc., and I’ve downloaded Aquamacs which appears to use most of the standard Mac keybindings (using the more standard command key rather than the control key). The main thing I would like to be able to do is to use the standard (on Mac) command-i, command-b, and command-u to toggle italics, bold, and underline, respectively, in org-mode, inserting or removing the relevant emphasis marks around the selected region (or point, if nothing is selected). The closest solution I’ve found so far is a configuration called emacs-org-mode-for-the-laity, but its keybindings for *removing* italics, bold, or underline from a selection are non-standard, requiring the use of the shift key. I'm surprised not to have found an existing simple way of implementing this (I'm currently using an extension that does exactly this for markdown syntax in Visual Studio Code). This makes me think that it may be trickier to set this up in org-mode than one might think. Would it be particularly difficult to set this up in org-mode? Is there an existing package that I've overlooked that allows for this functionality? # Answer > 2 votes This works for me (using general), though it doesn't remove markup, so perhaps YMMV. See also this stack exchange answer: Unable to bind emphasize key in org-mode See also: org-appear for showing and hiding markup. Note that below requires expand region as well. ``` (general-define-key :states '(normal insert) :keymaps 'org-mode-map "s-b" (lambda () (interactive) (er/mark-word) (org-emphasize ?\*)) "s-i" (lambda () (interactive) (er/mark-word) (org-emphasize ?\/)) "s-l" (lambda () (interactive) (er/mark-word) (org-emphasize ?\=)) ;; better pasting behavior in org-mode "s-v" 'org-yank)) ``` --- Tags: org-mode, key-bindings, faces, cua-mode, org-emphasis ---
thread-63886
https://emacs.stackexchange.com/questions/63886
Large org-mode file causes error "Re-entering top level after C stack overflow"
2021-03-13T17:01:31.333
# Question Title: Large org-mode file causes error "Re-entering top level after C stack overflow" I use org-mode quite a lot and of late I have noticed one of my larger org-mode files has caused Emacs to throw this error: ``` Re-entering top level after C stack overflow ``` I tried debugging using the usual debugging mechanisms, including debugging a single function \[1\] but I could not get any additional information on the problem. Note also that I used the file for a very long time without seeing any problems, and I have much larger org-mode files which do not suffer from this issue. \[1\] https://stackoverflow.com/questions/8273546/emacs-how-to-see-how-to-debug-a-single-elisp-function-emacs-command # Answer In the end, the solution to all my woes was as per this reddit question \[1\], which I quote verbatim: > What ultimately fixed it was deleting the unto-treehistory file corresponding to the Org file I was trying to open. The history file itself was a good 280k, probably the largest of all of my undo tree history files. I periodically commit my Org changes to Git, so having that whole history stored is not even providing any value in the long-term, so deleting it was no problem. I addressed my issue by first disabling `undo-tree-mode`, at which point I could use Emacs normally again including saving the file. I then found the undo-tree file by looking at the messages buffer, where you should see something like: ``` Wrote /tmp/.!home!${VERY_LONG_PATH}!${FILE_NAME}.org.~undo-tree~ ``` You can safely delete this file and re-enable undo-tree and Emacs should return back to normal. \[1\] https://www.reddit.com/r/emacs/comments/9fs8pp/reentering\_top\_level\_after\_c\_stack\_overflow/ > 4 votes --- Tags: org-mode, undo-tree-mode ---
thread-34684
https://emacs.stackexchange.com/questions/34684
How to directly complete org-mode tags with helm?
2017-08-04T23:11:59.120
# Question Title: How to directly complete org-mode tags with helm? When using `org-set-tags` in org-mode headings, the somewhat clunky `*Org tags*` selection buffer is shown by default. I always press `tab` in order to switch to `helm-mode-org-set-tags`, which lets me choose from the list of defined tags with the usual fuzzy matching. Is there a way to arrive at `helm-mode-org-set-tags` without detour? # Answer > 1 votes The latest `helm-org` version currently published to melpa links to this GitHub revision. The README contains the following snippet in the configuration section that worked for me ``` (add-to-list 'helm-completing-read-handlers-alist '(org-capture . helm-org-completing-read-tags)) (add-to-list 'helm-completing-read-handlers-alist '(org-set-tags . helm-org-completing-read-tags)) ``` --- Tags: helm, completion, org-tags ---
thread-63891
https://emacs.stackexchange.com/questions/63891
Highlight all words in a line
2021-03-13T22:40:23.997
# Question Title: Highlight all words in a line Is there an easy way to highlight all the words in a line with just one command? I'm trying to write an elisp function to achieve this but my knowledge is pretty rudimentary. So far, I can only move the point to the beginning of the line and highlight the word there: ``` (defun hx () "Highlight all words in a line." (interactive) (beginning-of-line) ;; Split string based on comma-separator (let ((mylist (split-string (thing-at-point 'line t) ",")))) (highlight-symbol-at-point) ) ``` I was hoping to iterate over `mylist` and use `re-search-forward` to find the first occurrence of each word in the list, move the point to that word and then highlight it. However, `mylist` contains an empty list. Even if `mylist` contained a list of words, I don't know if the above approach would actually work. # Answer `mylist` is only usable inside the body of `let`. your `(highlight-symbol-at-point)` is not inside of this `let` Btw. `highlight-symbol-at-point` is just a alias for `hi-lock-face-symbol-at-point` (use `M-.` to get to the source code). So I took the source code of latter and your code and combined it into a working version: ``` (defun hx () "Highlight all words in a line." (interactive) (beginning-of-line) ;; Split string based on comma-separator (let ((mylist (split-string (thing-at-point 'line t) ","))) (dolist (item mylist) (let ((hi-lock-auto-select-face t) (face (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) (hi-lock-set-pattern item face))))) ``` Note, that you are splitting that line at `,`, not `space`. `(beginning-of-line)` is not needed. Note, you might need to `(require 'hi-lock)` before using this function. Note, this function uses (with default Emacs settings) different colors for every (different) string. It is asking which color to use at the minibuffer. > 1 votes --- Tags: font-lock, highlighting ---
thread-63880
https://emacs.stackexchange.com/questions/63880
How to get package `dired-icon` to show icon images in Dired?
2021-03-13T00:45:34.807
# Question Title: How to get package `dired-icon` to show icon images in Dired? I installed the package dired-icon and restarted Emacs. I then ran ``` M-x dired-icon-mode ``` But no icon shows up in Dired mode and in the minibuffer the following message is shown: ``` Opened text-plain.png in external program ``` In my `init.el` file: ``` (add-to-list 'load-path "~/.emacs.d/elpa/openwith") ;; https://github.com/emacsmirror/openwith (require 'openwith) ;; Settings for package "openwith" (when (require 'openwith nil 'noerror) (setq openwith-associations (list (list (openwith-make-extension-regexp '("doc" "docx" "rtf")) "word" '(file)) (list (openwith-make-extension-regexp '("mpg" "mpeg" "mp3" "mp4" "avi" "wmv" "wav" "mov" "mkv")) "vlc" '(file)) (list (openwith-make-extension-regexp '("pdf")) "FoxitReader" '(file)) (list (openwith-make-extension-regexp '("bmp" "gif" "jpeg" "jpg" "png" "tif")) "xnview" '(file)) (list (openwith-make-extension-regexp '("rdp")) "Remote Desctop Connection" '(file)) (list (openwith-make-extension-regexp '("xls" "xlsx")) "excel" '(file)) )) (openwith-mode 1)) ``` ## Versions Linux Mint 20 Emacs 26.3 What do I need to do, to see icons in Dired? # Answer The issue is that `openwith` is set to open any `.png` file with the external program `xnview`. Remove `"png"` from the fourth `openwith-make-extension-regexp` list and reload. Now emacs will handle the `.png`file natively if it can. > 2 votes --- Tags: dired, images, linux ---
thread-61899
https://emacs.stackexchange.com/questions/61899
Symbol's function definition is void: rx-let
2020-11-23T16:05:21.557
# Question Title: Symbol's function definition is void: rx-let Whenever I try to use elpy, or even just fontlock (with elpy disabled) in a python file, I get the error that rx-let is void. This is what I got from `--debug-init`: ``` Debugger entered--Lisp error: (void-function rx-let) (rx-let ((block-start (seq symbol-start (or "def" "class" "if" "elif" "else" "try" "except" "finally" "for" "while" "with" (and "async" (+ space) (or "de$ (python-rx line-start (* space) defun (+ space) (group symbol-name)) (defvar python-nav-beginning-of-defun-regexp (python-rx line-start (* space) defun (+ space) (group symbol-name)) "Regexp matching class or function defi$ eval-buffer(#<buffer *load*-951749> nil "/home/ben/.emacs.d/elpa/python-0.27/python.el" nil t) ; Reading at buffer position 60382 ``` I am using the Ubuntu 26.3 Build. This is just driving me nuts. I tried searching for this error, but I didn't get any results. Requesting for help. # Answer Solution for me: `M-x` `package-delete` then `python-0.27.1`. Ubuntu 20.10, emacs 26.3 (from distro). I had installed python-0.27.1 (via Options \> Manage Emacs Packages) after naively assuming that anything offered for installation was workable. Oops. > 1 votes # Answer From @Basil's suggestion, that my python.el was a newer version, I decided to re-install my emacs. The following worked: ``` sudo apt remove emacs-gtk sudo apt install emacs-gtk ``` I don't know why, but I think even though python.el was built-in, the wrong version was installed. Re-installing has fixed that. > 0 votes --- Tags: python, elpy, require, rx ---
thread-63898
https://emacs.stackexchange.com/questions/63898
Org-babel: Notify if the result of execution differs from the previous recorded result
2021-03-14T16:05:25.527
# Question Title: Org-babel: Notify if the result of execution differs from the previous recorded result I want to use my org-mode documentation as a sort of quasi-unittest; I want to execute the whole buffer, and be notified if marked cells' new results differ from their previous results. E.g, ``` #+begin_src python :results verbatim :exports both :wrap example :notify_on_change x3(10) #+end_src #+RESULTS: #+begin_example 30 #+end_example ``` Suppose `x3` is changed and now `x3(10)` returns `40`. I want to be notified that this change has happened (and get a diff of the two results). PS: If this should be possible for visual (image) results, it would be really awesome. PPS: Is there any testing framework that works like this? I.e., it only reports change, and does not need you to manually hardcode values? # Answer One idea might be to save a copy of the current buffer, run the tests, and then run a diff command on them. ``` (defun run-tests () (interactive) (copy-to-buffer "*my-test*" (point-min) (point-max)) (org-babel-execute-buffer) (diff-buffers "*my-test*" (current-buffer))) ``` This will make a new buffer showing the diff (if any). There are lots of variations I suppose, like writing to files, different ways of diffing. It would be hard I think to get this to work for images. \[edit\]: here is a version that works on a copy of the buffer with ediff. ``` (defun run-tests () (interactive) (let ((contents (buffer-string)) (buf (current-buffer))) (with-current-buffer (get-buffer-create "*my-test*") (erase-buffer) (insert contents) (org-mode) (org-babel-execute-buffer) (ediff-buffers buf "*my-test*")))) ``` > 2 votes --- Tags: org-mode, org-babel, testing ---
thread-63896
https://emacs.stackexchange.com/questions/63896
How to match emacs column count to gofmt column count?
2021-03-14T13:54:27.717
# Question Title: How to match emacs column count to gofmt column count? I am writing Go code but the error messages do not agree with Emacs' column count. Is there an off-the-shelf solution for this? I'm wondering about a minor mode or even a few lines for my `.emacs` file. I've tried searching but haven't found anything. I can't be the only one who has come across this and I'm sure it's not just Go that has this issue. ### Background * My `tab-width` is set to 4. * My Emacs counts `\t` (tab) as four columns; go and gofmt counts `\t` as one column. * Emacs starts counting columns from 0; gofmt starts counting from 1. (I can solve this) * gofmt, which runs whenever I save a Go file, puts tabs instead of spaces at the start of each line. (I like this standardisation.) * I'm running Emacs 24.5. (This is the latest version available on the Long Term Support Linux distribution I'm using.) The main problem comes from the discrepancy between the tab counts. The secondary issue is the column count in Emacs starting from 0 instead of 1. # Answer This sounds like an X–Y problem, where someone has a detailed question that we could find an answer for but that seems to be leading them in the wrong direction. Since you haven’t said what you’re really trying to accomplish here, we can only guess. My guess is that `next-error` (or other ways of navigating to error locations, such as clicking on them) is taking you to the wrong column, because of the odd way that gofmt reports error locations. The bad news is that there’s no good way to transform the error locations before you call `next-error`. The good news is that you can fix this *after* you invoke `next-error`. Emacs identifies errors by using `compilation-error-regexp-alist`, which is an index into all the available regexes for matching error messages and extracting their line and column numbers. You should use `C-h v` to pull up the documentation and familiarize yourself with the details, though they’re not directly useful. The regexes don’t provide you with any way to do math on the column number, but it’s useful background information. If you check the help for `next-error`, however, you will find that it calls hook functions after it does the main job. The variable `next-error-hook` holds a list of functions to call right after moving to the error location. If you add a function to this list, you can move to the correct point. Perhaps something like this: ``` (defun db48x/go-next-error-hook () (let ((col (current-column))) (move-beginning-of-line nil) (right-char col))) (add-hook 'next-error-hook #'db48x/go-next-error-hook) ``` This is pretty simple; it just moves back to the beginning of the line, then moves over the right number of characters, counting tabs as one character. You can find elsewhere how to add this hook only in buffers that are visiting a go file. Also, I should point out that this problem is apparently already handled correctly in Emacs 27.1. I don’t know what version it was fixed in, but given the number of new features and bug fixes that have gone in since Emacs 24, I recommend upgrading. Even in the long–term support version of an OS you deserve to have the best possible editor. Naturally, if this answer doesn’t solve your problem, feel free to amend your question to supply additional information. > 2 votes --- Tags: tabs, column, golang ---
thread-63795
https://emacs.stackexchange.com/questions/63795
why do I need to use ctrl-G twice to quit a minibuffer prompt?
2021-03-08T14:41:36.247
# Question Title: why do I need to use ctrl-G twice to quit a minibuffer prompt? Sometime recently emacs started making me hit `C-g` twice to quit a minibuffer prompt and I can't figure out how or why it's doing this. What happens is I start a minibuffer command -- say, `C-x C-f` -- and then hit `C-g` to quit. Emacs then appends "`[Quit]` to the end of the minibuffer prompt, and doing `C-g` quits as expected. It's the `[Quit]` that strikes me. I think that's related to some package I tried, but I don't see anything in my configuration. I'm using emacs 27.1 on Windows. There are several seemingly-related questions to this -- ...but they seem to be about Linux, or GTK, or something else. What package or configuration might cause this behavior? # Answer This was a dependency package -- org-random-todo depends on alert. Uninstalling and reinstalling `org-random-todo` seems to have cleared up the problem. So something in the installation seems to have gotten mixed up. > 1 votes --- Tags: minibuffer, quitting ---
thread-63913
https://emacs.stackexchange.com/questions/63913
Latex-preview not working; Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’
2021-03-15T18:46:41.177
# Question Title: Latex-preview not working; Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’ i have a strange problem with latex-preview. If the cursor is inside ``` \begin{equation} \frac{n!}{k!(n-k)!} = \binom{n}{k} \end{equation} ``` then the tex file is created and a resulting pdf. BUT no svg file and no preview. the resulting log-file does not contain any special, as far as i see. ``` This is LuaHBTeX, Version 1.12.0 (TeX Live 2020) (format=lualatex 2020.11.8) 15 MAR 2021 19:34 restricted system commands enabled. **/tmp/orgtexlLgQbd.tex (/tmp/orgtexlLgQbd.tex LaTeX2e <2020-02-02> patch level 5 Lua module: luaotfload-main 2020-05-06 3.14 luaotfload entry point Lua module: luaotfload-init 2020-05-06 3.14 luaotfload submodule / initializatio n Lua module: lualibs 2020-02-02 2.70 ConTeXt Lua standard libraries. Lua module: lualibs-extended 2020-02-02 2.70 ConTeXt Lua libraries -- extended c ollection. Lua module: luaotfload-log 2020-05-06 3.14 luaotfload submodule / logging Lua module: luaotfload-parsers 2020-05-06 3.14 luaotfload submodule / filelist Lua module: luaotfload-configuration 2020-05-06 3.14 luaotfload submodule / conf ig file reader luaotfload | conf : Root cache directory is "/home/held/.texlive2020/texmf-var/l uatex-cache/generic-dev/names". luaotfload | init : Loading fontloader "fontloader-2020-05-06.lua" from kpse-res olved path "/usr/share/texlive/texmf-dist/tex/luatex/luaotfload/fontloader-2020- 05-06.lua". Lua-only attribute luaotfload@noligature = 2 Lua-only attribute luaotfload@syllabe = 3 luaotfload | init : Context OpenType loader version 0x1.8e353f7ced917p+1 Lua module: luaotfload-fallback 2020-05-06 3.14 luaotfload submodule / fallback Lua module: luaotfload-multiscript 2020-05-06 3.14 luaotfload submodule / multis cript Lua module: luaotfload-script 2020-05-06 3.14 luaotfload submodule / Script help ers Inserting `luaotfload.node_processor' at position 1 in `pre_linebreak_filter'. Inserting `luaotfload.node_processor' at position 1 in `hpack_filter'. Lua module: luaotfload-loaders 2020-05-06 3.14 luaotfload submodule / callback h andling Inserting `luaotfload.define_font' at position 1 in `define_font'. Lua module: luaotfload-database 2020-05-06 3.14 luaotfload submodule / database Lua module: luaotfload-unicode 2020-05-06 3.14 luaotfload submodule / Unicode he lpers Lua module: luaotfload-colors 2020-05-06 3.14 luaotfload submodule / color Lua-only attribute luaotfload_color_attribute = 4 Lua module: luaotfload-resolvers 2020-05-06 3.14 luaotfload submodule / resolver s luaotfload | conf : Root cache directory is "/home/held/.texlive2020/texmf-var/l uatex-cache/generic-dev/names". Lua module: luaotfload-features 2020-05-06 3.14 luaotfload submodule / features Lua module: luaotfload-harf-define 2020-05-06 3.14 luaotfload submodule / databa se Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_opentype_file'. Inserting `luaotfload.harf.strip_prefix' at position 1 in `find_truetype_file'. Lua module: luaotfload-harf-plug 2020-05-06 3.14 luaotfload submodule / database Inserting `Harf pre_output_filter callback' at position 1 in `pre_output_filter' . Inserting `Harf wrapup_run callback' at position 1 in `wrapup_run'. Inserting `Harf finish_pdffile callback' at position 1 in `finish_pdffile'. Inserting `Harf glyph_info callback' at position 1 in `glyph_info'. Lua module: luaotfload-letterspace 2020-05-06 3.14 luaotfload submodule / color Lua module: luaotfload-embolden 2020-05-06 3.14 luaotfload submodule / color Lua module: luaotfload-notdef 2020-05-06 3.14 luaotfload submodule / color Lua module: luaotfload-suppress 2020-05-06 3.14 luaotfload submodule / suppress Lua module: luaotfload-szss 2020-05-06 3.14 luaotfload submodule / color Lua module: luaotfload-auxiliary 2020-05-06 3.14 luaotfload submodule / auxiliar y functions Inserting `luaotfload.aux.set_sscale_dimens' at position 1 in `luaotfload.patch_ font'. Inserting `luaotfload.aux.set_font_index' at position 2 in `luaotfload.patch_fon t'. Inserting `luaotfload.aux.patch_cambria_domh' at position 3 in `luaotfload.patch _font'. Inserting `luaotfload.aux.fixup_fontdata' at position 1 in `luaotfload.patch_fon t_unsafe'. Inserting `luaotfload.aux.set_capheight' at position 4 in `luaotfload.patch_font '. Inserting `luaotfload.aux.set_xheight' at position 5 in `luaotfload.patch_font'. Lua module: luaotfload-tounicode 2020-05-06 3.14 luaotfload submodule / tounicod e Inserting `luaotfload.rewrite_fontname' at position 6 in `luaotfload.patch_font' . L3 programming layer <2020-04-06> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2019/12/20 v1.4l Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option) luaotfload | db : Font names database loaded from /home/held/.texlive2020/texmf- var/luatex-cache/generic-dev/names/luaotfload-names.luc) \c@part=\count163 \c@section=\count164 \c@subsection=\count165 \c@subsubsection=\count166 \c@paragraph=\count167 \c@subparagraph=\count168 \c@figure=\count169 \c@table=\count170 \abovecaptionskip=\skip47 \belowcaptionskip=\skip48 \bibindent=\dimen134 ) (/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty Package: color 2019/11/23 v1.2a Standard LaTeX Color (DPC) (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg File: color.cfg 2016/01/02 v1.6 sample color configuration ) Package color Info: Driver file: luatex.def on input line 147. (/usr/share/texlive/texmf-dist/tex/latex/graphics-def/luatex.def File: luatex.def 2018/01/08 v1.0l Graphics/color driver for luatex )) (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty (/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty (/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty Package: expl3 2020-04-06 L3 programming layer (loader) (/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def File: l3backend-pdfmode.def 2020-03-12 L3 backend support: PDF mode \l__kernel_color_stack_int=\count171 \l__pdf_internal_box=\box45 )) Package: xparse 2020-03-06 L3 Experimental document command parser \l__xparse_current_arg_int=\count172 \g__xparse_grabber_int=\count173 \l__xparse_m_args_int=\count174 \l__xparse_v_nesting_int=\count175 ) Package: fontspec 2020/02/21 v2.7i Font selection for XeLaTeX and LuaLaTeX Lua module: fontspec 2020/02/21 2.7i Font selection for XeLaTeX and LuaLaTeX (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty Package: fontspec-luatex 2020/02/21 v2.7i Font selection for XeLaTeX and LuaLaTe X \l__fontspec_script_int=\count176 \l__fontspec_language_int=\count177 \l__fontspec_strnum_int=\count178 \l__fontspec_tmp_int=\count179 \l__fontspec_tmpa_int=\count180 \l__fontspec_tmpb_int=\count181 \l__fontspec_tmpc_int=\count182 \l__fontspec_em_int=\count183 \l__fontspec_emdef_int=\count184 \l__fontspec_strong_int=\count185 \l__fontspec_strongdef_int=\count186 \l__fontspec_tmpa_dim=\dimen135 \l__fontspec_tmpb_dim=\dimen136 \l__fontspec_tmpc_dim=\dimen137 (/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty Package: fontenc 2020/02/11 v2.0o Standard LaTeX package ) (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty Package: graphicx 2019/11/30 v1.2a Enhanced LaTeX Graphics (DPC,SPQR) (/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty Package: keyval 2014/10/28 v1.15 key=value parser (DPC) \KV@toks@=\toks15 ) (/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty Package: graphics 2019/11/30 v1.4a Standard LaTeX Graphics (DPC,SPQR) (/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty Package: trig 2016/01/03 v1.10 sin cos tan (DPC) ) (/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration ) Package graphics Info: Driver file: luatex.def on input line 105. ) \Gin@req@height=\dimen138 \Gin@req@width=\dimen139 ) (/usr/share/texlive/texmf-dist/tex/latex/grffile/grffile.sty Package: grffile 2019/11/11 v2.1 Extended file name support for graphics (legacy ) Package grffile Info: This package is an empty stub for compatibility on input l ine 40. ) (/usr/share/texlive/texmf-dist/tex/generic/ulem/ulem.sty \UL@box=\box46 \UL@hyphenbox=\box47 \UL@skip=\skip49 \UL@hook=\toks16 \UL@height=\dimen140 \UL@pe=\count187 \UL@pixel=\dimen141 \ULC@box=\box48 Package: ulem 2019/11/18 \ULdepth=\dimen142 ) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty Package: amsmath 2020/01/20 v2.17e AMS math features \@mathmargin=\skip50 For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty Package: amstext 2000/06/29 v2.01 AMS text (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty File: amsgen.sty 1999/11/30 v2.0 generic functions \@emptytoks=\toks17 \ex@=\dimen143 )) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty Package: amsbsy 1999/11/29 v1.2d Bold Symbols \pmbraise@=\dimen144 ) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty Package: amsopn 2016/03/08 v2.02 operator names ) \inf@bad=\count188 LaTeX Info: Redefining \frac on input line 227. \uproot@=\count189 \leftroot@=\count190 LaTeX Info: Redefining \overline on input line 389. \classnum@=\count191 \DOTSCASE@=\count192 LaTeX Info: Redefining \ldots on input line 486. LaTeX Info: Redefining \dots on input line 489. LaTeX Info: Redefining \cdots on input line 610. \Mathstrutbox@=\box49 \strutbox@=\box50 \big@size=\dimen145 LaTeX Font Info: Redeclaring font encoding OML on input line 733. LaTeX Font Info: Redeclaring font encoding OMS on input line 734. \macc@depth=\count193 \c@MaxMatrixCols=\count194 \dotsspace@=\muskip16 \c@parentequation=\count195 \dspbrk@lvl=\count196 \tag@help=\toks18 \row@=\count197 \column@=\count198 \maxfields@=\count199 \andhelp@=\toks19 \eqnshift@=\dimen146 \alignsep@=\dimen147 \tagshift@=\dimen148 \tagwidth@=\dimen149 \totwidth@=\dimen150 \lineht@=\dimen151 \@envbody=\toks20 \multlinegap=\skip51 \multlinetaggap=\skip52 \mathdisplay@stack=\toks21 LaTeX Info: Redefining \[ on input line 2859. LaTeX Info: Redefining \] on input line 2860. ) (/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty Package: textcomp 2020/02/02 v2.0n Standard LaTeX package ) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty Package: amssymb 2013/01/14 v3.01 AMS font symbols (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support \symAMSa=\mathgroup4 \symAMSb=\mathgroup5 LaTeX Font Info: Redeclaring math symbol \hbar on input line 98. LaTeX Font Info: Overwriting math alphabet `\mathfrak' in version `bold' (Font) U/euf/m/n --> U/euf/b/n on input line 106. )) No file orgtexlLgQbd.aux. \openout1 = orgtexlLgQbd.aux LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 31. LaTeX Font Info: Trying to load font information for TS1+cmr on input line 31 . (/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions ) LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 31. LaTeX Font Info: ... okay on input line 31. (/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii [Loading MPS to PDF converter (version 2006.09.02).] \scratchcounter=\count266 \scratchdimen=\dimen152 \scratchbox=\box51 \nofMPsegments=\count267 \nofMParguments=\count268 \everyMPshowfont=\toks22 \MPscratchCnt=\count269 \MPscratchDim=\dimen153 \MPnumerator=\count270 \makeMPintoPDFobject=\count271 \everyMPtoPDFconversion=\toks23 ) (/usr/share/texlive/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 48 5. (/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live )) Package fontspec Info: Adjusting the maths setup (use [no-math] to avoid (fontspec) this). \symlegacymaths=\mathgroup6 LaTeX Font Info: Overwriting symbol font `legacymaths' in version `bold' (Font) OT1/cmr/m/n --> OT1/cmr/bx/n on input line 31. LaTeX Font Info: Redeclaring math accent \acute on input line 31. LaTeX Font Info: Redeclaring math accent \grave on input line 31. LaTeX Font Info: Redeclaring math accent \ddot on input line 31. LaTeX Font Info: Redeclaring math accent \tilde on input line 31. LaTeX Font Info: Redeclaring math accent \bar on input line 31. LaTeX Font Info: Redeclaring math accent \breve on input line 31. LaTeX Font Info: Redeclaring math accent \check on input line 31. LaTeX Font Info: Redeclaring math accent \hat on input line 31. LaTeX Font Info: Redeclaring math accent \dot on input line 31. LaTeX Font Info: Redeclaring math accent \mathring on input line 31. LaTeX Font Info: Redeclaring math symbol \Gamma on input line 31. LaTeX Font Info: Redeclaring math symbol \Delta on input line 31. LaTeX Font Info: Redeclaring math symbol \Theta on input line 31. LaTeX Font Info: Redeclaring math symbol \Lambda on input line 31. LaTeX Font Info: Redeclaring math symbol \Xi on input line 31. LaTeX Font Info: Redeclaring math symbol \Pi on input line 31. LaTeX Font Info: Redeclaring math symbol \Sigma on input line 31. LaTeX Font Info: Redeclaring math symbol \Upsilon on input line 31. LaTeX Font Info: Redeclaring math symbol \Phi on input line 31. LaTeX Font Info: Redeclaring math symbol \Psi on input line 31. LaTeX Font Info: Redeclaring math symbol \Omega on input line 31. LaTeX Font Info: Redeclaring math symbol \mathdollar on input line 31. LaTeX Font Info: Redeclaring symbol font `operators' on input line 31. LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font (Font) `operators' in the math version `normal' on input line 31. LaTeX Font Info: Overwriting symbol font `operators' in version `normal' (Font) OT1/cmr/m/n --> TU/lmr/m/n on input line 31. LaTeX Font Info: Encoding `OT1' has changed to `TU' for symbol font (Font) `operators' in the math version `bold' on input line 31. LaTeX Font Info: Overwriting symbol font `operators' in version `bold' (Font) OT1/cmr/bx/n --> TU/lmr/m/n on input line 31. LaTeX Font Info: Overwriting symbol font `operators' in version `normal' (Font) TU/lmr/m/n --> TU/lmr/m/n on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathit' in version `normal' (Font) OT1/cmr/m/it --> TU/lmr/m/it on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathbf' in version `normal' (Font) OT1/cmr/bx/n --> TU/lmr/b/n on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `normal' (Font) OT1/cmss/m/n --> TU/lmss/m/n on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `normal' (Font) OT1/cmtt/m/n --> TU/lmtt/m/n on input line 31. LaTeX Font Info: Overwriting symbol font `operators' in version `bold' (Font) TU/lmr/m/n --> TU/lmr/b/n on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathit' in version `bold' (Font) OT1/cmr/bx/it --> TU/lmr/b/it on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathsf' in version `bold' (Font) OT1/cmss/bx/n --> TU/lmss/b/n on input line 31. LaTeX Font Info: Overwriting math alphabet `\mathtt' in version `bold' (Font) OT1/cmtt/m/n --> TU/lmtt/b/n on input line 31. \GPT@outputbox=\box52 LaTeX Font Info: Trying to load font information for U+msa on input line 38. (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd File: umsa.fd 2013/01/14 v3.01 AMS symbols A ) LaTeX Font Info: Trying to load font information for U+msb on input line 38. (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd File: umsb.fd 2013/01/14 v3.01 AMS symbols B ) [1 {/usr/share/texlive/texmf-dist/fonts/map/pdftex/updmap/pdftex.map}] (/tmp//orgt exlLgQbd.aux)) Here is how much of LuaTeX's memory you used: 5099 strings out of 480991 100000,460012 words of node,token memory allocated 487 words of node memory still in use: 6 hlist, 2 vlist, 2 rule, 2 glue, 4 kern, 1 glyph, 8 attribute, 51 glue_spec, 8 attribute_list, 1 write nodes avail lists: 2:79,3:32,4:6,5:33,6:2,7:45,8:31,9:59 22474 multiletter control sequences out of 65536+600000 47 fonts using 4814611 bytes 44i,7n,40p,239b,122s stack positions out of 5000i,500n,10000p,200000b,100000s </usr/share/texlive/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></ usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/sha re/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texl ive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texlive/texm f-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb> Output written on orgtexlLgQbd.pdf (1 page, 34227 bytes). PDF statistics: 31 PDF objects out of 1000 (max. 8388607) 20 compressed objects within 1 object stream 0 named destinations out of 1000 (max. 131072) 1 words of extra memory for PDF output out of 10000 (max. 100000000) ``` Here are the relevant latex configs. ``` ;; Latex Einstellungen (setq org-latex-compiler "lualatex") (setq org-preview-latex-image-directory "~/ltximg/") (setq org-preview-latex-process-alist '((dvisvgm :programs ("lualatex" "dvisvgm") :description "dvi > svg" :message "you need to install the programs: lualatex and dvisvgm." :image-input-type "dvi" :image-output-type "svg" :image-size-adjust (1.7 . 1.5) :latex-compiler ("lualatex -interaction nonstopmode -output-directory %o %f") :image-converter ("dvisvgm %f -n -b min -c %S -o %O") ) ) ) (setq org-latex-default-packages-alist '( ("" "fontspec" t nil) ("" "graphicx" t nil) ("" "grffile" t nil) ("" "longtable" nil nil) ("" "wrapfig" nil nil) ("" "rotating" nil nil) ("normalem" "ulem" t nil) ("" "amsmath" t nil) ("" "textcomp" t nil) ("" "amssymb" t nil) ("" "capt-of" nil nil) ("" "hyperref" nil nil) ("" "bookmark" nil nil) )) (setq org-preview-latex-default-process 'dvisvgm) ``` I use Emacs 28 with the latest org-mode version on Linux Fedora. Does anybody know how this possible? Regards Poul # Answer > 1 votes `lualatex` seems to produce a PDF. The `dvisvgm` process expected a `dvi` file. Try changing the setting for `dvisvgm` to ("latex" "dvisvgm"). `latex` produces a `dvi` that `dvisvgm` can then consume. Alternatively, you can ask `lualatex` to produce a `dvi` instead of PDF, by changing the entry to `("lualatex --output-format=dvi" "dvisgvgm")`. Untested. --- Tags: org-mode, preview-latex ---
thread-63713
https://emacs.stackexchange.com/questions/63713
AppleScript wrapper for pdf viewer fails to complete
2021-03-03T18:24:26.397
# Question Title: AppleScript wrapper for pdf viewer fails to complete My setup is 2020 MacBook Pro M1 (Apple silicon), Big Sur 11.2.2, MacPorts, emacs-mac-app, AucTeX, and PDF Expert. I am trying to get C-c C-c (View) to open PDF Expert at the right page. I'm almost there, but my AppleScript wrapper for PDF Expert is not completing properly. The AppleScript wrapper, ~/bin/pdfe, is below. It is invoked as "pdfe filename page-number". It works fine from the command line, but does not seem to execute the "tell" portion when executed through Emacs `(setq TeX-view-program-list '(("PDFExpert" "pdfe %o %(outpage)")))`. ``` #!/usr/bin/osascript use framework "Foundation" use scripting additions on run argv set arguments to (current application's NSProcessInfo's processInfo's arguments) as list do shell script "open -a \"PDF Expert\" " & item 3 of arguments activate application "PDF Expert" tell application "System Events" tell process "PDF Expert" click menu item "Go to Page..." of menu 1 of menu bar item "Go" of menu bar 1 keystroke item 4 of arguments key code 36 end tell end tell end run ``` I have taken some pains to ensure that Emacs is running in my usual login environment including PATH, so I'm reasonably confident that isn't the problem (but I can supply my Emacs startup script if requested). I have tried it with and without dbus running. I have tried putting delays all over. I have tried putting popup messages at various places, and found that the script just seems to stop dead before or during the first `tell`. I suspect there might be a permissions issue. Emacs I think has all the permissions it needs, but I don't understand enough about the situation to know how exactly the script is forking from Emacs, or how to enable the necessary permissions. --- EDIT: I tried Emacs in an iTerm2 windows, invoking with `/Applications/MacPorts/EmacsMac.app/Contents/MacOS/Emacs -nw`, and the `pdfe` script runs perfectly, after I enabled Accessibility for iTerm2. I have now also enabled Accessibility in Terminal, and my Emacs GUI version still does not have the right permissions. --- EDIT 2: I tried running GUI Emacs by invoking with `/Applications/MacPorts/EmacsMac.app/Contents/MacOS/Emacs`, and the `pdfe` script again runs perfectly, so it seems the issue is with the way I start up GUI Emacs. So here is my startup script, which I based on Emacs Wiki with a small modification to stop the Automator gear from turning indefinitely: ``` EMACS=/Applications/MacPorts/EmacsMac.app/Contents/MacOS/Emacs EMACSCLIENT=/Applications/MacPorts/EmacsMac.app/Contents/MacOS/bin/emacsclient cd # start in my home directory if pgrep -U $(id -u) $(basename $EMACS) >/dev/null; then if [ "$#" -eq 0 ]; then # set -- -e '(select-frame-set-input-focus (car (or (visible-frame-list) (frame-list)))' echo "\"$EMACSCLIENT\" -e '(select-frame-set-input-focus (car (or (visible-frame-list) (frame-list))))'" | bash --login -s "$@" ; else echo "\"$EMACSCLIENT\" -n \"\$@\"" | bash --login -s "$@" ; fi else nohup bash --login -c "$EMACS "$@"" >/dev/null 2>&1 & fi ``` # Answer After trying it out for a while, I've found that the script works fine until PDF Expert encounters an error of some kind, then PDF Expert seems to stop taking the go to page command. I've found that closing and then opening PDF Expert (or just the window in question) seems to reset it, and then the script works fine until the next error. The best way to solve this problem once and for all is to modify PDF Expert to accept a command line option to "go to page ...". I've submitted a feature request to them. In the mean time, I'll check out some other PDF viewers, and I'll just have to remember to close the PDF window(s) when it starts acting up. > 0 votes --- Tags: auctex ---
thread-63912
https://emacs.stackexchange.com/questions/63912
How to remove an org-mode entry's effort property while viewing the agenda?
2021-03-15T17:49:57.687
# Question Title: How to remove an org-mode entry's effort property while viewing the agenda? Is there any way to completely delete an entry's effort property from within the org-mode agenda? Ideally, I'd also like to be able to bulk remove efforts from the agenda view. "org-agenda-set-effort" doesn't provide a method to remove the property. # Answer > 2 votes There are three parts to the answer: * write a function that deletes an `Effort` entry from the properties drawer of the current headline. * write the corresponding `agenda` function that calls the function above "remotely"; i.e. you call the agenda function in the agenda and it in turn switches context to the headline in the file and calls the first function above. * add an entry for the `agenda` function to `org-agenda-bulk-custom-functions`, consisting of the character that you use to call the agenda function and the *symbol* corresponding to the name of the function. There are plenty of examples of remote functions in the Org mode sources, so I just copied the code from the `org-agenda-set-effort` function and changed the local function that it calls, to come up with the following code (seems to work; very lightly tested): ``` #+begin_src elisp :results drawer (defun org-delete-effort () (interactive) (org-entry-delete (point) org-effort-property)) (defun org-agenda-delete-effort () "Set the effort property for the current headline." (interactive) (org-agenda-check-no-diary) (org-agenda-maybe-loop #'org-agenda-delete-effort nil nil nil (let* ((hdmarker (or (org-get-at-bol 'org-hd-marker) (org-agenda-error))) (buffer (marker-buffer hdmarker)) (pos (marker-position hdmarker)) (inhibit-read-only t) newhead) (org-with-remote-undo buffer (with-current-buffer buffer (widen) (goto-char pos) (org-show-context 'agenda) (call-interactively 'org-delete-effort) (end-of-line 1) (setq newhead (org-get-heading))) (org-agenda-change-all-lines newhead hdmarker))))) (add-to-list 'org-agenda-bulk-custom-functions '(?Y org-agenda-delete-effort)) #+end_src ``` So you mark the entries in the agenda, then do `B Y` to delete efforts. I chose `Y` as the character to call the function because it was not being used for any other bulk operation (in my case - YMMV). This can obviously be used as a template for other such remote operations. --- Tags: org-mode, org-agenda ---
thread-24377
https://emacs.stackexchange.com/questions/24377
hs-minor-mode with python.el - hide if statements, for/while loops, etc
2016-07-05T05:41:52.047
# Question Title: hs-minor-mode with python.el - hide if statements, for/while loops, etc Currently, I use the `hs-minor-mode` to collapse my python code and make it easier to work with - however, by default this only folds `def my_function():` blocks. Is it possible to get it to work with `if`, `for`, `while` etc. blocks as well? If not, does anyone know a better option for code folding? I do use `C-s` and `M-x occur` to move around my code already, I just sometimes like to fold my code so I don't have so much to look at. # Answer After a little more looking around, I found: Which can do what I wanted (and possibly a little more). I haven't thoroughly tested them both out, but on first impression, yafolding is working the best so far on python.el. > 2 votes # Answer I use spacemacs distro and was struggling with this issue. Use this gist to get `hideshow` folding to work with indentation. Edit: Sure Drew, here's the elaboration. 1. Add both the snippets found in the link to `user-init()` function of .spacemacs file 2. Call `hs-hide-level` using `M-x` or keybind it, the way shown below ``` (with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "zs") 'hs-hide-level)) ``` right after the pasted snippets 3. Profit :) > 0 votes --- Tags: python, code-folding ---
thread-60808
https://emacs.stackexchange.com/questions/60808
US-Intl layout EU users of Emacs in WSL - how do you input those Alt-Gr characters?
2020-09-23T11:33:34.173
# Question Title: US-Intl layout EU users of Emacs in WSL - how do you input those Alt-Gr characters? I am a user of the US-International keyboard layout and the German language. Somehow Emacs does not allow me to access those Alt-Gr characters for example the German Eszett "ß" and many others: How do you access those characters in Emacs? Edit: I'm calling emacs from WSL (Debian is installed) in Windows 10, displaying emacs through the VcXsrv X Server. Within Windows 10, Eszett "ß" can be access by pressing AltGr + S, for applications such as Notepad. However, this doesn't work in this emacs: basically none of the AltGr combinations work, and only those dead keys work to create modified characters, e.g. ä, ö, ü. # Answer Just found this issue, looking around the internet I came across this page, and the solution is at the bottom, basically you have to set the keyboard mapping with the following command on the Debian terminal: ``` setxkbmap us -variant intl ``` I use US-INTL, so from what I am reading on your question, this is your case too. Finally you might want to add it to your `.profile`, `.bashrc`, o wherever you need it. > 2 votes # Answer I am using EurKEY as my keyboard layout. This allows me to use the right `Alt` key as a modifier for those special characters. > 0 votes --- Tags: character-encoding, keyboard-layout, wsl ---
thread-63925
https://emacs.stackexchange.com/questions/63925
How to make Auctex TeX-command-Show do nothing?
2021-03-16T16:30:19.417
# Question Title: How to make Auctex TeX-command-Show do nothing? When I use `C-a` to compile a source tex file, its final step is to call Evince to display the pdf (through `xdg-open`, I believe). However, in my computer this makes Emacs freeze for many seconds and finish with the following message: ``` LaTeX: successfully formatted {16} pages error in process sentinel: dbus-call-method: D-Bus error: "Message recipient disconnected from message bus without replying" error in process sentinel: D-Bus error: "Message recipient disconnected from message bus without replying" Unable to load color "unspecified-fg" ``` I'd rather disable the call to Evince completely than bothering trying to fix this. And I don't want to abandon `C-a` in favor or `C-c` because then I'd have to type Return to compile. How can I rebind `TeX-command-Show` to something that won't freeze Emacs? # Answer > 0 votes In AucTeX, the PDF viewer is specified via the variable `TeX-view-program-selection`. Find the entry for `output-pdf` and select a viewer you don't have. You'll get a small warning message in the mini-buffer, but otherwise you won't be interrupted. Alternatively, you could set the value to something you do have that isn't Evince, and you might solve your other problem. --- Tags: latex, auctex ---
thread-63873
https://emacs.stackexchange.com/questions/63873
ess: transform a text selection into an R vector
2021-03-12T14:32:05.090
# Question Title: ess: transform a text selection into an R vector Is there any `ess` function that does the following? Assume you have the line in Emacs like this ``` 1 2 3 4 ``` then once selected (e.g., using the mouse), it is transformed into ``` c(1,2,3,4) ``` It would be a wonderful tool. I copy and paste stuff that I transform into vectors quite often. Also, it would be great to have a function that if you select ``` A B C D E ``` it produces ``` "A", "B", "C", "D", "E" ``` # Answer > 2 votes Not a solution based on `ess`, but both of these are relatively simple to implement using Elisp. For your first example, that is, `1 2 3 4` =\> `c(1,2,3,4)`: use the Elisp functions `format` and `replace-regexp-in-string` to convert your data as text using a regular expression. Put this Elisp command somewhere in your `init.el`: ``` (defun my-command (start end) (interactive "r") (insert (prog1 (format "c(%s)" (replace-regexp-in-string "\\([[:digit:]]+\\) " "\\1," (buffer-substring-no-properties start end))) (delete-region start end)))) ``` Mark a space-separated sequence of numbers, then invoke it with `M-x my-command RET`, or bind `my-command` to the key combination of your choice for easy access. --- Tags: ess ---
thread-43684
https://emacs.stackexchange.com/questions/43684
Dynamic syntax highlighting (font-lock-mode) stops working in emacs 25.3
2018-07-18T18:23:49.143
# Question Title: Dynamic syntax highlighting (font-lock-mode) stops working in emacs 25.3 About 15-20 minutes into using emacs my syntax highlighting stops dynamically updating. Instead any new text just uses the color of the text right before it. Any ideas on how to debug this issue or any work arounds? Running `M-x global-font-lock-mode` (x2) properly refreshes it, but it doesn't re-enable the dynamic syntax highlighting. The only way to solve the issue I've found is to kill my emacs server and start a new server, but the issue eventually crops up again. Here are some screenshots of Python code which shows the behavior. Here it is properly highlighted: This is what new code looks like after it stops working: And here's how it looks after running `M-x font-lock-mode` (x2): # Answer This is normally a sign that some error occurred during font-locking. I suggest you look at the `*Messages*` buffer soon after the highlighting stops updating dynamically (it should contain some error message about it). You can try and get more info about the error with: ``` M-x font-lock-debug-mode RET M-x toggle-debug-on-error RET ``` Or with ``` M-x toggle-debug-on-error RET M-: (setq font-lock-support-mode nil) RET M-x font-lock-mode RET M-x font-lock-mode RET ``` \[ I.e. re-start font-lock so it pays attention to the new value of `font-lock-support-mode`. \] After that, try and reproduce the problem which should then give you a backtrace. > 2 votes # Answer Also check the variable `inhibit-modification-hooks` (docs). If your case is like mine, font-lock gets stuck because an error occurs in one of the modification hook functions (... not even necessarily font-lock itself), and, as a consequence: > If an unhandled error happens in running these functions, the variable's value remains nil. That prevents the error from happening repeatedly and making Emacs nonfunctional. ... but then also, after-modification functions aren't called anymore, font lock doesn't work automatically, and you won't get stack traces from the code that was actually broken, until you restart emacs, or, more conveniently: ``` (setq inhibit-modification-functions nil) ``` You can then proceed with Stefan's methods for debugging afterwards! > 1 votes --- Tags: font-lock, syntax-highlighting ---
thread-63935
https://emacs.stackexchange.com/questions/63935
EMMS: browse by folders
2021-03-17T03:53:38.593
# Question Title: EMMS: browse by folders Is there a way in EMMS that I can browse by folders, instead of artists? I can use smart browse to open a buffer that can add songs to the playlist. That buffer opens by artists, how can I change it to open by folders instead? # Answer The short answer is no, not without writing some elisp: out of the box, the supported fields to browse by are `artist`, `album`, `genre`, `year` and `performer`. One could get close to what you want by configuring `dired` to allow adding a track to a playlist. See EmacsWiki for an idea in this direction. > 1 votes --- Tags: doom, emms, music-player ---
thread-61072
https://emacs.stackexchange.com/questions/61072
Avoid query to recover `buffer-undo-list`
2020-10-08T20:14:59.093
# Question Title: Avoid query to recover `buffer-undo-list` Every time I commit via Magit before the buffer `COMMIT_EDITSMSG` is opened I get the question `buffer-undo-list is not empty. Do you want to recover now? (yes or no)` I'm guessing this is coming from an Emacs extension but I haven't been able to locate the source that prints this message neither in the Emacs sources nor under my ELPA root. Is this a known type of message or could it be triggered by the extensions https://gitlab.com/ideasman42/emacs-undo-fu and https://github.com/m2ym/undohist-el I'm using? # Answer > 1 votes I just realized that, during the query in the Minibuffer, I can check the Option "Enter debugger on Quit" and press C-g to get a stacktrace. The stacktrace is indeed triggered by my Emacs package `undohist`: ``` Debugger entered--Lisp error: (quit) yes-or-no-p("buffer-undo-list is not empty. Do you want to recover now? ") undohist-recover-1() undohist-recover-safe() run-hooks(find-file-hook) after-find-file(nil t) ``` The reason why I didn't find this is because my `~/.emacs.d/elpa` directory is ignored by Git. --- Tags: undo ---
thread-63939
https://emacs.stackexchange.com/questions/63939
Org-mode: How to place a table left aligned on the paper?
2021-03-17T09:03:08.280
# Question Title: Org-mode: How to place a table left aligned on the paper? I'm very new to Latex or PDF-export. I try to export an Org-document with tables. The problem is, that I cannot (or better: don't know how to) place them left aligned. The problem seems to come from some default Latex command at the exported .tex: ``` \begin{center} \begin{tabular}{lll} ... \end{tabular} \end{center} ``` Does anyone know how to override this 'center'ing w/o any time editing the generated .tex? Best regards, Chris. # Answer If you want all tables to be always left-aligned, then setting `org-latex-tables-centered`as @gigiair's answer suggests is the right way to go: you customize it once and never worry about it again. If you want to change the centering behavior only for a single file, then the way to do it is to use the `#+BIND` mechanism. Add the following line to the top of your file: ``` #+BIND: org-latex-tables-centered nil ``` That will set the local value of `org-latex-tables-centered` to nil *during export only*. In order for this to work however, you will have to enable the BIND mechanism by setting (or customizing) the variable `org-export-allow-bind-keywords` to `t`. I find the BIND mechanism useful, so I set it permanently. Finally, if you want to change the centering of a single table, you can set an attribute for that table only: ``` #+NAME: cubes #+ATTR_LATEX: :center nil | a | a^{3} | |----+-------| | 1 | 1 | | 2 | 8 | ... ``` > 1 votes # Answer You can eval ``` (setq org-latex-tables-centered nil) ``` or customize the variable org-latex-tables-centered To customize the latex export, you can browse Org Export LaTeX ``` (customize-group "org-export-latex") ``` > 0 votes --- Tags: org-mode, latex, org-table ---
thread-63936
https://emacs.stackexchange.com/questions/63936
Getting first number from string
2021-03-17T04:23:04.450
# Question Title: Getting first number from string The following function fails to return "16": ``` (string-to-number "bm16") ``` It seems to get tripped up if the first characters of a string aren't numbers. Is there a way to construct an elisp function which takes a string of text and returns the number it contains (it doesn't have to handle decimals)? # Answer A possible implementation: find the first digit, get the substring of the original string that starts at that first digit and *then* call `string-to-number` on the result: ``` (defun first-number-of-string (s) (string-to-number (substring s (string-match-p "[0-9]" s)))) (first-number-of-string "bm16" -> 16 (first-number-of-string "abc123def456" -> 123 (first-number-of-string "abc123") -> 123 (first-number-of-string "123def") -> 123 (first-number-of-string "123") -> 123 (first-number-of-string "abcdef") -> 0 ``` That's assuming that the answers to the questions in my comment are that you indeed want a number, not its string representation, and in the case where there is no number in the string, having the function return `0` is acceptable. > 2 votes # Answer An alternative using cl functions: ``` (defun first-number-in-string(s) (string-to-number (seq-take-while #'cl-digit-char-p (seq-drop-while (lambda(x)(not (cl-digit-char-p x))) s)))) (mapcar #'first-number-in-string '( "bm16" "abc123def456" "abc123" "123def" "123" "abcdef")) => (16 123 123 123 123 0) ``` The same algorithm splitted for clarity:: ``` (defun collect-first (pred coll) (seq-take-while pred (seq-drop-while (lambda (x) (not(funcall pred x))) coll))) (defun first-number-in-string(s) (string-to-number (collect-first #'cl-digit-char-p s))) ``` > 1 votes --- Tags: string ---
thread-63953
https://emacs.stackexchange.com/questions/63953
Complete in-progress merge with the --no-verify option
2021-03-17T20:08:45.727
# Question Title: Complete in-progress merge with the --no-verify option Often when I'm merge the upstream branch into my branch I'll need to fix up some merge conflicts. At that point I have an in-progress merge. When I fix the conflict and hit `m` to complete the merge there is no `--no-verify` option available. The only options are `merge` and `abort`. `--no-verify` would be useful because often the upstream code has changes that will fail my pre-commit hooks (style linters, etc). Is there a way to add `--no-verify` when completing an in-progress merge? # Answer In the in-progress state I can just use the regular `c` commit command, and select `no-verify` there. > 1 votes --- Tags: magit ---
thread-60362
https://emacs.stackexchange.com/questions/60362
Unexpected indentation in python chunks
2020-08-28T08:45:20.073
# Question Title: Unexpected indentation in python chunks Already one year ago, I described a problem on github with polymode and unexpected indents. Since there was no answer there so far and the problem is really annoying, I ask here for ideas for a workaround of the problem: > I am using polymode like this for `pycode` environments in latex documents: > > ``` > > (defcustom pm-inner/python (pm-inner-chunkmode "python" > :head-matcher "\\\\begin{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}" > :tail-matcher "\\\\end{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}" > :mode 'python-mode) "python typical chunk." :group 'innermodes :type 'object) > > (defcustom pm-poly/latex-python (pm-polymode "latex-python" > :hostmode 'pm-host/latex > :innermodes '(pm-inner/python)) "latex-python typical polymode." :group 'polymodes :type 'object) > > (define-polymode poly-latex+python-mode pm-poly/latex-python) > (add-to-list 'auto-mode-alist '("\\.tex$" . poly-latex+python-mode)) > > > > ``` > > Now the pycode environment may have an optional argument for the python session name, for example > > `\begin{pycode}[SessionName] a = 2 \end{pycode}` > > If I hit Enter at the end of a line, in the next line it automatically adds some unwanted tabs like in the following screen cast: > > In a `pycode` environment without optional argument however it works as expected. > > My polymode version is 20190624.1927 in emacs 26.1 # Answer When you enter a newline in Python mode, it calls the hook `electric-indent-post-self-insert-function`. This function calls (eventually) `pm-indent-line-dispatcher`, provided by `polymode` to fill the role of `indent-according-to-mode`. In order for polymode to know what mode you're in, and what the appropriate indentation for that mode is, it needs to know the mode of the current span, and, most crucially here, what the extent of that span is. Knowing where the span starts depends on the value of `:head-matcher`. That is your problem! You defined your head matcher as: ``` :head-matcher "\\\\begin{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}" ``` This matches the first part of your pycode block: **\begin{pycode}**\[SessionName\] This means that polymode considers your python span to start with `[SessionName]`, and it correctly tries to match the indentation when you enter a new line. That's why you get tabs inserted. They are unwanted by you, but necessary to bring the indentation out to match the beginning of **\[SessionName\]**. Knowing that, we can fix your problem by correcting the `head-matcher`, such that it matches all possible span heads: ``` (defcustom pm-inner/python (pm-inner-chunkmode "python" :head-matcher "\\\\begin{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}\\(\\[[^]\\]+]\\)?" :tail-matcher "\\\\end{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}" :mode 'python-mode) "python typical chunk." :group 'innermodes :type 'object) ``` This works for my tests, but may require additional tweaking if there are edge cases I'm not aware of. Here, I'm assuming you might have a single option surrounded by `[]`, with no following text. It works ok if there is whitespace after the option, but additional non-whitespace will confuse it. If you want to match everything to the end of the line, you could use this: ``` :head-matcher "\\\\begin{\\(pycode\\|pythontexcustomcode\\|sagecode\\)}\\(\\[[^]\\]+]\\)?.*$" ``` > 2 votes --- Tags: latex, python, indentation, debugging, polymode ---
thread-63956
https://emacs.stackexchange.com/questions/63956
"Auto-Confirmation: Automatically Saying Yes" but how?
2021-03-17T22:13:15.097
# Question Title: "Auto-Confirmation: Automatically Saying Yes" but how? i have ``` (defun insert-buffername () (interactive) (compile (concat "lua " (buffer-file-name)))) (global-set-key (kbd "C-c C-e") #'insert-buffername) ``` but when i use this key binding it always asks me "Save file: (y, n, !, ...)" question which i would prefer not to see every time. I can not adopt the code in https://www.emacswiki.org/emacs/YesOrNoP to my case. Need help # Answer Try customizing (or binding) `compilation-ask-about-save` to `nil`. `C-h v` tells you: > `compilation-ask-about-save` is a variable defined in `compile.el`. > > Its value is `t` > > Documentation: > > Non-`nil` means `M-x compile` asks which buffers to save before compiling. > > ***Otherwise, it saves all modified buffers without asking.*** > > You can customize this variable. If you want to just bind it in your command, then do this: ``` (defun insert-buffername () (interactive) (let ((compilation-ask-about-save nil)) (compile (concat "lua " (buffer-file-name))))) ``` > 2 votes --- Tags: saving, compile, confirmation ---
thread-63958
https://emacs.stackexchange.com/questions/63958
How to add suffix to all list member?
2021-03-18T05:41:54.937
# Question Title: How to add suffix to all list member? When I evaluate ``` (setq sample-list (list 'abc 'def)) (message "%s_suffix" sample-list) ``` Output is: ``` (abc def)_suffix ``` But I need to get: ``` abc_suffix def_suffix ``` How can I get the output? # Answer It's unclear just what you want - *return a list* with elements `abc_suffix` and `def_suffix`? Print each of those? Show them in the echo area (`message`)? Return a string of those separated by a space? ``` ;; Return a list with the suffix appended to each element. (mapcar (lambda (ss) (format "%s_suffix" ss)) sample-list) ``` ``` ;; Print, with the suffix appended to each. (dolist (ss sample-list) (princ (format "%s_suffix" ss))) ``` ``` ;; Return the string "abc_suffix def_suffix". (mapconcat (lambda (ss) (format "%s_suffix" ss)) sample-list " ") ``` ``` ;; Show message in echo area, with the two separated by a space. (message (mapconcat (lambda (ss) (format "%s_suffix" ss)) sample-list " ")) ``` > 5 votes # Answer An idiomatic way to achieve this via recursion: ``` (defun print-list-with-suffix (lst) (cl-labels ((rec (x) (unless (null x) (message "%s_suffix" (car x)) (rec (cdr x))))) (rec lst))) (setq sample-list (list 'abc 'def)) (print-list-with-suffix sample-list) ``` > 0 votes --- Tags: list ---
thread-63961
https://emacs.stackexchange.com/questions/63961
lsp-mode: disable documentation popup
2021-03-18T08:06:03.037
# Question Title: lsp-mode: disable documentation popup I installed rustic-mode with LSP server. They work. But now it shows docs and description of every symbol I put my cursor on. It distracts and irritates me a lot. How can I make it show the symbol info and docs on demand only when I click a certain key? I tried this: ``` (setq lsp-eldoc-render-all nil) (setq lsp-enable-symbol-highlighting nil) (setq lsp-eldoc-render-all nil) (setq lsp-signature-render-documentation nil) ``` But only what I got so far is this: # Answer Try the following. ``` (setq lsp-ui-doc-enable nil lsp-ui-sideline-enable nil) ``` You can check how to set/reset the options from the LSP page. > 5 votes --- Tags: lsp-mode, rust ---
thread-63831
https://emacs.stackexchange.com/questions/63831
How do I change backend for company?
2021-03-10T17:13:24.323
# Question Title: How do I change backend for company? Recently I have discovered tabnine, a really good completion backend. I wanted to use it in emacs. So I went through the installation procedure and now I have it. But when I M-x company-diag, it shows me that I am using company-yasnippet in major mode python. I want to use tabnine instead. How do I do that? ``` Emacs 27.1 (x86_64-pc-linux-gnu) of 2020-08-28 on juergen Company 0.9.13 company-backends: ((company-anaconda) company-capf company-yasnippet company-tabnine) Used backend: company-yasnippet Major mode: python-mode ``` This is company-diag. # Answer > 1 votes A few things. 1. `company` decides its backend based on the variable `company-backends`. If you want a specific auto-completion backend, you must specify it in your `init.el` file. In general, you can read documentation on variables by using `M-x apropos-variable`. 2. To add a backend to company, call `(add-to-list 'company-backends '(<backend name>))` For example, to add Elisp completion, there is a backend called `company-elisp` that comes with company. To use this, you run `(add-to-list 'company-backend '(company-elisp))`. This will add `company-elisp` to the list of backends that `company` decides to use. 3. Company runs through its list of backends in `company-backends` and performs a test to see if it should run a given backend for your current mode. **The first to pass the test is used. All others are ignored.** Now, looking at `company-anaconda`, it recommends: ``` (eval-after-load "company" '(add-to-list 'company-backends 'company-anaconda)) ``` or, if you want both `company-anaconda` and `company-capf` together: ``` (eval-after-load "company" '(add-to-list 'company-backends '(company-anaconda :with company-capf))) ``` Finally, you **must** add: `(add-hook 'python-mode-hook 'anaconda-mode)` Looking at the source code for `company-anaconda` reveals that you **must** enable `anaconda-mode` for `company` to choose the `company-anaconda` backend. --- Tags: company-mode ---
thread-55483
https://emacs.stackexchange.com/questions/55483
New version of Org mode throws dbus-call-method: peculiar error: "Emacs not compiled with dbus support"
2020-02-12T13:34:39.903
# Question Title: New version of Org mode throws dbus-call-method: peculiar error: "Emacs not compiled with dbus support" I upgraded Org from the built-in 9.1.9 to the maint branch 9.3.3 (directions here). I now get this error when I clock in or out: ``` Debugger entered--Lisp error: (dbus-error "Emacs not compiled with dbus support") signal(dbus-error ("Emacs not compiled with dbus support")) dbus-call-method(:session "org.freedesktop.Notifications" "/org/freedesktop/Notifications" "org.freedesktop.Notifications" "Notify" :string "Emacs" :uint32 0 :string "/Applications/Emacs.app/Contents/Resources/etc/images/icons/hicolor/scalable/apps/emacs.svg" :string "Org mode message" :string "Task ‘zero email inbox’ should be finished by now. (0:30)" (:array) ((:dict-entry "urgency" (:variant :byte 0))) :int32 3000) notifications-notify(:title "Org mode message" :body "Task ‘zero email inbox’ should be finished by now. (0:30)" :timeout 3000 :urgency low) org-show-notification("Task ‘zero email inbox’ should be finished by now. (0:30)") org-notify("Task ‘zero email inbox’ should be finished by now. (0:30)" nil) org-clock-notify-once-if-expired() org-clock-update-mode-line() org-clock-in(nil) funcall-interactively(org-clock-in nil) call-interactively(org-clock-in nil nil) command-execute(org-clock-in) ``` From the depth of the error in the stack trace, I think this is a bug with Org mode or an incompatibility with my system (Emacs 26.3 (9.0) and macOS Mojave 10.14.6). I tried to catch the error with: ``` (condition-case nil (org-clock-in) (message "caught error clocking in")) ``` and I still get the error. Is this a bug I should report? How can I silence it in the meantime? # Answer At least in the more recent version of org-mode (9.4.4), one can fix this issue by modifying the variable `org-show-notification-handler`, e.g., by adding the following to the init file: `(setq org-show-notification-handler 'message)` org notifications (e.g., alerts related to clocking and effort) are then displayed at the bottom of the screen. > 2 votes --- Tags: org-mode, version-compatibilty ---
thread-11008
https://emacs.stackexchange.com/questions/11008
Can org-mode open a link in external browser when using prefix key?
2015-04-29T09:30:53.677
# Question Title: Can org-mode open a link in external browser when using prefix key? In my Emacs I have set `browse-url-browser-function` to `eww` and `org-open-at-point` (`org-return`) will open my links using `eww` as expected. However, I would like to configure `org-mode` so that when I press prefix + return (`C-u RET`) the link is opened using an external browser instead, is this possible without modifying `org-open-at-point`? I already have a helper function, `user/browse-url-external`, that I use in other modes to open URL at-point in an external browser instead of `eww`. It doesn't work with links in `org-mode` since `browse-url` only sees the descriptive text and not the hyperlink. # Answer > 8 votes That's not directly possible, since `org-open-at-point` already uses the prefix argument for something else. But of course there's nothing preventing you from wrapping `org-open-at-point` with your own code: ``` (defun my-org-open-at-point (&optional arg) (interactive "P") (if (not arg) (org-open-at-point) (let ((browse-url-browser-function #'browse-url-chromium)) (org-open-at-point)))) ``` and binding it to `C-c C-o`: ``` (define-key org-mode-map (kbd "C-c C-o") #'my-org-open-at-point) ``` Note that I didn't just advise `org-open-at-point`, since I'm a little nervous about changing its behaviour — it might break some other parts of *Org*. # Answer > 0 votes There is an alternative that should work without any modifications. If you look at the documentation for `org-open-at-point`: ``` (defun org-open-at-point (&optional arg) "Open link, timestamp, footnote or tags at point. When point is on a link, follow it. Normally, files will be opened by an appropriate application. If the optional prefix argument ARG is non-nil, Emacs will visit the file. With a double prefix argument, try to open outside of Emacs, in the application the system uses for this file type. ``` See that last sentence? Simply pressing `C-u C-u RET` should open any link with a system application rather than in Emacs. --- Tags: org-mode, web-browser ---
thread-62376
https://emacs.stackexchange.com/questions/62376
Slow markdown-mode as Emacs spends lots of time fontifying
2020-12-19T03:48:54.927
# Question Title: Slow markdown-mode as Emacs spends lots of time fontifying Emacs on my Mac got upgraded when I upgraded some other package in Homebrew and now working with Markdown files is very slow. I'm now running the `railwaycat/emacsmacport/emacs-mac` package version with Emacs version 27.1. My markdown-mode is 20201211.329. Disabling markdown-mode makes the problem go away. I have run the profiler (in cpu mode) and gotten the following report: ``` + redisplay_internal (C function) 7782 75% + command-execute 1850 18% + ... 443 4% + jit-lock--antiblink-post-command 162 1% + timer-event-handler 21 0% + #<compiled 0x421b5d07> 9 0% + gui-set-selection 4 0% + clear-transient-map 1 0% ``` Digging into redisplay\_internal reveals the following: ``` - redisplay_internal (C function) 7782 75% - jit-lock-function 7687 74% - jit-lock-fontify-now 7687 74% - jit-lock--run-functions 7681 74% - run-hook-wrapped 7681 74% - #<compiled 0x1feee74d43f1> 7681 74% - font-lock-fontify-region 7671 74% - font-lock-default-fontify-region 7671 74% - font-lock-fontify-keywords-region 7663 74% - markdown-match-italic 7418 72% - markdown-match-italic 7295 71% - markdown-match-italic 7282 70% - markdown-match-italic 7267 70% - markdown-match-italic 7132 69% - markdown-match-italic 6999 68% - markdown-match-italic 6884 67% - markdown-match-italic 6764 65% - markdown-match-italic 6656 64% - markdown-match-italic 6556 63% - markdown-match-italic 6454 62% - markdown-match-italic 6446 62% - markdown-inline-code-at-pos-p 5758 56% - markdown-inline-code-at-pos 5757 56% - markdown-match-code 5753 56% - markdown-search-until-condition 5753 56% apply 5752 55% markdown-beginning-of-text-block 3 0% markdown-end-of-text-block 1 0% ``` In short, Emacs appears to be spending looking for the following regular expression in order to identify inline code blocks: ``` "\\(?:\\`\\|[^\\]\\)\\(?1:\\(?2:`+\\)\\(?3:\\(?:.\\|\n[^\n]\\)*?[^`]\\)\\(?4:\\2\\)\\)\\(?:[^`]\\|\\'\\)" ``` I know much more than when I posted v1 of this question but I'm still not sure--how do I fix this? # Answer It is caused due to common `*` syntax of lists and italics. For deeply nested lists, parsing gets expensive due to recursive checks for italics. If you are willing to abandon `*italics*` syntax in favor of `_italics_` then the computational overhead can be avoided. ``` (defconst markdown-regex-italic "\\(?:^\\|[^\\]\\)\\(?1:\\(?2:[_]\\)\\(?3:[^ \n\t\\]\\|[^ \n\t]\\(?:.\\|\n[^\n]\\)[^\\ ]\\)\\(?4:\\2\\)\\)") ;; and/or (defconst markdown-regex-gfm-italic "\\(?:^\\|[^\\]\\)\\(?1:\\(?2:[_]\\)\\(?3:[^ \\]\\2\\|[^ ]\\(?:.\\|\n[^\n]\\)\\)\\(?4:\\2\\)\\)" ``` > 1 votes --- Tags: osx, performance, markdown, markdown-mode, profiler ---
thread-45403
https://emacs.stackexchange.com/questions/45403
Is it possible to create clickable links to macos mail.app email via "message://..." in orgmode?
2018-10-16T14:50:47.860
# Question Title: Is it possible to create clickable links to macos mail.app email via "message://..." in orgmode? I use the "Copy Message URL" quite heavily in mail app. I would like to paste the link into an org document and make it a clickable link that opens the email in mail.app. This does not currently work. I did try: ``` [[message://...][email link]] ``` But this did not work. # Answer > 0 votes This should work: ``` (require 'org) (org-add-link-type "message" (lambda (id) (shell-command (concat "open message:" id)))) ``` The link should be in the following format: ``` [[message:<message_id@domain.com>][Apple Mail Link]] ``` # Answer > 0 votes Based on Lars Careliusson's answer, I made it work by doing the following: When 'Copy Message URL', append `%3c` and `%3e` before and after messageid, as suggested by this article. Here is the Applescript from the article: ``` tell application "Mail" set selectedMessages to selection set theMessage to item 1 of selectedMessages set messageid to message id of theMessage -- Make URL (must use URL-encoded values for "<" and ">") set urlText to "message://" & "%3c" & messageid & "%3e" return urlText end tell ``` Then, add this to your emacs init file: ``` (org-add-link-type "message" (lambda (id) (shell-command (concat "open message:" id)))) ``` and the link should be in the following format: ``` [[<copied_text_from_apple_script>][Subject]] ``` Alternatively, you can wrap `%3c` and `%3e` into the `org-add-link-type` function and paste the Message ID directly into the org file. --- Tags: org-mode, email ---
thread-59289
https://emacs.stackexchange.com/questions/59289
monitor commands from gud/gdb command line not showing output
2020-06-26T20:34:42.983
# Question Title: monitor commands from gud/gdb command line not showing output In a plain terminal, I can run gdb, connect to gdb server via 'target remote :nnnn\` and then use the 'monitor' command to send commands to the remote app, and the results from running those commands on the remote app are displayed at the gdb command line. Under gud/gdb, if I type the same 'monitor xxx' command, the results of the command, if the command has output, do not get echoed on the gud comint command line. The monitor interface does work -- I can send output-less monitor commands and observe that they are followed. The issue is that if the remote command has output, it does not make its way all the way back to the gud command line. I can create a rudimentary workaround, printing each line to the *Messages* buffer, with code such as: ``` (defun gts-gud-gdb-mon (mon-command) "send command as monitor command, collect output" (interactive "MMonitor command: ") (let* ((gdb-command (format "monitor %s" mon-command)) (out-lines (gud-gdb-run-command-fetch-lines gdb-command gud-comint-buffer))) (dolist (l out-lines) (message (format "monitor output line: %s." l))))) ``` But I would like to either (1) be able to type 'monitor xxxx' and see multiple lines of output at the gud command line, or (2) have a new window, "monitor", that echos the result of any monitor commands. *How can I see the output of 'monitor' commands within gud?* # Answer > 0 votes It looks like the default behavior for `gdb-mi` is to simply ignore the target-stream output from `gdb`. This is data returned by the MI interface prefixed with `@`. The key function is `gdbmi-bnf-target-stream-output` in `gdb-mi.el`. I used the `advice-add` feature to override this function in my `.emacs` file: ``` (defun my-gdbmi-bnf-target-stream-output (c-string) "Change behavior for GDB/MI targe the target-stream-output so that it is displayed to the console." (gdb-console c-string)) (advice-add 'gdbmi-bnf-target-stream-output :override 'my-gdbmi-bnf-target-stream-output) ``` With this, I'm now able to see monitor command output, e.g. results from running `monitor get_vbits <addr> <size>` when debugging interactively with valgrind. --- Tags: gdb, gud ---
thread-63890
https://emacs.stackexchange.com/questions/63890
Connect to Melpa on Port 80 in Setup Script
2021-03-13T20:47:15.177
# Question Title: Connect to Melpa on Port 80 in Setup Script I'm trying to setup emacs in a docker image that I am creating. I would like to create the image with a particular melpa package installed. This is my Dockerfile: ``` FROM ubuntu RUN apt-get update RUN apt-get install -y emacs COPY setup.el /root/.emacs.d/ WORKDIR /root/.emacs.d/ RUN emacs --script setup.el ``` This is my setup.el file: ``` (require 'package) (package-initialize) (setq package-archives '(("melpa" . "http://melpa.org/packages/"))) (package-refresh-contents) (package-install 'racket-mode)) ``` When I go to build the docker image, I get the following error: ``` Loading /etc/emacs/site-start.d/00debian.el (source)... Contacting host: melpa.org:80 error in process filter: Could not create connection to melpa.org:443 ``` I looked at the 00debian.el file to see if it had any effect on the docker build. ``` $ cat /etc/emacs/site-start.d/00debian.el ;; Set the default mail server and news server as specified by Debian ;; policy. (setq gnus-nntpserver-file "/etc/news/server") (setq mail-host-address (let ((name (expand-file-name "/etc/mailname"))) (if (not (file-readable-p name)) nil (with-temp-buffer (insert-file-contents-literally name) (while (search-forward "\n" nil t) (replace-match "" nil t)) (buffer-string))))) ``` It doesn't seem to have any effect on the package system nor does it seem to be reaching out to Melpa or Elpa. I made the package-archives point to http Melpa as opposed to https Melpa so that I wouldn't connect on port 443. However, my system still seems to be connecting to Melpa on port 443. I did this because when emacs tries to connect over port 443 it throws an unknown certificate authority error (the certificate authority is R3). Does anyone have an idea how I might be able to fix the certificate authority error in my docker image or otherwise get Melpa to connect over port 80? # Answer > 1 votes Create your own local ELPA mirror repo from installed packages and use that repo in docker. See https://github.com/redguardtoo/elpa-mirror Remote elpa repo might be blocked by corp firewall. # Answer > 0 votes I don't have complete answer, but few points which you have to take into consideration: 1. It won't be possible to connect to Melpa.org over port 80, so it is better to switch to https (port 443) 2. I don't have any debian to verify/falsify this guess, but most likely you are missing TLS library and certificates. Ad1. As you can see below, any query to http `melpa.org` is moved permanently to https: ``` ~  curl -v http://melpa.org/packages/ * Trying 178.128.185.1:80... * Failed to set TCP_KEEPALIVE on fd 6 * Connected to melpa.org (178.128.185.1) port 80 (#0) > GET /packages/ HTTP/1.1 > Host: melpa.org > User-Agent: curl/7.74.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 301 Moved Permanently < Server: nginx < Date: Thu, 18 Mar 2021 21:25:41 GMT < Content-Type: text/html < Content-Length: 162 < Connection: keep-alive < Location: https://melpa.org/packages/ < <html> <head><title>301 Moved Permanently</title></head> <body> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html> * Connection #0 to host melpa.org left intact ``` Ad.2 Consider adding to your docker image package gnutls, openssl or libressl. Good luck! # Answer > 0 votes This is something of a workaround but if you create a docker image and install emacs on it and then connect it to melpa/elpa and then approve the connections to the package repositories, it will create a file network.data in root/.emacs.d/. If you copy the text of that file and create a file named network.data and incorporate that into your docker build process in root/.emacs.d/, it will allow the connection to melpa in a non-interactive mode during the docker build process. This isn't perfect but it worked for me! --- Tags: package, package-repositories, docker ---
thread-63987
https://emacs.stackexchange.com/questions/63987
Timer runs immediately then periodically
2021-03-20T06:57:53.170
# Question Title: Timer runs immediately then periodically I have a timer I want to run every day at 4am. Thus, I put something like this in my configuration. ``` (defvar my/timer nil) (unless my/timer (setq my/timer (run-at-time "04:00am" (* 24 60 60) #'my/function))) ``` This works as expected, except that each time this snippet is evaluated for the first time (*e.g.*, when launching emacs), `my/function` is executed immediately. In fact, evaluating `(run-at-time "04:00am" (* 24 60 60) #'my/function)` at any time in the day causes this effect. Maybe I have a misunderstanding, but isn't it supposed to run only at the specified time ? # Answer Unfortunately, you're telling it to run the function at 04:00am *today*. Unless you evaluated that code between midnight and 4am, that's a target time in the *past*, and so Emacs runs it ASAP. The `run-at-time` code knows this is a bit dumb: ``` ;; Handle "11:23pm" and the like. Interpret it as meaning today ;; which admittedly is rather stupid if we have passed that time ;; already. (Though only Emacs hackers hack Emacs at that time.) (if (stringp time) (progn (require 'diary-lib) (let ((hhmm (diary-entry-time time)) (now (decode-time))) (if (>= hhmm 0) (setq time (encode-time 0 (% hhmm 100) (/ hhmm 100) (decoded-time-day now) (decoded-time-month now) (decoded-time-year now) (decoded-time-zone now))))))) ``` You could figure out how many seconds there are between now and 4am, and use that instead; or else something like: ``` (unless my/timer (let ((24hours (* 24 60 60))) (setq my/timer (run-at-time "04:00am" 24hours #'my/function)) (when (> (timer-until my/timer (current-time)) 0) (timer-inc-time my/timer 24hours)))) ``` > 5 votes --- Tags: timers ---
thread-63989
https://emacs.stackexchange.com/questions/63989
Do changes made inside a hook persist after the hook has finished evaluation?
2021-03-20T08:33:20.740
# Question Title: Do changes made inside a hook persist after the hook has finished evaluation? Let's say I am setting a variable to a value inside a hook. I'm hooking the hook to the `minibuffer-setup-hook` so that it runs whenever the minibuffer opens. Will the changes made by the hook persist after I close the minibuffer? Or will they revert back to their original state? # Answer > 2 votes It depends on what kind of changes you make. There's nothing special about code invoked from a hook. If you set a global variable it remains set until something sets it differently or `makunbound`s it. Your question is general, so the answer is general. If you pose a specific question, e.g. with some code, specific answers can likely be given. --- Tags: hooks ---
thread-63991
https://emacs.stackexchange.com/questions/63991
Emacs cursor border hides the character
2021-03-20T13:32:21.720
# Question Title: Emacs cursor border hides the character Cursor does not show the bottom section such as `_` or bottom part of character `g`. This is the case in `emacs -q -nw file.py` and also the case in my init.el file. I am not sure how can I fix this issue. ``` _g _g ``` I am using `emacs` under iTerm, where it has smart-box setting it on. Smart-box should let cursor's color as: character's color to be the background color and character's color to be black. --- Sometimes cursor's background and foreground color becomes the same, where I don't know how that happens # Answer 1. Have you tried a different font? The cursor shape is likely not easy to change, but the font should be. 2. You can also increase line spacing: See (elisp) Layout Parameters and (elisp) Special Properties. 3. You can also try to change frame parameter `cursor-type` or user option `cursor-type`. (They allow the same values.) You can set the height of the cursor with them. But I don't know whether that will override what iTerm imposes. > 1 votes --- Tags: faces, terminal-emacs, cursor ---
thread-63995
https://emacs.stackexchange.com/questions/63995
Using org-map-entries to add properties to all entries with tags
2021-03-20T15:20:14.677
# Question Title: Using org-map-entries to add properties to all entries with tags I'm trying to make a function that will allow me to add properties to all entries in an org file that contain a particular tag ("drill"): ``` (defun add-to-chinese-anki () (interactive) (org-entry-put (point) "ANKI_DECK" "Chinese Org Notes") (org-entry-put (point) "ANKI_NOTE_TYPE" "chinese-org-drill") (org-entry-put (point) "ANKI_TAGS" "languages") ) (defun add-all-to-chinese-anki () (interactive) (org-map-entries (lambda () (add-to-chinese-anki) "drill" 'file)) ) ``` However the above code is adding the tags to every entry in the file, and not filtering by tag. Any help would be appreciated! # Answer > 2 votes Your call to org-map-entries is wrong - you have a misplaced paren. It should be ``` ... (org-map-entries (lambda () (add-to-chinese-anki)) "drill" 'file) ... ``` Note that the `lambda` is not necessary. The following works just as well: ``` ... (org-map-entries #'add-to-chinese-anki "drill" 'file) ... ``` For more complicated matching, the Matching tags and properties section of the manual is indispensable: you can read it locally with `C-h i g(org) Matching tags RET`. --- Tags: org-mode, org-tags ---
thread-64001
https://emacs.stackexchange.com/questions/64001
Why do many buffer switching commands in Doom Emacs skip over buffers that aren't visiting files? How can it be prevented?
2021-03-20T16:47:14.303
# Question Title: Why do many buffer switching commands in Doom Emacs skip over buffers that aren't visiting files? How can it be prevented? In Doom Emacs many commands that replace the buffer in the current window with a different buffer will automatically select the most recent buffer that you have had open in a window. But buffers that are not visiting files, such as `*Messages*`, `*Scratch*`, `*term*`, and `*shell*` will never be considered the most recent. This is how it seems to work: All buffers are in a stack. Buffers currently currently being displayed in windows are put on the bottom of the stack because you don't need to select them. When a buffer in a window is replaced by another buffer it is put on the top of the stack. When you execute one of the buffer switching commands, the default selection is whichever buffer is on top of the stack. But for some reason buffers that aren't visiting files are either inserted lower in the stack or skipped over when deciding the default selection even though they are on top of the stack. These are some of the commands I've found that behave this way: `ivy-switch-buffer`, `counsel-switch-buffer`, `ido-switch-buffer`, `mode-line-other-buffer` I've found that `helm-buffers-list` and `helm-mini` have a more consistent behavior with all buffers regardless of whether they are visiting a file or not. They will allow, for example, a `term` buffer to be the default selection when it is the most recently hidden buffer. I've found that removing the asterisks from the buffer name has no affect and the mode of the buffer does not seem to matter. # Answer I found that the behavior is caused by two of the functions in `doom-unreal-buffer-functions` and can be prevented by redefining the variable without those functions, like this: ``` (setq doom-unreal-buffer-functions '(minibufferp)) ``` These are the two functions that were removed: > (doom-special-buffer-p BUF) > > Returns non-nil if BUF's name starts and ends with an \*. > (doom-non-file-visiting-buffer-p BUF) > > Returns non-nil if BUF does not have a value for buffer-file-name. I found the answer in this github issue: https://github.com/hlissner/doom-emacs/issues/3495 I haven't yet found any documentation about the concepts of real or unreal buffers in Doom Emacs. > 4 votes --- Tags: buffers, window, doom ---
thread-62594
https://emacs.stackexchange.com/questions/62594
What' s going on with this program?
2021-01-04T18:40:08.737
# Question Title: What' s going on with this program? I have been using emacs for many years, but from version 26 ... there is a mess with server as I have to type emacsclient in place of simply emacs. Going worse with 27. From 26 I haven't found a way to disable server mode ... From 27 emacsclient allows me to open only one session at a time ... I received message showing `type CTRL # when you have finished` ... while the file I try to open in another shell is asking me to Wait. It's not fine at all. How can I get the old behaviour ? I don't need server mode by default. I just need that `emacs -nw` opens my file without messing ... # Answer Solution (it's silly) : Oh\_my\_zsh defined an alias launching the daemon mode by default. I had to disable the call to emacs plugin in my .zshrc See https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emacs for details. > 1 votes --- Tags: emacsclient ---
thread-53229
https://emacs.stackexchange.com/questions/53229
Finding missing key bindings
2019-10-18T15:56:37.673
# Question Title: Finding missing key bindings I was just looking at the Ediff manual¹ for something, and it's one of those Emacs manuals that (a bit annoyingly) only list keybinds and not function names (so, if you have rebinding going on, you don't know what it's talking about without digging into source). And the keys it suggests for the things I want to do aren't doing anything for me—I get `X is undefined`, and if I `C-h``k``X`, I get `X is undefined`—these keys Ediff says should be available aren’t otherwise bound to `self-insert` or anything else. (I should note here this doesn’t mean that I have *no* Ediff bindings; the keys shown onscreen in the Ediff Control Panel window do all work. It’s just keys that the manual mentions I’m having trouble invoking.) The weird things, though, are that 1. searching my configs, I don't have anything named `.*ediff.*` rebound, so I don't know why those default keys wouldn't work, and 2. since Ediff has its own control panel buffer with its own keymap that uses mostly unchorded commands, why is a key that the manual says should do something, like `@` or `*`, unbound (not bound to self-insert)? I can use the source (mostly `ediff-util.el`) to find what functions these keys are supposed to be bound to and then bind them or run them with `M-x`, but I’m not sure how to go about diagnosing why I don’t have these keys bound in the first place. (In case it matters, I’m running Emacs in server mode with my emacsclient running in a TTY.) To clarify why I haven’t accepted prior answers: 1. I’m not asking how to find a *particular key of Ediff* — neither any particular key, nor any key of Ediff in particular. I’m asking how (if it’s possible at all, and from the Elisp manual’s explanation of keymaps, it feels like it should be) to find what the default map of *any given mode or package* might set, so that if the manual or someone online tells me to do something by typing some keys, and that doesn’t work, to find out what they were telling me to do in terms of Elisp commands. 2. The crux of this is not that I want to know how to do certain functions of Ediff (or any other package), it’s that somehow my keymaps are *obliterating default mappings entirely*, and I don’t know how that’s happening. I’m looking for how to find the missing key mappings *and how they became missing in the first place*. I generally use `use-package` to create bindings and keychords, and I can’t see where any of them conflict. 3. I’m not even sure how I’d go about removing another keybinding without replacing it with one of my own if I wanted to (using use-package bindings and not explicitly removing bindings or mapping them explicitly to `self-insert`), which is what I’m experiencing with Ediff—if someone can explain that, it would be a huge clue. --- ¹ Though I link to the current HTML version of the Ediff manual for convenience, the one I’m reading is the Info pages shipped with Emacs 25.2.2. # Answer > 1 votes When you say `X`, are you referring to the help output such as `X - read only in buffer X`. There `X` is referring to the Ediff buffer names, for example A or B. # Answer > 0 votes ## On X * open two files to compare in two separate windows * `M-x ediff-buffers RET RET RET` * now the cursor is in a new small `ediff` frame * `C-h k w d` Now I see a help window explaining that `w d` runs ediff-buffers and how it works. Maybe you had the cursor in the main frame instead of the small `ediff` frame? ## On terminal Same as above, but instead of a new small frame I have a new small (one-line) ediff window. With the cursor on the new window, I can ask for help on `w d`. Maybe you had the cursor in one of the two windows containing the files instead of the small `ediff` window? # Answer > 0 votes The information of orignial keybindings of a package can, of course, be found in the source code. All of Emacs is open source so it is easy to have a look at it. For example, you want to know which keys Emacs `help-mode` originally bound? Then keybindings of that mode is expected to be found in the variable `help-mode-map`. So you only need to go to the place, where `help-mode-map` is defined. (You get there by putting point over the string `help-mode-map` and run the command `xref-find-definitions`, which is bound to `M-.`) You could also search the source code of the feature for `define-key`. With this you will very often find the information you seek, but of course, Emacs is not an entirely homogeneous system and there might be cases, where you have to understand more of its source code. Another option, which does not involve looking at the source code, is running an Emacs instance without any customization. You can do that by starting Emacs with its command line option `-Q`, you might have to load Elpa packages by hand, though. --- Tags: key-bindings, ediff ---
thread-63952
https://emacs.stackexchange.com/questions/63952
Trying to install scad-mode from package repository
2021-03-17T19:02:59.077
# Question Title: Trying to install scad-mode from package repository This melpa.org page suggests that the scad-mode package is installable from a package repository. But I tried adding http://marmalade-repo.org/ to my package archives, but `scad-mode` still doesn't show up in list-packages. Is this page incorrect? I now have ``` '(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/") ("melpa-stable" . "http://stable.melpa.org/packages/") ("marmalade" . "http://marmalade-repo.org/packages")))) ``` in my `custom-set-variables` list. And in the description, isn't the correct syntax `M-x package-intstall, not` M-x install-package\`? # Answer > 1 votes scad-mode is available on MELPA, not MELPA stable. You'll therefore need to set up regular MELPA instead of MELPA stable to install it. You might find this opinion piece about MELPA stable useful: https://old.reddit.com/r/emacs/comments/etikbz/speaking\_as\_a\_package\_maintainer\_please\_do\_not/ Marmalade is unmaintained at this point. Despite repeated prodding the admin never bothered making it run again, so I'd remove it from the package archives variable. It should look like this instead: ``` '(package-archives (quote (("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/")))) ``` --- Tags: package-repositories ---
thread-60315
https://emacs.stackexchange.com/questions/60315
Make org mode use helm-find files when inserting local file links
2020-08-26T10:01:08.640
# Question Title: Make org mode use helm-find files when inserting local file links How can I achieve that org mode uses `helm-find-files` if I insert a link to a local file via `C-u C-c C-l`? # Answer You need enable helm-mode, for example: `(helm-mode 1)`. Another option is to call `helm-find-files` followed by `C-c @` to insert the link. > 1 votes --- Tags: org-mode, helm ---
thread-64019
https://emacs.stackexchange.com/questions/64019
How can I suppress the message `When done with this frame, type C-x 5 0`?
2021-03-21T14:12:24.850
# Question Title: How can I suppress the message `When done with this frame, type C-x 5 0`? I am running `emacs v26` daemon on the background and using a single terminal. Usually I open files using `emacsclient -qt` and close them using `C-x C-s` and `C-x C-c` to get back to terminal run the script and afterwards re-open another file. --- I wanted to make this operation faster where when I run `emacsclient -qt -e '(progn (find-file "file.py"))'` seems like it opens the files much faster than `emacsclient -qt file.py` (this may lag to show previous buffers for a second). But now, when I run `emacsclient -qt -e '(progn (find-file "file.py"))'` I keep seeing `When done with this frame, type C-x 5 0` message in the minibuffer. =\> How can I suppress this warning message? and also safe to open files this way? --- Not perfect but the script I come up with: ``` #!/bin/bash open_emacs() { FILE=$1 if [[ -d $FILE ]]; then echo "Folder path is provided, please provide a file" return fi if [ ! -f "$FILE" ]; then echo "$FILE does not exist." return fi if [ "$#" -ge 1 ]; then emacsclient -qt -e '(progn (find-file "'$FILE'"))' if [ $? -eq 0 ]; then true else emacsclient -qt -e '(progn (find-file "'$FILE'"))' fi else echo "## Please provide a file" fi } open_emacs file.py ``` # Answer > 5 votes This is possible starting from Emacs 28, which provides the user option `server-client-instructions` for this purpose. ``` (setq server-client-instructions nil) ``` --- Tags: minibuffer, daemon, message ---
thread-64022
https://emacs.stackexchange.com/questions/64022
where is emacs saving files to open after launch?
2021-03-21T16:36:24.550
# Question Title: where is emacs saving files to open after launch? I am using Spacemacs but I think this shouldn't matter for this question. For some reason I am not able to find the place where Emacs is storing the files to reopen after launch. I've greped for a file it always loads and found some instances of that path in the `.emacs.d/.cache` folder. I've deleted these files. Didn't work. I even deleted the entire `.cache` folder. Even then the same files are reloaded after startup. Where is Emacs saving these locations so I can delete them? I have also not found a way to overwrite the state by deleting all buffers before quitting Emacs. Edit for clarification: All files being reloaded were `.org` files. # Answer > 0 votes I think it would normally be enough to delete the `.cache` folder. In my instance Emacs loads all the `org-agenda-files` I have defined in my config. That was the "problem". Realizing the reopened files were `.org` files gave me the hint that it had to do with the org agenda. Though I don't load my agenda directly, it could very well be that some config in my init loads it. I would have to investigate the root cause further but for now I at least understand it is me that is loading the files and not some `desktop save` or persistent workspace gone awry. --- Tags: start-up ---
thread-64024
https://emacs.stackexchange.com/questions/64024
Multiple files for reading abbreviations?
2021-03-21T18:42:10.597
# Question Title: Multiple files for reading abbreviations? Is it possible to have multiple files to tell emacs reads abbrevs? In other words I would like that emacs reads abbrevs from files `A` and `B`, but write abbrevs only in `A`. Is it possible? ``` (setq abbrev-file-name "~/.emacs.d/abbrev_defs") ``` # Answer An abbrev file contains regular Lisp code and is evaluated using `load`. Therefore all you need to do is to add `(load B)` (with B being the full path to file B) to your init file wherever appropriate. > 2 votes --- Tags: abbrev, libraries, load ---
thread-64021
https://emacs.stackexchange.com/questions/64021
headings in org-mode: unexpected behavior
2021-03-21T15:04:27.813
# Question Title: headings in org-mode: unexpected behavior Recently, I started experiencing unexpected behavior when editing org-mode files. Suppose I have two headings, with _ indicating the cursor position. ``` * Heading *_ ** Subheading ``` I want to insert a new subheading before the existing one. So I now press * to get a second asterisk. But I don't get a second \*. Instead, one of the asterisks from the existing subheading on the line below disappears! Then I press * again, and now the asterisk reappears! Now I press * for a third time, and I finally get the second asterisk on the new heading that I want to insert. So I press space to give it a title, only to find that I now have four asterisks! Like this: ``` * Heading **** _ ** Subheading ``` I find this behavior extremely annoying and have no idea how it is supposed to be helpful or what purpose it serves. I don't think I changed anything in my setup, so it might have been enabled by an update. I want to turn it off, but I can't find the relevant variable (meaning I don't even know what to search for). Does anyone know how to turn this "feature" off? # Answer **EDIT:** I found this is a known bug in org-mode. The problem is setting `org-hide-emphasis-markers` to t. Once it's set back to nil (the default), the problem goes away. It is because org tries to hide the strong emphasis marker, \**. I reported my finding to the org mailing list. > 2 votes --- Tags: org-mode ---
thread-64031
https://emacs.stackexchange.com/questions/64031
Why does the prompt remain even if I quit my command?
2021-03-21T23:03:05.783
# Question Title: Why does the prompt remain even if I quit my command? I'm trying to write a function that should allow me to conditionally choose how to replace a regexp. E.g. if I have the string "A. Z" I'd like to choose if replace it with "A@. Z" or "A.~Z". I wrote this function: ``` (defun fix-latex-after-full-stop-space () "DOCSTRING" (interactive) (save-excursion (let* ((a (point-min-marker)) (case-fold-search nil) (case-replace nil)) (catch 'quit (goto-char a) (while (search-forward-regexp "[A-Z]\\. [A-Z]" nil t) (let* ((MATCH (match-string 0)) (CHOICE (read-char-choice "Choose @, ~, \"n\" or \"q\"" '(?@ ?~ ?n ?q)))) (cond ((char-equal CHOICE ?@) (setq MATCH (replace-regexp-in-string "\\. " "\\@. " MATCH t t ))) ((char-equal CHOICE ?~) (setq MATCH (replace-regexp-in-string "\\. " ".~" MATCH t t ))) ((char-equal CHOICE ?n) nil ) ((char-equal CHOICE ?q) (throw 'quit nil) )) (replace-match MATCH t t)))) ))) ``` But it has a strange behaviour. If I type "q" to quit or when I replace the last match the prompt doesn't quit but keeps asking for a char. Whats wrong in it? You can test it on: ``` A. Z A. Z A. Z ``` **Edit.** It happens that if I add `(princ "something")` after the `while` loop the minibuffer quits like I expect: ``` (defun fix-latex-full-stop-space () "DOCSTRING" (interactive) (save-excursion (let* ((a (point-min-marker)) (case-fold-search nil) (case-replace nil)) (catch 'quit (goto-char a) (while (search-forward-regexp "[A-Z]\\. [A-Z]" nil t) (let* ((MATCH (match-string 0)) (CHOICE (read-char-choice "Choose @, ~, \"n\" or \"q\"" '(?@ ?~ ?n ?q) t))) (cond ((char-equal CHOICE ?@) (setq MATCH (replace-regexp-in-string "\\. " "\\@. " MATCH t t ))) ((char-equal CHOICE ?~) (setq MATCH (replace-regexp-in-string "\\. " ".~" MATCH t t ))) ((char-equal CHOICE ?n) nil ) ((char-equal CHOICE ?q) (throw 'quit nil) )) (replace-match MATCH t t)))) (princ "") ;; <-- STRING ADDED HERE ))) ``` but why? # Answer > 1 votes There's nothing wrong with your code. What's happening is that you are indeed exiting the function, but *nothing is clearing the echo area, so your prompt remains there*. You can use `(message nil)` or `(message "Done")` to clear it. You can put that at the end of your code. --- Tags: echo-area, message ---
thread-37327
https://emacs.stackexchange.com/questions/37327
Don't complain about unmatching parenthesis and brackets in latex math mode
2017-12-05T19:35:42.440
# Question Title: Don't complain about unmatching parenthesis and brackets in latex math mode In mathematical notation, parenthesis and brackets have overloaded meaning, and when it comes to represent intervals, the parenthesis/brackets don't have to match. For example, ``` (1, 2] ``` means an interval with left open and right closed. But unfortunately, in math mode in latex mode, this becomes fairly annoying that whenever notation likes this is used, emacs highlights it as error. For example, But outside of math mode, it's really not normal if any mismatches happen. I am wondering if you guys got a way to fix it? --- enabled minor modes: ``` Enabled minor modes: Async-Bytecomp-Package Auto-Composition Auto-Compression Auto-Encryption Auto-Fill Auto-Revert Company Diff-Auto-Refine Electric-Indent File-Name-Shadow Flyspell Font-Lock Global-Eldoc Global-Font-Lock Global-Git-Commit Global-Hi-Lock Global-Undo-Tree Hi-Lock Latex-Preview-Pane Line-Number Linum Magit-Auto-Revert Magit-File Menu-Bar Mouse-Wheel Origami Override-Global Projectile Pyvenv Rainbow-Delimiters Save-Place Shell-Dirtrack Show-Smartparens Show-Smartparens-Global Tex-Pdf Tool-Bar Tooltip Transient-Mark Undo-Tree Yas ``` # Answer AFAIU the error message is sent by `blink-matching-open`. Calls a var holding `blink-matching-check-function`, which points to `blink-matching-check-mismatch`. Finally appears function `syntax-after` and the `char-table`. Please consider reporting it at bug-gnu-emacs@gnu.org. For the moment customizing var `blink-matching-paren` to nil avoids the error message - at some cost. As for the face: `M-x` `customize-face` `RET` `show-paren-mismatch` `RET` might mitigate the distraction. Finally `M-x` `customize-variable` `RET` `show-paren-mode` `RET` to `off` avoids the highlighting. > 1 votes # Answer I encountered the same problem and found the culprit to be rainbow-delimeters, which is listed in the OP's list of minor modes. A workaround is to disable rainbow-delimeters in LaTeX mode. In Doom Emacs, this can be accomplished by adding the following to your `config.el`: ``` (after! tex (remove-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)) ``` > 1 votes --- Tags: latex ---
thread-64025
https://emacs.stackexchange.com/questions/64025
Org-mode export to HTML filter: Replace LaTeX commands
2021-03-21T21:09:32.393
# Question Title: Org-mode export to HTML filter: Replace LaTeX commands I am trying to export org-mode file to HTML. Because I am exportig the same file also to LaTeX format, I am having in the org-mode file a few LaTeX commands, for example \LaTeX command. For HTML export I would like to replace this command with its transcript in normal letters, simply "LaTeX." I am also using Doom Emacs and running org-mode export in `--batch` mode (or with `-nv` flag), to run emacs export commands non-interactively (and via `makefile`). Using this filter function written in `exportConfig.el` file: ``` (with-eval-after-load 'ox (with-eval-after-load 'ox-html (with-eval-after-load 'htmlize (defun my-latex-filter-example (text backend info) "Replace \LaTeX with \"LaTeX\" in HTML output." (when (org-export-derived-backend-p backend 'html) (replace-regexp-in-string "\\\\LaTeX" "LaTeX" text))) (add-to-list 'org-export-filter-latex-fragment-functions 'my-latex-filter-example)) )) ``` (those `with-eval-after-load` functions might be redundant because of `-nw` emacs start flag.) But in the resulting exported HTML I still get \LaTeX sequences converted to regular strings. I also tried to add the filter function to `org-export-filter-plain-tex-functions` alist, but that did not work either. How can I correctly replace simple LaTeX commands like this for org-mode export to HTML? **EDIT:** Command I am using is: ``` emacs main.org -nw -l exportConfig.el -f org-html-export-to-html --kill ``` Previously I have misspelled the emacs start flag to `-nv`, I have corrected that. I am using approach recommended here: Using htmlize in batch mode Yes, I want to replace "\LaTeX" command in org-mode source with simple "LaTeX" string for HTML export. Currently, `my-latex-filter-example` function doesnt replace it, so the exported HTML contains string "\LaTeX" in multiple places. # Answer > 2 votes A couple of problems I think: * `with-eval-after-load` will do something after the indicated file is loaded, but you have to load that file somehow. Indeed, what happens is that since the files are not loaded by anybody, the `with-eval-after-load`s never trigger, so your filter never gets installed. I suggest a plain `(require 'ox)` and similar. * `-nw` does not imply `--batch` so I suggest you change your command to do that explicitly. The following seems to work for me (I called the file `init.el`, but you can call it anything you want, as long as you use the correct name in the Makefile below): ``` (require 'ox) (require 'ox-html) (defun my-latex-filter-example (text backend info) "Replace \LaTeX with \"LaTeX\" in HTML output." (when (org-export-derived-backend-p backend 'html) (replace-regexp-in-string "\\\\LaTeX" "LaTeX" text))) (add-to-list 'org-export-filter-latex-fragment-functions 'my-latex-filter-example) ``` There is no need to load `htmlize` AFAICT (but if you need it, then load it with `(require 'htmlize)`). The Makefile looks like this: ``` %.html: %.org emacs --batch -l init.el $< -f org-html-export-to-html --kill ``` and if my org file is called `foo.org`, I invoke the Makefile with `make foo.html`. --- Tags: org-mode, org-export ---
thread-64018
https://emacs.stackexchange.com/questions/64018
Pdf-tools: Toggle between viewing and editing mode
2021-03-21T13:48:34.867
# Question Title: Pdf-tools: Toggle between viewing and editing mode In DocView (without pdf-tools installed) I could hit `C-c C-c` to toggle between viewing-mode and editing-mode. After installing pdf-tools I expected `C-c C-c` to act the same. But now it toggles between PDFView and DocView, without any editing mode. What can I do to make it toggle between PDFView and editing mode? # Answer > 1 votes The name of the command you would need to invoke to edit the pdf is: M-x pdf-virtual-edit-mode I don't think toggling is possible but I may be wrong. # Answer > 1 votes Using the standard hooks to remap `C-c C-c` and use it as a toggle key, seems to be the easiest way: ``` ;; edit -> view (add-hook 'pdf-virtual-edit-mode-hook (lambda () (define-key pdf-virtual-edit-mode-map (kbd "C-c C-c") #'pdf-view-mode) )) ;; view -> edit (add-hook 'pdf-view-mode-hook (lambda () (define-key pdf-view-mode-map (kbd "C-c C-c") #'pdf-virtual-edit-mode) )) ``` --- Tags: pdf-tools, docview ---