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-443
https://emacs.stackexchange.com/questions/443
Editing files with one-sentence-per-line
2014-09-29T10:01:48.467
# Question Title: Editing files with one-sentence-per-line *A bit of background.* I’m trying to version-control my latex documents, and the effectiveness of this initiative would be greatly improved if I adopt a *one-sentence-per-line* approach. For instance, the following is what my documents will look like. ``` Some text here. New stencence on the same paragraph. Some more text, still on the same paragraph. This is another paragraph. ``` My question is simple. **How much of that can I automate/improve with Emacs?** The following two points are what I have in mind. 1. My sentences are **long**, so I need to wrap lines without actually filling them. That is, a very long sentence needs to be displayed over several lines on my screen, but it needs to be a single line in the *“.tex”* file. *This would preferably be done in a way that doesn’t wrap equations.* `visual-line-mode` wraps at window width, that is too wide. I need something that wraps lines and limits their width to 80 or so characters. Just like `fill-paragraph` would normally do, but without actually breaking the lines in the file. 2. I can manually break the line after each sentence, but it would be highly preferable if I could configure `fill-paragraph` (or maybe even `auto-fill-mode`) to put one sentence per line as well. # Answer > 12 votes If you just want something like `visual-line-mode` but configurable, you can try `longlines-mode` which is what I use for most of my prose. `longlines-mode` wraps your text similarly to `visual-line-mode` with the width configured by `fill-column`. Here's a screenshot with `fill-column` set to `70` (the window actually extends even more to the right). Configuring `fill-paragraph` would be neat, but I'm not sure how to do it. Instead, here's a reasonable temporary hack: make your `.` character electric in TeX mode, inserting a newline. This just involves rebinding it in whatever the appropriate mode hook is: ``` (defun my-electric-dot () (interactive) (insert ".\n")) (defun my-tex-hook () (local-set-key (kbd ".") 'my-electric-dot)) (add-hook 'TeX-mode-hook 'my-tex-hook) ``` # Answer > 14 votes For (1), I would use an enlarged margin, so that `visual-line-mode` wraps lines at the desired `fill-column`. This will affect both text lines and equations, though. As for (2), one can define a custom filling command to be bound to `M-q` and correctly fill paragraphs. I haven't yet managed to write a command with the correct behaviour for auto-filling. Wrapping this all in a minor mode could look like the following. It is not very beautiful code, but should work in most cases. (I have had the `unfill-paragraph` function in my `init.el` for quite some time without noticing problems). ``` (define-minor-mode ospl-mode "One Sentence Per Line" :init-value nil :lighter " ospl" :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "M-q") 'ospl/fill-paragraph) map) (if ospl-mode (progn (visual-line-mode 1) (setq right-margin-width (- (window-body-width) fill-column))) (visual-line-mode -1) (setq right-margin-width 0)) ;; Account for new margin width (set-window-buffer (selected-window) (current-buffer))) (defun ospl/unfill-paragraph () "Unfill the paragraph at point. This repeatedly calls `join-line' until the whole paragraph does not contain hard line breaks any more." (interactive) (forward-paragraph 1) (forward-paragraph -1) (while (looking-at paragraph-start) (forward-line 1)) (let ((beg (point))) (forward-paragraph 1) (backward-char 1) (while (> (point) beg) (join-line) (beginning-of-line)))) (defun ospl/fill-paragraph () "Fill the current paragraph until there is one sentence per line. This unfills the paragraph, and places hard line breaks after each sentence." (interactive) (save-excursion (fill-paragraph) ; takes care of putting 2 spaces if needed (ospl/unfill-paragraph) ; remove hard line breaks ;; insert line breaks again (let ((end-of-paragraph (make-marker))) (save-excursion (forward-paragraph) (backward-sentence) (forward-sentence) (set-marker end-of-paragraph (point))) (forward-sentence) (while (< (point) end-of-paragraph) (just-one-space) (delete-backward-char 1) (newline) (forward-sentence)) (set-marker end-of-paragraph nil)))) ``` # Answer > 9 votes Would your version-control issues be avoided/resolved if you use git diff --color-words or latexdiff? Then you can look at changed words. # Answer > 2 votes One way of improving this that I have used (at times) for several years is to display sentences with line breaks as flowing after each other by *folding* the line breaks using the facilities of `tex-fold` (a part of AUCTeX). This means that this ``` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pellentesque fringilla justo, quis dapibus velit tincidunt quis? Quisque varius ligula arcu, ut imperdiet risus maximus nec. ``` is folded to ``` Lorem ipsum dolor sit amet, consectetur adipiscing elit⁎ Mauris pellentesque fringilla justo, quis dapibus velit tincidunt quis❓ Quisque varius ligula arcu, ut imperdiet risus maximus nec⁎ ``` I've recently put this together as a minor mode in a package. Perhaps someone else will also find this useful: https://github.com/andersjohansson/tex-fold-linebreaks # Answer > 1 votes Jan Seeger has made Twauctex. One of the features it provides is > Enable one-sentence-per-line mode. It says: > ### Usage > > Simply write your latex as you would normally. twauctex will take care of breaking the line whenever you enter a space after a sentence end. If the standard settings do not agree with you, use (customize-group 'twauctex), and you can customize the builtin configuration. At the time of writing this, the package is not available on MELPA. You need to following installation instructions as provided on the GitHub repo page of Twauctex. --- Tags: latex, fill-paragraph, line-break ---
thread-29726
https://emacs.stackexchange.com/questions/29726
org-mode different latex document class
2017-01-01T15:08:44.203
# Question Title: org-mode different latex document class I am trying to use tufte-book document class in org-mode. But for some reason, org-mode doesn't let me use it and says it is unrecognized. So I am going to the resulting *.tex* file and manually changing `article` to `tufte-book`. But doing this everytime got worrysome. So I want a way to make org-mode recognize tufte-book. I looked for the manual and found something about `org-article` class but couldn't make much sense out of it for my own problem. # Answer By default `org-mode` only knows about the `article`, `report` and `book` classes. To teach it a new one you have to add an entry to it to `org-latex-classes`. I'm not familiar with `tufte-book` but most of the time it suffices to copy the existing values and just change the `\documentclass` part. Adding something like: ``` (add-to-list 'org-latex-classes '("tufte-book" "\\documentclass{tufte-book}" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))) ``` to your config file should enable the class > 12 votes # Answer Tom Dye has made Tufte-org-mode for Org-mode export to PDF. > 0 votes --- Tags: org-mode, org-export, latex ---
thread-59603
https://emacs.stackexchange.com/questions/59603
How to draft email programmatically?
2020-07-13T10:22:01.670
# Question Title: How to draft email programmatically? I use `mu4e` for email with multiple accounts. I have multiple accounts in `mu4e` and followed the manual with a function `my-mu4e-set-account` and a hook to it: ``` (add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account) ``` I can start a message with ``` (compose-mail "To <to@to>" "subject" '(("From" . "me <me@me>"))) ``` I get queried twice about which account to use: ``` [mu4e] Select context: [A]ccount1 [S]omeOther Compose with account: (Account1/SomeOther) ``` and then the "From" of my choice is overwritten by the selection from mu4e. How can I set the "From" header programmatically without `mu4e` asking for the context twice? And how can I pre-fill the body of the email, since `compose-mail` only takes headers in the `other-headers` argument and the body is not a header? **Update**: Following the comments, here is a scenario. I have a list of 20 email addresses to which I want to send a similar email with a custom `To:` and the name in the body. I would like to send those twenty emails programmatically from `mu4e`: * initiate the email * set the right context with the `From:` address * set the subject * set the custom recipient * set the body, customized to the recipient * send the email At the moment, the interactive prompts interrupt me at step 2 of setting the `From:` address. The second prompt was my blunder from adding a function from the manual: ``` (defun my-mu4e-set-account () "Set the account for composing a message. This function is taken from: https://www.djcbsoftware.nl/code/mu/mu4e/Multiple-accounts.html" (let* ((account (if mu4e-compose-parent-message (let ((maildir (mu4e-message-field mu4e-compose-parent-message :maildir))) (string-match "/\\(.*?\\)/" maildir) (match-string 1 maildir)) (completing-read (format "Compose with account: (%s) " (mapconcat #'(lambda (var) (car var)) my-mu4e-account-alist "/")) (mapcar #'(lambda (var) (car var)) my-mu4e-account-alist) nil t nil nil (caar my-mu4e-account-alist)))) (account-vars (cdr (assoc account my-mu4e-account-alist)))) (if account-vars (mapc #'(lambda (var) (set (car var) (cadr var))) account-vars) (error "No email account found")))) (add-hook 'mu4e-compose-pre-hook 'my-mu4e-set-account) ``` From the comments, I can set the body with `message-goto-body` and `insert`. So the only other question is how to set the right context programmatically. I disabled the context switch hooks and tried this code: ``` (compose-mail "" "" '(("From" . "me <me@domain.com>"))) ``` and I get a draft from the last used context email address and a body with a mysterious `158` in it. **Second update**: I read the Contexts part of the manual and am still unclear on how to set the right context. The variables `mu4e-contexts` and `my-mu4e-account-alist` are set to my list of accounts, e.g. `Account1` and `SomeOther`, and I don't know how to tell `mu4e` to pick the one that matches a string such as `SomeOther`. I tried ``` (setq mu4e-compose-pre-hook nil) (mu4e-context-switch nil "SomeOther") ``` I compose a new message with `C-x m` and still get a draft from `Account1`. Although the suggestion of `auto-answer` in a comment could work, I believe a more straightforward solution exists. # Answer > 4 votes Something as simple as this snippet will work, the only pitfall is that `mu4e` should be loaded before trying to select a context or it'll fail. From here you can "complicate" the thing as much as you need. The string used to call the context is the `:name` you used to define it. Also you could get it from `mu4e-contexts` variable. All the rest is pretty straightforward. ``` (defun compose-message (context to subject body) (let ((mu4e-compose-context-policy nil)) (mu4e-context-switch t context) (compose-mail to subject) (message-goto-body) (insert body))) ``` --- Stopped there because in fact you don't want to "draft" in the sense of storing it into draft mail, just to precompose an email automatically, probably check it out, then send. --- Tags: mu4e, email ---
thread-59963
https://emacs.stackexchange.com/questions/59963
Long message showing up while opening emacs from command line in ubuntu 20.04
2020-08-04T16:32:18.973
# Question Title: Long message showing up while opening emacs from command line in ubuntu 20.04 A long message appears every time I open emacs from the command line. I am currently using ubuntu 20.04. The message that appears every time, is shown at the end. It would be very helpful if someone could give me some solution and the reason behind this. A similar situation did not occur in ubuntu 18.04. Is this a problem in the OS? **Message:** ``` /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so: undefined symbol: g_date_time_format_iso8601 Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so Fontconfig warning: "/etc/fonts/fonts.conf", line 5: unknown element "its:rules" Fontconfig warning: "/etc/fonts/fonts.conf", line 6: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'translate' Fontconfig error: "/etc/fonts/fonts.conf", line 6: invalid attribute 'selector' Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/fonts.conf", line 7: invalid attribute 'version' Fontconfig warning: "/etc/fonts/fonts.conf", line 9: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/10-hinting-slight.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/10-hinting-slight.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/10-scale-bitmap-fonts.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/11-lcdfilter-default.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/20-unhint-small-vera.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/30-metric-aliases.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/30-metric-aliases.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/40-nonlatin.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/40-nonlatin.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/45-generic.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/45-generic.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/45-latin.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/45-latin.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/49-sansserif.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/49-sansserif.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/50-user.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/51-local.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/51-local.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/60-generic.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/60-generic.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/60-latin.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/60-latin.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/65-fonts-persian.conf", line 34: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 35: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 36: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/65-fonts-persian.conf", line 36: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/65-nonlatin.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/65-nonlatin.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/69-unifont.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/69-unifont.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/69-unifont.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/70-no-bitmaps.conf", line 8: unknown element "description" Fontconfig warning: "/etc/fonts/conf.d/80-delicious.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/80-delicious.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/80-delicious.conf", line 6: invalid attribute 'version' Fontconfig warning: "/etc/fonts/conf.d/90-synthetic.conf", line 4: unknown element "its:rules" Fontconfig warning: "/etc/fonts/conf.d/90-synthetic.conf", line 5: unknown element "its:translateRule" Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 5: invalid attribute 'translate' Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 5: invalid attribute 'selector' Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 6: invalid attribute 'xmlns:its' Fontconfig error: "/etc/fonts/conf.d/90-synthetic.conf", line 6: invalid attribute 'version' Fontconfig error: Cannot load config file from /etc/fonts/fonts.conf ``` # Answer You've got two types of messages there, so they'll have different fixes. The first is a complaint from the linker that it couldn't load `libgvfsdbus.so` because it was missing a symbol. On my Fedora machine that is provided by the `gvfs-client` package. It's part of Glib, the support libraries for GTK and Gnome. Emacs uses GTK, so it probably gets pulled in along with all the rest. You could remove it, but on my system that would result in removing Nautilus, the Gnome file manager, as well as Evolution, the Gnome email client, as well as rythmbox, a music player, and finally gedit, a text editor. I don't use most of those, but I do use Nautilus, so personally I wouldn't want to just remove it. Still, it's likely providing functionality that Emacs doesn't really care about, so the message is just a warning that you can ignore. Maybe the next upgrade provided by Ubuntu will fix the problem, but to be sure of that you ought to file a bug over on Ubuntu's bug tracker. The other messages are from FontConfig, and they talk about various problems in the config files that FontConfig uses. These are just warnings as well, since FontConfig will still work. It'll probably fall back to some default configuration rather than relying on your broken config files, but you may not even be able to notice that. This is especially true if you've never customized your FontConfig settings. To get rid of the messages you could fix the config files, or figure out why they're broken. Perhaps you upgraded FontConfig, but still have config files from an older version? Maybe at some point in the past you edited those configuration files, and when you upgraded FontConfig the package manager declined to overwrite them as a result. Ubuntu uses a package manager called 'apt' to install software, so perhaps if you read the apt manual you can figure out what it does in that circumstance. Fedora uses a package manager called 'rpm', and I happen to know that it saves a copy of the new config file in the same directory under a different name. Thus I would be able to go look for the `/etc/fonts/fonts.conf.rpmnew` file if that had happened, and I could decide whether to use the new config file or not. Perhaps apt does something similar. > 1 votes --- Tags: fonts, gui-emacs ---
thread-59964
https://emacs.stackexchange.com/questions/59964
How can I insert some multiline text that respects the indentation at which it is inserted?
2020-08-04T18:19:09.927
# Question Title: How can I insert some multiline text that respects the indentation at which it is inserted? I have a function that reads a link from the clipboard and generates a metadata-ful markdown link from it, and inserts it: ``` (defun night/unt () (interactive) (let* ((link (current-kill 0)) (cmd (concat "brishzr.dash " (shell-quote-argument (concat "ec " (shell-quote-argument link) " | inargsf unt")))) ) (message "%s" cmd) (insert (shell-command-to-string cmd)) (save-buffer) )) ``` But this doesn't respect the indentation at which the text is to be inserted. Invoking it on here: ``` * https://github.com/org-roam/org-roam CARET_IS_HERE ``` will produce ``` * https://github.com/org-roam/org-roam * [org-roam/org-roam-server](https://github.com/org-roam/org-roam-server) * A Web Application to Visualize the Org-Roam Database - org-roam/org-roam-server ![](https://avatars0.githubusercontent.com/u/65036520?s=400&v=4) ``` I want it to produce ``` * https://github.com/org-roam/org-roam * [org-roam/org-roam-server](https://github.com/org-roam/org-roam-server) * A Web Application to Visualize the Org-Roam Database - org-roam/org-roam-server ![](https://avatars0.githubusercontent.com/u/65036520?s=400&v=4) ``` # Answer > 0 votes I found an answer: ``` (defun night/unt () (interactive) (let* ( (my-column (current-column)) (link (current-kill 0)) (cmd (concat "brishzr.dash " (shell-quote-argument (concat "ec " (shell-quote-argument link) " | inargsf unt")))) (text (progn (message "%s" cmd) (shell-command-to-string cmd))) ) (let ((lines (split-string text "\n"))) (dolist (line lines) (progn (if (not (string= "" line)) ; so as to not insert the last empty line (insert line "\n" (make-string my-column ?\s)) )))) (save-buffer) )) ``` --- Tags: indentation, text-editing, insert ---
thread-59979
https://emacs.stackexchange.com/questions/59979
Elpy Configuration...Setting Up a Virtual Environment and Pip Conflic with Conda? Need hand holding
2020-08-05T16:08:04.363
# Question Title: Elpy Configuration...Setting Up a Virtual Environment and Pip Conflic with Conda? Need hand holding Full disclosure: I installed anaconda and set it to the path variable. After I did this I was able to access elpy-config which I was not able to (see my prior question). I still pretty much have no idea why this worked and what I'm doing right or wrong. My three questions: **1.** When I type command `M-x pyvenv` I get a message saying `Can't find a workon home directory, set $WORKON_HOME.` How do I actually do this without screwing up the existing paths? **2.** How do I setup a virtual environment? I have trouble understanding this conceptually and I get confused as to what I'm actually doing when following instructions. **3.** I read that having pip and conda simultaneously can bring issues when trying to install various packages. The warning tells me that I need pip...but do I? <pre><code>Elpy Configuration Emacs.............: 26.3 Elpy..............: 1.34.0 Virtualenv........: None Interactive Python: python . (c:/Users/Robby Parliament/AppData/Local/Microsoft/WindowsApps/python.exe) RPC virtualenv....: rpc-venv (c:/Users/Robby Parliament/.emacs.d/elpy/rpc-venv) Python...........: c:/ProgramData/Anaconda3/pythonw.exe 3.8.3 (c:/ProgramData/Anaconda3/pythonw.exe) Jedi.............: 0.17.1 Rope.............: 0.17.0 Autopep8.........: 1.5.3 Yapf.............: 0.30.0 Black............: Not found Syntax checker....: flake8.exe (c:/ProgramData/Anaconda3/Scripts/flake8.exe)``` </code></pre> Followed by: ``` Warnings You have not activated a virtual env. While Elpy supports this, it is often a good idea to work inside a virtual env. You can use M-x pyvenv-activate or M-x pyvenv-workon to activate a virtual env. Elpy could not connect to Pypi (or at least not quickly enough) and check if the python packages were up-to-date. You can still try to update all of them: [Update python packages] Pip doesn't seem to be installed in the dedicated virtualenv created by Elpy (c:/Users/Robby Parliament/.emacs.d/elpy/rpc-venv). This may prevent some features from working properly (completion, documentation, reformatting, ...). You can try reinstalling the virtualenv. If the problem persists, please report on Elpy's github page. [Reinstall RPC virtualenv] The black package is not available. Commands using this will not work. ``` # Answer > 3 votes **Step 1:** If you haven't already done so, go ahead and create a new `conda` environment. Let us say we want to create an anaconda environment with name `py38` which uses `python 3.8`. Execute the following in an (Anaconda prompt) ``` conda create --name py38 python=3.8 ``` *Note:* You can get to an anaconda prompt by clicking on the windows button and then searching for *anaconda prompt* Now we need to find out where the previous `conda create` command created your virtual environment. In the `anaconda prompt` execute: ``` conda info --envs ``` This command will show you a list of locations where your `virtual environments` are located. (including the base environment that anaconda creates by default). The output will look something like the following: ``` # conda environments: # base * C:\ProgramData\Anaconda3 py38 C:\Users\robbie\.conda\envs\py37 ``` Now everytime you create a virtual environment it will (by default) go inside of `C:\Users\robbie\.conda\envs` unless you tell it otherwise by messing with `config` files. Since you are getting started I suggest you go with the default location. **Step 2** We can now set the `WORKON_HOME` to be this location. Put the following in your `init.el` (obviously change it to the actual output you got previously) ``` ;; workon home (setenv "WORKON_HOME" "C:/Users/robbie/.conda/envs/") ``` Now `re-start` emacs and run ``` M-x: pyvenv-workon [TAB] ``` Your previously created virtual environment will now show up here. Choose your desired virtual environment (in this case `py38`) now your `Emacs` session uses this virtual environment. If you now run `elpy-config` you will see that the `python` entry in your `elpy` configuration has changed to something like: ``` Python...........: python 3.8.1 (c:/Users/robbie/.conda/envs/py38/python.exe) ``` If you'd rather use the `base` anaconda. ``` M-x: pyvenv-activate [RET] ``` then give the location of your `base` environment. In your case `c:/ProgramData/Anaconda3`. I suggest you heed elpy's advise here and always work inside a virtual environment. As for your third question `conda` and `pip` can co-exist peacefully. If you want more information see this blogpost by Jake VanderPlas. **Notes**: 1. You can get more information about (for example) `conda create` by running in the `anaconda prompt`. ``` conda create --help ``` 2. In windows you must run these commands in the `anaconda prompt` rather than your regular windows `cmd prompt`. --- Tags: microsoft-windows, elpy, anaconda-mode ---
thread-59983
https://emacs.stackexchange.com/questions/59983
How to revert Dired drag and drop for dirs to old behavior?
2020-08-05T21:59:08.120
# Question Title: How to revert Dired drag and drop for dirs to old behavior? When I drag and drop a directory to Dired in Emacs 26.3, it copies the directory (and its contents) to the directory that Emacs is showing. This is like the behavior in MS Windows explorer. *I don't like that!*, at least not for Emacs. I prefer the old behavior where dired will rather just list that directory in Dired. Can anyone please tell me what to hack to get back that old behavior? (Google did not provide me an answer, alas.) # Answer > 1 votes Here's the answer: `(setq dired-dnd-protocol-alist nil)` after dired is loaded. From dired.el: ``` (defcustom dired-dnd-protocol-alist '(("^file:///" . dired-dnd-handle-local-file) ("^file://" . dired-dnd-handle-file) ("^file:" . dired-dnd-handle-local-file)) "The functions to call when a drop in `dired-mode' is made. See `dnd-protocol-alist' for more information. When nil, behave as in other buffers. Changing this option is effective only for new Dired buffers." ``` --- Tags: dired, drag-and-drop ---
thread-47088
https://emacs.stackexchange.com/questions/47088
I have package X installed as a dependency. How can I discover which package pulls it in? ie Reverse Dependency
2019-01-12T22:40:54.710
# Question Title: I have package X installed as a dependency. How can I discover which package pulls it in? ie Reverse Dependency I tried to delete package X (in order to try an older built-in version). But when I restart emacs, it's automatically re-installed. `package-list-packages` lists it as a dependency so that behaviour seems reasonable, actually quite smart. The trouble is, I can't see what other package has created the dependency. I've tried visiting all the 'installed' and most of the 'dependency' packages in `(package|paradox)-list-packages` but X does not show up as a dependency. I'd prefer to know how to find out this information, but X is org-plus-contrib-20181230 (I won't be uninstalling this permanently, it's just curiosity). # Answer > 3 votes All packages are in *~/.emacs.d/elpa* Package dependencies are listed in files ending with "*-pkg.el*" in each package directory. To find which packages require some package, find "*-pkg.el*"'s that contain that package's name. ## Using `M-x rgrep`: Example: find all packages that require "*popup*" package. `M-x rgrep` prompts: ``` Search for: ``` Each dependency is in a list, so the name starts with a "**(**", then goes package name, one or more spaces, and a double quote(**"**) of a version string. So, use basic regular expression to find a string in this format: `(popup "` ``` Search for: **(popup \+"** ``` ``` Search for "(popup \+"" in files matching wildcard: ***pkg.el** ``` ``` Base directory: **/home/somename/.emacs.d/elpa/** ``` ## Result: A *\*grep\** buffer with links to all packages that depend on *popup*. ## UPD In such situations just ``M-x rgrep`` everything. I grepped all my Emacs installation for a "contrib" word. And there' a NEWS org file that logs all changes in new versions. In version 7.9.2, about that "//orgmode.org/elpa/": > You can now add the Org ELPA repository like this: > > (add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) > > It contains both the =org-*.tar= package (the core Org distribution, also available through https://elpa.gnu.org) and the =**org-plus*****.tar**= package (**the extended Org distribution, with non-GNU packages from the =contrib/= directory**.) # Answer > 1 votes Another reason a package might be listed as a dependency is because it is in `~/.emacs.d/elpa`, but not in `package-selected-packages`. One possible way to reach that state is install a newer version of a package, notice it, and delete one of them. --- Tags: package ---
thread-58008
https://emacs.stackexchange.com/questions/58008
File org-capture entry under current headline at point
2020-04-23T21:55:03.910
# Question Title: File org-capture entry under current headline at point Let's say that I have a tree of tasks like so: ``` * TODO Launch website ** TODO Get database running *** TODO Select MySQL vs. PostgreSQL ``` Let's say I'm looking at the "Select MySQL vs. PostgreSQL" and I decide I want to file a task under that headline using my Org Capture template. Is there a way to directly tell `org-capture` to file the new headline under the current headline (i.e., the headline at `(point)`)? I'm aware of the `(clock)` capture target, but I don't necessarily want to have to clock in at the current point. # Answer Go to a new line below the headline `*** TODO Select MySQL vs. PostgreSQL` Then press `C-u 0` before your capture key, i.e. ``` C-u 0 <your_capture_key> ``` and you're good to go. The indentation level will be three stars, so you have to indent it manually by `M- rightarrow` You can also press `C-0 <your_capture_key>` and Emacs will interpret it as `C-u 0` > 3 votes # Answer I've implemented the following functions to implement this feature: * `my-org-capture-under-headline`: the main command. * Some advice around `org-capture` to provide a new `C-u 2` prefix argument ``` ;; Create ‘C-u 2 M-x org-capture’ command to refile org-capture template under ;; headline at point. (defun my-org-capture-under-headline (&optional _goto keys) "Capture under the headline at current point. This finds an appropriate point at the end of the subtree to capture the new entry to, then call ‘org-capture’ with \"C-u 0\" to capture at this new point, and finally fixes the level of the newly-captured entry to be a child of the headline at which this function was called. KEYS are passed to ‘org-capture’ in its KEYS argument. _GOTO corresponds to the GOTO argument of ‘org-capture’, but is is ignored because we intentionally place the point where we want it." (interactive "P") (unwind-protect (progn (unless (eq major-mode 'org-mode) (user-error "Must be called from an Org-mode buffer")) (org-with-point-at (point) (org-back-to-heading t) (let* ((headline-marker (point-marker)) (headline-level (org-current-level))) (org-end-of-subtree t) (unless (org--line-empty-p 1) (end-of-line) (open-line 1) (forward-line 1)) (cl-letf* (((symbol-function 'my-org-capture-under-headline--fixup-level) (lambda () ;; If :begin-marker doesn’t point to a buffer, the capture ;; has already been finalized, so don’t try to do any work ;; in that case. (when-let* ((begin-marker (org-capture-get :begin-marker)) ((marker-buffer begin-marker))) ;; Go to the capture buffer. (org-goto-marker-or-bmk begin-marker) ;; Make the captured headline one level below the original headline. (while (< (org-current-level) (+ 1 headline-level)) (save-excursion (org-demote-subtree))) (while (> (org-current-level) (+ 1 headline-level)) (save-excursion (org-promote-subtree)))))) ;; Store the original ‘org-capture-finalize’ for the override before. ((symbol-function 'org-capture-finalize-orig) (symbol-function 'org-capture-finalize)) ;; Need to fixup level in case ‘:immediate-finish’ set in ‘org-capture-templates’ ((symbol-function 'org-capture-finalize) (lambda (&optional stay-with-capture) (my-org-capture-under-headline--fixup-level) (org-capture-finalize-orig stay-with-capture)))) (apply #'org-capture 0 keys) ;; If the template didn’t contain ‘:immediate-finish’, we fix up ;; levels now. (my-org-capture-under-headline--fixup-level))))))) (defun my-org-capture-under-headline-prefix (_orig-fn &rest _args) "Provide an additional “C-u 2” prefix arg to `org-capture'. When ‘org-capture’ is called with this prefix argument, it will capture a headline according to the template you select, and then immediately refile that headline under the headline at the current point." (let ((goto (nth 0 _args))) (if (equal goto 2) (apply #'my-org-capture-under-headline _args) (apply _orig-fn _args)))) (advice-add 'org-capture :around #'my-org-capture-under-headline-prefix) ``` **Update 2022-02-22**: make the function more robust. > 1 votes --- Tags: org-mode, org-capture ---
thread-59956
https://emacs.stackexchange.com/questions/59956
Xref / xref-find-refernces / Windows 7 does not work
2020-08-04T11:37:46.927
# Question Title: Xref / xref-find-refernces / Windows 7 does not work I'm struggling with Xref `M-?` finding references to symbols (C-code). It doesn't work for (e)tags nor for any symbol even in the buffered file. The Xref window/buffer with results is not opened instead an error-message ist displayed in the minibuffer 'No references found for: ' The strange thing is: `M-.` works perfectly! `emacs-version` 26.3, Windows 7 (on Macintosh the same Emacs version has no such problem) Is there anything missing under Windows, which is needed for Xref? Output of functions: `(project-roots (project-current))` "Minbuffer: No applicable method: project-roots, nil" `(insert (format " >%s<" (semantic-symref-detect-symref-tool)))` \>grep\< # Answer Try downloading `grep.exe`, `find.exe` and `xargs.exe` and putting them somewhere in `PATH`. Last I checked, https://sourceforge.net/projects/ezwinports/ had good binaries for MS Windows. > 0 votes # Answer The problem is really because of grep and find missing on the Windows-system. You need the GnuWin or equivalent tools on the Windows-system. That is the easy part. I took GnuWin findutils, grep and pcre. Afterwards they must be added to the environment variable PATH. Which is also not a problem and won't need any further work, if there wasn't the fact, that Windows also comes with a 'find' which isn't compatible with the GNU-version. So you have to make sure, that the GNU-find comes first. Without admin rights or 'batching' impossible on Windows (my knowledge). Emacs has it's own search-path called `exec-path`, which is at start a copy of the components of PATH. I decided to adapt my configuration file to extend both by placing the search-tools before anything else, for PATH and for exec-path: ``` (cond ((string-equal system-type "windows-nt") (setq lh-add-path '("C:/Users/user/app/findutils/bin" "C:/Users/user/app/grep/bin" "C:/Users/user/app/pcre/bin")) (setq exec-path (append lh-add-path exec-path)) (setq lh-tmp-path "") (while lh-add-path (setq lh-tmp-path (concat lh-tmp-path (format "%s;" (car lh-add-path)))) (setq lh-add-path (cdr lh-add-path))) (setq lh-tmp-path (replace-regexp-in-string "/" "\\\\" lh-tmp-path)) (setenv "PATH" (concat lh-tmp-path (getenv "PATH"))))) ``` > 0 votes --- Tags: microsoft-windows, tags, xref ---
thread-59992
https://emacs.stackexchange.com/questions/59992
Emacs install folder vs .emacs.d vs .emacs/.emacs~ confusion [Windows 10]
2020-08-06T19:05:22.810
# Question Title: Emacs install folder vs .emacs.d vs .emacs/.emacs~ confusion [Windows 10] I've recently run into complications regarding elpy and setting up virtual environments (see other questions) which have brought me back to a more fundamental issue that I must resolve before I continue integrating python functionality into emacs. **Details:** 1. My HOME environment variable is located in `c:\users\robby parliament` 2. My root emacs install folder is located in `c:\users\robby parliament\documents` 3. The `.emacs` and `.emacs~` *files* are also located in `c:\users\robby parliament` 4. The .emacs.d *folder* is also located in `c:\users\robby parliament` and contains the following items: ``` > - c:\users\robby parliament > --- .emacs.d > ----- auto-save-list > ----- elpa > ----- elpy > ----- snippets > ----- url ``` **Questions:** 1. When I move the `.emacs` and `.emacs~` files into the `.emacs.d` folder I lose my theme (dracula), why is this so? 2. In response to the above question I figured I must change the HOME environment variable to \`c:\users\robby parliament.emacs.d, so when I do that I get the following warning/error: ``` Warning (initialization): An error occurred while loading ‘c:/Users/Robby Parliament/.emacs.d/.emacs’: Symbol's function definition is void: elpy-enable To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the ‘--debug-init’ option to view a complete error backtrace. ``` 3. Then when I move the `.emacs` and `.emacs~` files *into* the `.emacs.d` subfolder within `c:\users\robby parliament\.emacs.d` the warning is now gone yet the theme is still gone. I've watched LigerLearn's tutorial on setting up emacs and the customization of the file paths several times but I feel like I'm still not understanding a fundamental concept which is bringing me all these warnings and errors. What am I doing wrong? Also, this is within my `.emacs` file: ``` ;; Added by Package.el. This must come before configurations of ;; installed packages. Don't delete this line. If you don't want it, ;; just comment it out by adding a semicolon to the start of the line. ;; You may delete these explanatory comments. (package-initialize) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(ansi-color-faces-vector [default default default italic underline success warning error]) '(ansi-color-names-vector ["black" "red3" "ForestGreen" "yellow3" "blue" "magenta3" "DeepSkyBlue" "gray50"]) '(custom-enabled-themes (quote (dracula))) '(custom-safe-themes (quote ("b46ee2c193e350d07529fcd50948ca54ad3b38446dcbd9b28d0378792db5c088" default))) '(display-line-numbers t) '(package-archives (quote (("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "http://stable.melpa.org/packages/")))) '(package-selected-packages (quote (flymake elpy dracula-theme))) '(ring-bell-function (quote ignore)) '(visible-bell nil)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) '(setq visible-bell 1) (elpy-enable) (define-key yas-minor-mode-map (kbd "C-c k") 'yas-expand) (define-key global-map (kbd "C-c o") 'iedit-mode) ``` # Answer > 0 votes 1. When you move `.emacs` to `emacs.d`, Emacs just can't find it. It must reside in the `HOME` directory. You can move it to `emacs.d` but you have to rename it. You can see the pertinent Emacs manual section "The Emacs Initialization File". 2. When you change the `HOME` directory, Emacs can't find the `emacs.d` directory, which is referenced by the variable `user-emacs-directory`, with a default value of "~/.emacs.d/". 3. I don't know. But you should not be doing that anyway. Why are you moving `.emacs` into `.emacs.d`? It doesn't belong there, but in your `HOME`. When you point `HOME` to `emacs.d`, your are messing the setup of your packages. If you really need to move `.emacs` into `emacs.d` you can do so by renaming it to `init.el`. It is in the manual section "The Emacs Initialization File". --- Tags: init-file, microsoft-windows ---
thread-59997
https://emacs.stackexchange.com/questions/59997
More than one value for properties (multiple values)
2020-08-07T11:44:44.647
# Question Title: More than one value for properties (multiple values) I would like to assign, for example, more then one responsible person to a task. I thought to use properties like ``` :PROPERTIES: :RESPONSIBLE: Kate :RESPONSIBLE+: Aaron :END: ``` But my agenda search for `RESPONSIBLE="Aaron"` has no results. One reason not to use tags is, I can easily search for tasks without a responsible person, if the values were numbers, I could use operators like `>` and it does not clutter the headings with a lot of tags. Is there a way to do this with properties? Or is there a different way to make agenda search include, e. g., a todo with multiple responsible persons? # Answer > 2 votes Property values are strings. The value of the property `RESPONSIBLE` above is the string `"Kate Aaron"`, so your search does not find it. You could do a regular expression search instead: `RESPONSIBLE={Aaron}` (see Matching tags and properties for details). IMO however, you are better off using tags. Given headlines like this: ``` * TODO Something :Kate:Aaron: ... * TODO Something else ``` you can do `C-c a m +Aaron` to find headlines tagged with `Aaron` and you can find unassigned headlines with `C-c a m TAGS=""` \- this is using the fact that Org recognizes Special properties. --- Tags: org-mode, org-agenda ---
thread-59998
https://emacs.stackexchange.com/questions/59998
Restrict agenda to current buffer (with few keystrokes)
2020-08-07T13:31:57.750
# Question Title: Restrict agenda to current buffer (with few keystrokes) I would like to call an agenda which is restricted to the current buffer, even if it is not in the agenda files. I tried to go one way with a custom agenda here, but it feels like maybe peeling the banana from the wrong side. I know about the `<` feature in the agenda dispatcher, but maybe there is a shorter way. How can I call an agenda, which is restricted to the current buffer, using as few keystrokes as possible? # Answer Here's two implementations. The first one is along the lines that @Aquaactress suggested in a comment: ``` (defun my/org-agenda-list-current-buffer () (interactive) (let ((org-agenda-files (list (buffer-file-name (current-buffer))))) (call-interactively #'org-agenda))) ``` Basically, rebind `org-agenda-files` temporarily before calling `org-agenda`. You get the dispatcher, type `a` and get the daily/weekly/whatever agenda but with just the current buffer contributing. The code is missing error handling: in particular, it should check that the current buffer is associated with a file and the file is in Org mode. The second implementation bypasses the dispatcher, so it is closer to your "few keystrokes" desideratum: ``` (defun my/org-agenda-list-current-buffer (&optional arg) (interactive "P") (org-agenda arg "a" t)) ``` This pre-chooses the daily/weekly/whatever agenda (the `"a"` argument) and sets the restriction (the `t` argument) when calling `org-agenda`. It uses the same `"P"` `interactive` spec that `org-agenda` uses in order to deal with a prefix argument. The error handling comments above apply to this case too. You can then bind whichever function you prefer to a key that will allow you to call it. It's probably best to use the Org mode map for that, since it does not make sense to call either of the functions above in a non-Org mode buffer. That ameliorates a bit the need for error handling: the key is only bound in Org mode buffers - but you will get an error if the buffer is not associated with a file in either implementation. If you are using GUI emacs, you probably have access to function keys with modifiers, so I'm using the `C-<f12>` key, since it was undefined in my case - which key to use is up to you though: I just wanted to provide an example: ``` (define-key org-mode-map (kbd "<C-f12>") #'my/org-agenda-list-current-buffer) ``` EDIT: In reply to how to restrict to subtree, all you need to do is to change the `t` argument in the second implementation. That argument can be a symbol with any of the following values: `buffer`, `subtree` and `region`. The call ``` (org-agenda arg "a" t) ``` is equivalent to ``` (org-agenda arg "a" 'buffer) ``` so you can restrict to e.g. the current subtree with ``` (org-agenda arg "a" 'subtree) ``` PS. I hope this works, but I have not tested it, so there may be problems. I'll do some testing at some point to verify. > 1 votes --- Tags: org-mode, org-agenda ---
thread-59966
https://emacs.stackexchange.com/questions/59966
Is it possible to prevent screen flashing on combination of `isearch` and `recenter`?
2020-08-05T01:03:15.250
# Question Title: Is it possible to prevent screen flashing on combination of `isearch` and `recenter`? I have followed answer for Emacs: Combine iseach-forward and recenter-top-bottom, replacing `(recenter-top-bottom)` to `(recenter)`. My goal is to re-center after each `isearch-forward` or `isearch-backward`. When I put same two words into the buffer and do `isearch-repeat-forward` operation (CTLR and hold `s` for the selected word) screen keep flashes (like keep blinks). This does not happen on default `isearch-repeat-*` operation. **\[Q\]** Is it possible to prevent flashing on combination of `isearch` and `recenter`? --- My setup: ``` (defadvice isearch-repeat-forward (after isearch-repeat-forward-recenter activate) (recenter)) (defadvice isearch-repeat-backward (after isearch-repeat-backward-recenter activate) (recenter)) (ad-activate 'isearch-repeat-forward) (ad-activate 'isearch-repeat-backward) ``` # Answer In a comment underneath the question, the O.P. stated that he/she is using a version of Emacs on macOS Catalina -- presumably the GUI version (although not stated one way or the other). In the event that Alan Third (the maintainer of the macOS port of Emacs) reads this, I really do appreciate everything that he has done and continues to do to keep the macOS port of Emacs alive. My comments are not meant to be a criticism of anything he has implemented as a means of working around certain problems introduced by Apple ... For at least as long as I have been using Emacs (i.e., version 24), and probably a lot longer than that, Emacs updated the glass directly during its redisplay cycle when running `update_window` in `dispnew.c`. All was well until Apple introduced its Mojave version of the macOS operating system -- effectively doing away with the ability for applications such as Emacs to update the glass directly at any given time during its redisplay cycle. In a nutshell, applications must now wait until the OS calls `drawRect` to update the glass. It is possible (but not recommended), or at least it was possible the last time I checked, to force the OS to call `drawRect` out of order in its normal redisplay cycle. As of 09/28/2018 (7946445962372c4255180af45cb7c857f1b0b5fa), the macOS port of Emacs now only marks dirty rectangles (areas that need updating) during `update_window` and then Emacs has to wait until the OS calls `drawRect` to update the areas of the glass that had been marked as dirty -- triggering Emacs to run `expose_frame` on said areas. That changeover in the way the glass is updated during redisplay causes certain screen glitches (e.g., flickering) in terms of areas that do not update correctly and/or certain additional areas of the screen are redrawn (which was not the case prior to 09/28/2018). I do not have a solution for those issues, sorry. I would suggest that the O.P. reduce the number of calls to `recenter` to an absolute bare minimum. My preference would be to run `recenter` prior to `isearch` calling `isearch-update`, because the latter updates the display based upon the lay of the land. I.e., running `recenter` *after* `isearch` runs `isearch-update` seems unwise (in my opinion). My idea is to call `recenter` *only* when the line containing point is not centered. I considered using something like `count-screen-lines` and recording the line containing point, but I know from experience that `vertical-motion` can slow things down when called excessively. I also know that `posn-at-point` can slow things down when called excessively, but I figure it will probably suffice for this use-case to help us record the Y-axis containing point. If the Y-axis containing point has changed, then `recenter` and record the new `Y` and the `selected-window` in a variable -- to be compared against future values. Other than reducing the calls to `recenter` as in the following example, I cannot think of anything else to reduce screen flickering: ``` (defvar my-isearch-window-start '(nil 0) "Record the `selected-window' and the Y-axis coordinate of point each time that `isearch-update' calls `my-isearch-update-recenter' (via an advice). The value of this variable will be a cons cell with the CAR being the `selected-window' and the CDR being the Y-axis coordinate of point.") (defun my-isearch-update-recenter () (let* ((win (selected-window)) (pt (point)) (y (cdr (nth 2 (posn-at-point pt win)))) (same-y-p (and y (eq win (car my-isearch-window-start)) (= y (cdr my-isearch-window-start))))) (when (and y (not same-y-p)) (recenter) (setq my-isearch-window-start (cons win y))))) (advice-add 'isearch-update :before 'my-isearch-update-recenter) ``` **USAGE**: **(1)** Open up either a terminal *or* a GUI version of Emacs 26.3.50, built for the OSX/macOS platform, *without* any user configuration -- aka `/path/to/correct/version/of/Emacs -nw -Q` or drop the `-nw` from the command-line if the GUI version is desired. I have tested the code on both a terminal version of Emacs and also a GUI version of Emacs -- the procedure and result should be the same. \[NOTE that many versions of OSX/macOS came with Emacs 22.1.1 pre-installed at `/usr/bin/emacs` -- therefore, we want to be sure to launch a current version of Emacs by either using the absolute path to the executable or navigating to its directory and typing `./Emacs ....` In my case, the Emacs executable is inside a packaged Emacs.app directory located at `/Applications/Emacs.app/Contents/MacOS/Emacs`\] **(2)** Copy the code snippets from the answer above, and then switch to the `*scratch*` buffer in Emacs and paste the code snippets we just copied, and then type `M-x eval-buffer`. **(3)** Open a lengthy test file by typing `M-x find-library RET simple RET`, which will open the `simple.el` library if our version of Emacs was built using the standard defaults that install the Lisp source code. **(4)** Type the keyboard shortcut `C-s` which is bound to `isearch-forward` by default. **(5)** `isearch-forward` is now active based upon the preceding step. Type the letters: `update`. Emacs searches forward for the first occurrence of the letters `update` and automatically recenters the screen. **(6)** Now we want to search for the next occurrence of the letters `update`. To do that, we can either type the keyboard shortcut `C-s` or `s-g` (aka Command-g) -- both keyboard shortcuts are bound to `isearch-repeat-forward`. Emacs searches forward for the next occurrence of the letters `update` and recenters the screen. **(7)** We can continue repeating the preceding step to verify that everything is working as advertised. This concludes our test. > 2 votes --- Tags: isearch ---
thread-60008
https://emacs.stackexchange.com/questions/60008
How to call a custom agenda command?
2020-08-08T10:37:45.120
# Question Title: How to call a custom agenda command? In org-mode, I have a custom agenda set with: ``` (setq org-agenda-custom-commands '(("d" "todo" agenda "" ((org-agenda-span 1) (org-agenda-start-day "-0d") (org-agenda-start-with-log-mode '(closed)) )) )) ``` I can call it with `C-c a d`. I want to call it programmatically. The documentation offers passing an argument: > (org-agenda &optional ARG ORG-KEYS RESTRICTION) > > Dispatch agenda commands to collect entries to the agenda buffer. Prompts for a command to execute. Any prefix arg will be passed on to the selected command. The default selections are: > > a Call ‘org-agenda-list’ to display the agenda for current day or week. I tried: ``` (org-agenda "a") ``` and get the same prompt as if I had run `(org-agenda)`. So I don't know how to proceed to the next step of selecting the custom agenda (the "d" after the "a"). How can I call this custom agenda programmatically? # Answer I found the answer in Is there a way to start org-mode agenda with a custom search? : ``` (org-agenda nil "d") ``` > 9 votes --- Tags: org-mode, org-agenda ---
thread-60004
https://emacs.stackexchange.com/questions/60004
Getting `dvisvgm` to work with `org-latex-preview`
2020-08-08T04:27:24.763
# Question Title: Getting `dvisvgm` to work with `org-latex-preview` I am relatively new to Emacs and `org-mode`, and I would like the images displayed by `org-latex-preview` to be `svg`. I am trying to follow the instructions from this Stack Exchange question. I have `(setq org-latex-create-formula-image-program 'dvisvgm)` in my configuration file, but the image I'm seeing is definitely not `svg` and rather seems to be the same as what appears with that variable set to `dvipng` instead. Changing the variable to `imagemagick` does visibly change the image, so I know that Emacs is reading this line of the config file. I can open and view a separate `svg` image with Emacs, so I know that Emacs is able to view `svg` files. Also, when I include `#+OPTIONS: tex:dvisvgm`, the LaTeX is rendered as an `svg`, so I know that Emacs can talk to `dvisvgm`. I am using: * Doom with Emacs 26.3 * org-mode 9.4 * MacOS Catalina # Answer > 1 votes The answer to the question is that the images I was looking at *were* svg files (they were not in a `ltximg` subdirectory, but in `~/.emacs.d/.local/cache/org-latex`, maybe something to do with Doom). I learned from this question that the blurriness is a known issue in Emacs. --- Tags: org-mode, latex ---
thread-60011
https://emacs.stackexchange.com/questions/60011
ORG. A way to mark a subtree to be exported only on one format?
2020-08-08T14:29:22.783
# Question Title: ORG. A way to mark a subtree to be exported only on one format? I'm writing a document to be PDF exported in org, and I'm also collaborating with a proof reader. I send her exports on ODT so she can open the documents and make edits in an easy way for her. I have a complex part that I'm directly writing in latex so I can export it to the pdf, but I also wrote the part in plain text using tables so she can check it, each one on it's own tree. Is there a way to mark one tree to only export on ODT and the other to only export on Latex? So far I'm using the `:noexport:` tag, but switching between exports is tedious. # Answer > 4 votes You can use tags to differentiate the sections: ``` * Section one This section will be exported always. * Section two :export_latex: This section should only be exported with the LaTeX/PDF exporter. * Section three :export_odt: This section should only be exported with the ODT exporter. ``` The trick is to then define the appropriate set of `noexport` tags: you basically want to define the equivalent of ``` #+EXCLUDE_TAGS: export_latex ``` when you export to ODT and ``` #+EXCLUDE_TAGS: export_odt ``` when you export to LaTeX/PDF. So instead of fiddling around with adding and removing tags, you can add the above tags permanently, add both `#+EXCLUDE_TAGS` lines to the file and then comment/uncomment appropriately: ``` # #+EXCLUDE_TAGS: export_latex #+EXCLUDE_TAGS: export_odt ``` for LaTeX/PDF export and ``` #+EXCLUDE_TAGS: export_latex # #+EXCLUDE_TAGS: export_odt ``` for ODT export. That should work better than your current method but it still involves fiddling every time you export, so the next step would be to do these settings through two different functions exporting to the two different formats. Here's an implementation with the two functions bound to `C-<f11>` and `C-<f12>` resp. (which only works in GUI Emacs AFAIK, so you should probably decide your own key bindings): ``` #+OPTIONS: tags:nil * foo ** Section one This section will be exported always. ** Section two :export_latex: This section should only be exported with the LaTeX/PDF exporter. ** Section three :export_odt: This section should only be exported with the ODT exporter. * Code :noexport: #+begin_src emacs-lisp (defun ndk/org-export-as-latex () (interactive) (let ((org-export-exclude-tags '("export_odt" "noexport"))) (org-open-file (org-latex-export-to-pdf)))) (defun ndk/org-export-as-odt () (interactive) (let ((org-export-exclude-tags '("export_latex" "noexport"))) (org-open-file (org-odt-export-to-odt)))) (define-key org-mode-map (kbd "C-<f11>") #'ndk/org-export-as-odt) (define-key org-mode-map (kbd "C-<f12>") #'ndk/org-export-as-latex) #+end_src ``` With that, you should be able to export in either of the two formats with the press of a key. --- Tags: org-mode, org-export ---
thread-28731
https://emacs.stackexchange.com/questions/28731
Easiest way to downgrade a package installed via MELPA
2016-11-18T05:51:33.190
# Question Title: Easiest way to downgrade a package installed via MELPA Sometimes, package updates from MELPA can break some part of emacs and when that happens I'd like to be able to revert back to using an older version of the package. Right now, I can do it in two ways: * I've set emacs to delete files by moving to trash and when I update a package, the older version is trashed. I can retrieve the older version and replace the one in `~/.emacs.d/elpa`. * Go to the github repo of the package that broke functionality, fetch an older version of the package, replace the one in `~/.emacs.d/elpa` with the one from gitub, byte-recompile the file(s). Both these ways involve a lot of manual work moving things around. Is there an easier(preferably automatic) way to downgrade packages installed from MELPA? # Answer > 12 votes When you update your packages through the `M-x list-packages` interface, after the successful installation of the package, you'll get asked if you want to remove the old package. Don't delete them so they stay in place and you could then later remove the newer package through this interface. My current package list shows 4 versions of magit installed in my ~/.emacs.d/elpa/ directory tree. ``` magit 20160827.1549 obsolete A Git porcelain inside Emacs magit 20160907.945 obsolete A Git porcelain inside Emacs magit 20161001.1454 obsolete A Git porcelain inside Emacs magit 20161123.617 installed A Git porcelain inside Emacs ``` You can clean-up old versions later with the key `~` (package-menu-mark-obsolete-for-deletion) to mark all obsolete packages. To delete a certain old version move to its line and press `d` to mark them for deletion. After you marked the packages you'd use `x` to execute the actions as usual. In **Emacs 25** the mark all packages for `U`pgrade functionality automatically sets all old packages for deletion, and doesn't prompt for confirmation after installing. You have to look for lines that start with a capital "D", which you can just unmark (best with the following macro) Type the key or chord on the left of the dash from the following lines. ``` <F3> - start macro recording C-s - isearch-forward C-q - quoted-insert C-j - linefeed character D - the mark at the start of the line <Ret> - stops the isearch on the line with the "D" u - unmark the package for deletion <F4> - stops macro recording - the first package is now unmarked <F4> - executes the macro for the next upgraded package ``` If there are no further matches for the search the macro will ring the bell and stop, so you could `C-u 0 <F4>` to unmark all packages marked for deletion. After this you can e`x`ecute the installations. The function I declared to be changed in my comment has to be changed in a way I cannot grasp yet, as it's important that the last (cond) block has to be successful in order to not loop endlessly. # Answer > 11 votes The "nuclear option", as it were, would be to ditch `package.el` entirely and instead use the package manager that I wrote, `straight.el`. The advantage would be that `straight.el` installs packages by cloning their Git repositories, thereby making it trivial to use whichever version you would like. Also, `straight.el` provides functionality for dealing with revision lockfiles, which allow you to record the exact state of your package management configuration down to the smallest detail. Then, in the case of an emergency, you can simply revert all packages to their known-good versions. These kinds of operations are, in general, impossible with `package.el`, and they will always be impossible, due to the overall design. In response to your desire to avoid making a commit every time you update your packages, this is not necessary with `straight.el`. I would *recommend* writing a version lockfile and committing that every time you update your packages, since that makes it impossible to ever get into a state where your Emacs configuration is broken after an upgrade and you don't know how to revert. But you don't have to do this, if you like living life on the edge. # Answer > 5 votes I find an easy way to downgrade: managing your own melpa archive. 1. Clone melpa repo. 2. Follow melpa's custom melpa archive wiki page to remove all recipes. 3. Find the commit of the package you want to down grade to, and create a new recipe with that commit for the package. (see melpa's readme about how to specify the commit) 4. Run `make` to build the downgraded package 5. Add your own melpa archive, which can be a local directory, to the `package-archives` list. 6. Install the downgraded package using the package menu. Or you can use `package-pinned-packages` to restrict the archive where the package should be downloaded from. # Answer > 4 votes Lots of people elect not to commit ELPA packages to version control, but this is an example of why I believe you should do so. Reverting *anything* is trivial if it's all committed. Depending on the state of the upstream ELPA packages is a risk. # Answer > 2 votes I download the package from github(the package home page) and build it, and recover files to `.emacs.d/elpa`. for example: If I want to downgrade package - hl-todo to version `3bba4591`, I can download the specific version package, then build it (with the command `make`), and it will generate `.elc` files and others. Copy and Cover them to `~/.emacs.d/elpa/hl-todo-20200807.1546` (replace the timestamp with yours) --- Tags: package, package-repositories ---
thread-60017
https://emacs.stackexchange.com/questions/60017
How to disable "/" 's default behavior on the F interactive mode?
2020-08-08T17:16:59.523
# Question Title: How to disable "/" 's default behavior on the F interactive mode? I use interactive mode with Ivy and Dired for interactively creating new files, like so: ``` (evil-local-set-key 'normal (kbd "t") (lambda (file) (interactive "Ftouch ") (let ((target_exists (file-directory-p file)) (target_dir (file-name-directory file))) (unless target_exists (make-directory target_dir t)) (with-temp-buffer (append-to-file (point-min) (point-max) file)) (revert-buffer) (dired target_dir)) ``` It works fine. The problem is that the `/` key always automatically completes what I am currently hovering in the completion list. Please take a look at the following GIF: https://gfycat.com/parallelscratchyhuman When I type `.` `A` `M` `/`, interactive mode will automatically complete it to ".AMD/", which is not my intention. What I want to do is get rid of this "completion" behavior of `/` to not disturb what I am typing, i.e. pressing `/` only outputs the literal `/` character and nothing else. # Answer > 0 votes After reading the documentation and the source code of `ivy`, I think there is no way to disable the effect of `/` elegantly. I may be wrong, those who are interested in the question can see the function `ivy--update-minibuffer` which calls `ivy--magic-file-slash` to autocomplete directory by `/` if only one directory matched the input string. **Workaround** Simply disable the function which triggers the directory completion, i.e `ivy--magic-file-slash`. (Not a great idea, because it is a "private" function of `ivy`.) First, define an advice function doing nothing. ``` (defun disable-function (oldfun &rest args)) ``` Then, replace your interactive snippet by this one: ``` (interactive (let ((file)) (advice-add #'ivy--magic-file-slash :around #'disable-function) (setq file (read-file-name "touch ")) (advice-remove #'ivy--magic-file-slash #'disable-function) (list file))) ``` The code above disables the effect of `/` before prompting for a filename (exactly as `(interactive "Ftouch ")` do) and then enable it again `/` in case you need it in another context. You will need to press `C-j` manually to complete existing directories. For instance in your example, if you want to touch the file `.AMD/Dir1/file.txt`, you will need to press `C-j` after that `.AMD` is selected as a candidate, so that the completion of its subdirectories will be possible. **Old (wrong) answer**: I think you are looking for the keybinding `C-M-j` (`ivy-immediate-done`, see the documentation). > Exits with the current input instead of the current candidate (like other commands). --- Tags: key-bindings, dired, completion, interactive, ivy ---
thread-60010
https://emacs.stackexchange.com/questions/60010
How rebind (remap) one key binding to another?
2020-08-08T14:06:19.683
# Question Title: How rebind (remap) one key binding to another? Emacs 26.1 I have key binding `C-a C-SPC C-e M-w` copies the current line without the newline. But it's too long. I want to change it to `C-c` So as result when I press `C-c` to copies the current line without the newline. Is it possible? # Answer > 3 votes Emacs commands are usually interactive function, but keyboard macro (i.e., a string or vector) works too, so you can write: ``` (global-set-key (kbd "C-o") (kbd "C-a C-SPC C-e M-w")) ``` An better (more rebust and efficient) option is writing some Lisp code, e.g., ``` (defun your-copy-current-line () (interactive) (kill-new (buffer-substring (line-beginning-position) (line-end-position)))) (global-set-key (kbd "C-o") #'your-copy-current-line) ``` Regarding to `C-c`, it is already occupied by default as a prefix key. I beilieve it's possible to unbind the prefix key. # Answer > 3 votes Use a keyboard macro. Keyboard macros are explained in chapter 17 of the Emacs manual, which is available online as well as inside emacs (type `C-h i` and select the Emacs manual). In your case, you want to start recording the keyboard macro by typing `F3`, then typing out the keys you want the macro to execute (`C-a C-SPC C-e M-w`). Finally, end the recording by typing `F4`. Now you can replay the macro by hitting `F4`. But `F4` will replay only the most recently recorded macro, so you still want to save this macro for later use. To do that, first give the macro a name by typing `C-x C-k n`, and then typing in some name like `copy-current-line`. Now open your emacs init file (`~/.emacs.d/init.el` by default on non-windows systems). Now run `M-x insert-kbd-macro`. It will ask you for the name of the macro you want to insert, but just leave it blank and hit return, so that it inserts the most recent macro. It will insert two lines that look like this: ``` (fset 'copy-current-line (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([1 67108896 5 134217847] 0 "%d")) arg))) ``` Finally, add a keybinding by typing in code that looks like this: ``` (global-set-key (kbd "C-c C-c") 'copy-current-line) ``` When executed, this will bind your macro to the `C-c C-c` key sequence. I recommend not binding it to `C-c` directly, because `C-c` is normally a prefix key that lets you access a whole keyboard's worth of keyboard shortcuts. It's specifically reserved for users to add their own custom keybindings to, so you should feel free to arrange it however you like. As with all prefix keys, you can see a list of the assigned keyboard shortcuts by typing `C-c C-h`. You should also edit the docstring so that it explains what the macro will do when called, so that the documentation for this key will be as useful as possible. (`C-h k C-c C-c` will pull up that documentation.) --- Tags: key-bindings ---
thread-59961
https://emacs.stackexchange.com/questions/59961
org-mode table: how to add the left-most vertical line with column groups notation?
2020-08-04T14:59:28.573
# Question Title: org-mode table: how to add the left-most vertical line with column groups notation? The documentation suggests that column groups syntax is a *general* way to add vertical lines in a table. For instance, the following `org-mode`'s table snippet ``` |--------+----------| | | Column 1 | |--------+----------| | / | <> | | Line 1 | | |--------+----------| ``` is rendered in pdf as and in ASCII as ``` --------+----------+ | Column 1 | --------+----------+ Line 1 | | --------+----------+ ``` (Apparently, this doesn't work for HTML as the boundaries are controlled by CSS). My question is: how to use column groups to obtain the left-most vertical line? The idea is to use **one syntax** to export the table with specific vertical lines in different formats. I'm aware of the alternative way to achieve it using `#+ATTR_LaTeX: :align |c|c|`, but it's specific to LaTeX. # Answer This answer suggests adding one extra column to achieve what is required, i.e. ``` |---+--------+----------| | | | Column 1 | |---+--------+----------| | / | < | <> | | | Line 1 | | |---+--------+----------| ``` > 2 votes --- Tags: org-mode, org-table ---
thread-60025
https://emacs.stackexchange.com/questions/60025
Switch to *scratch* buffer (global-set-key)
2020-08-08T20:26:32.547
# Question Title: Switch to *scratch* buffer (global-set-key) I am reading the Intro to Lisp Programing and got to the chapter where `switch-to-buffer` is introduced. I tried to bind `(switch-to-buffer "*scratch*")` via `global-set-key` But this does not work: `(global-set-key (kbd "<S-f11>") '(switch-to-buffer "*scratch*"))` I looked at Bernt Hansens config and he defined an extra function for this. ``` (defun bh/switch-to-scratch () (interactive) (switch-to-buffer "*scratch*")) ``` Why is this necessary? # Answer > 2 votes The following demonstrates the most commonly used method to define a keyboard shortcut using `global-set-key`. The function `bh/switch-to-scratch` is okay "as-is". Keep in mind that we are defining SHIFT+F11 in this example: ``` (defun bh/switch-to-scratch () (interactive) (switch-to-buffer "*scratch*")) (global-set-key (kbd "<S-f11>") 'bh/switch-to-scratch) ``` Alternatively, we could use the following -- keeping in mind that Emacs requires that functions activated via keyboard shortcuts be `interactive`, and `lambda` is required to make this example work: ``` (global-set-key (kbd "<S-f11>") (lambda () (interactive) (switch-to-buffer "*scratch*"))) ``` --- Tags: key-bindings, commands, interactive ---
thread-51885
https://emacs.stackexchange.com/questions/51885
How to filter a dynamic block column view by tags with a :match selector?
2019-07-27T21:59:56.140
# Question Title: How to filter a dynamic block column view by tags with a :match selector? I'm trying to filter an org mode heading by tag in a dynamic block, but the match syntax is not quite working out. Example: ``` #+COLUMNS: %25ITEM %TAGS * Something :work:home: * Other thing :home: #+BEGIN: columnview :id global :match "TAGS=\"work\"" | ITEM | TAGS | |-------------+-------------| | Something | :work:home: | | Other thing | :home: | #+END: columnview ``` The `:match "TAGS=\"work\""` query returns all headings. How to fix the query so only the headings tagged with `work` are displayed in the dynamic block? # Answer > 0 votes Try `:match "work"`. IIRC, match already takes care of the `"TAGS=\"` stuff. # Answer > 0 votes I had the same issue using org-mode 9.0.1. After updating to 9.3.7, it works like a charm. Comparing source code of org-colview.el, it showed that my org-mode version didn't have the match argument. Maybe updating would solve your issue as well? (It seems to me your query syntax is correct.) # Answer > 0 votes As Paul van Geber said, there was an update to Org-mode that seems to have resolved this issue. I just had to make a slight change in the way my match query was being made. If I want just the items tagged `work`, I have to do: ``` #+BEGIN: columnview :id global :match "work" ``` ... and then run `org-update-all-blocks`. If I use `TAGS=`, I have to match all tags, apparently. For instance, to match the first item in my original example, I need to do: ``` #+BEGIN: columnview :id global :match "TAGS=\":work:home:\"" ``` ... and again `org-update-all-dblocks`. --- Tags: org-mode, org-tags, column, filtering ---
thread-46663
https://emacs.stackexchange.com/questions/46663
How to connect to Windows 10 OpenSSH over tramp?
2018-12-18T14:27:27.827
# Question Title: How to connect to Windows 10 OpenSSH over tramp? I've installed OpenSSH on a Windows 10 machine, and can connect to it from the Linux command line with `ssh` or `scp`, giving the `cmd.exe` "shell". But tramp hangs on `Waiting for prompts from remote shell`: ``` Tramp: Opening connection for win using ssh... Tramp: Sending command ‘exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none win’ Tramp: Waiting for prompts from remote shell...failed Tramp: Opening connection for win using ssh...failed ``` also with `(setq tramp-use-ssh-controlmaster-options nil)` ``` Tramp: Opening connection for win using ssh... Tramp: Sending command ‘exec ssh -e none win’ Tramp: Waiting for prompts from remote shell...failed Tramp: Opening connection for win using ssh...failed ``` Is there some special trick? --- I've tried changing the Windows OpenSSH shell to bash, which makes regular ssh-ing and git cloning nicer, but doesn't seem to help tramp. I've also tried both ``` (setq explicit-shell-file-name "cmd" explicit-cmd-args '("/q")) ``` and ``` (setq explicit-shell-file-name "powershell" explicit-powershell-args '("-file" "-")) ``` to no avail. # Answer > 3 votes Use method `sftp`: ``` /sftp:WhoYou@WinHost:/C:/Users/WhoYou/SomeFile.txt ``` WFM as of this morning, using Emacs 26.1 on Linux Mint Debian Edition 2 -- so both quite old. Anything more up-to-date should at least be able to do the same. --- Tags: tramp ---
thread-52547
https://emacs.stackexchange.com/questions/52547
org-habit : time-dependent habit
2019-09-07T13:25:15.337
# Question Title: org-habit : time-dependent habit For instance, I have the following habit "sleep before 23h" ``` ** TODO sleep before 23h SCHEDULED: <2019-09-07 sam. 23:00 +1d> :PROPERTIES: :STYLE: habit :END: ``` And I mark it as DONE on my agenda each time I'm going to sleep. However, whether or not I've done it before 23h, `org-habit` considered it as done in time since it's day-based. Is there a trick to change its behaviour so that "sleeping after 23h" in this case is considered overdue? # Answer For starters, my suggestion would be to use `DEADLINE:` rather than `SCHEDULED:`. See The Org Manual: Deadlines and scheduling for an explanation of the distinction. Namely: > SCHEDULED Meaning: you are planning to start working on that task on the given date. and > DEADLINE Meaning: the task (most likely a TODO item, though not necessarily) is supposed to be finished on that date. You may wish to set a `SCHEDULED:` value as well to reflect the earliest you anticipate going to bed. > 2 votes # Answer I find this question quite interesting as trying to log my sleep schedule has been a conundrum for me as well : when you get to bed isn't the time to log it, and the day after isn't accurate, really. Also, the real info I aim for is the amount of sleep I had and if sleeping time and wake-up time are stable or not. Trying to implement @ebpa answer gave me ``` ** TODO sleep before 23h SCHEDULED: < 22:30 +1d> DEADLINE: < 23:00 +1d> :PROPERTIES: :STYLE: habit :END: ``` Now I'll try to get emacs/org-mode to compute sleep time ... > 0 votes --- Tags: org-mode, org-agenda, org-habit ---
thread-60014
https://emacs.stackexchange.com/questions/60014
Yasnippet conditional template depending on field value
2020-08-08T16:12:55.787
# Question Title: Yasnippet conditional template depending on field value I'm having an issue where I would like to be able to create a template which will conditionally insert a string into the template based on the value of one of the fields. This means I want some sort of embedded elisp (or elisp function call) to evaluate if one of my fields has the value 0. If it does not then I want to include a function definition in the snippet. If the field is 0 then there is no reason to include this function definition. This is what I have so far but it seems to matter what the string is included and the concatenation fails. ``` $>registerFn(id, &$1FieldEnd, $1FieldOtherEnd, $> ${5:$1Handler}, 0); `(if (string= (yas-field-value 5) "0") ( " ") ( concat (concat "\nstatic void " (concat (yas-field-value 5) "(void *argPtr)")) "\n { /* handlerImplementation */ } ") )` ``` # Answer On a more general note, here's an example that sets `b` to the value of `a` if `a` is not 0. ``` # -*- mode: snippet -*- # name: test # key: test # -- a = ${1:0} b = ${1:$(unless (equal yas-text "0") yas-text)} $0 ``` > 2 votes # Answer I managed to solve this by simply putting the following in my doom.d/config.el ``` (with-eval-after-load 'yasnippet (defun maybe_notify_snip (snip_str) (if (string= snip_str "0") " " (concat (concat "\nstatic void " (concat snip_str "(void *argPtr)")) "\n { /* handler implementation */ } ")))) ``` and then using it inside the template as such: ``` ${5:$(maybe_notify_snip yas-text)} ``` This seems to ensure that the snippet is updated such that if I enter 0 for field 5 then we don't include a function implementation snippet but as soon as I enter something in filed 5 the implementation appears > 1 votes --- Tags: yasnippet, template ---
thread-60044
https://emacs.stackexchange.com/questions/60044
.+$ fails to match remainder of line
2020-08-10T15:15:17.133
# Question Title: .+$ fails to match remainder of line This matches nothing: ``` Query replace regexp (default \.org.+ → ): \.org.+$ → ``` The same without '$' matches incompletely: I'd like to be able to match `\.org` and all that follows. # Answer `\.org.+$` works for me, starting from `emacs -Q`. Try starting Emacs using `emacs -Q` (no init file). Do you see the same thing? If not, bisect your init file to find the culprit. (Maybe pay attention too to what whitespace you're trying to match. Your question is underspecified. All we have to go on is your screenshot - we have no idea what whitespace chars you're trying to match, etc.) > 0 votes --- Tags: regular-expressions, query-replace-regexp ---
thread-60048
https://emacs.stackexchange.com/questions/60048
lsp project root
2020-08-10T16:34:22.973
# Question Title: lsp project root I just switched to using lsp for my C++ and Python IDE needs. However, I am running into a constant issue where Python and C++ files have the wrong root, as reported by `(lsp-workspace-root)`. The root is considered to be the git root (I assume from projectile) which is not the case in my project. When I first opened the file I did not get a prompt asking me for the project root and I made sure to delete the lsp session file (as set in `lsp-session-file`). Any help is much appreciated. # Answer > 9 votes You probably want `(lsp-workspace-folders-add)` to add sub-root directories. For example, if your Python files are located in the `tests/` subdirectory, you add it as such with the command. Then, upon starting an LSP server in any of `tests` or `tests/foo` or `tests/bar`, the current working directory will be set to `tests`. There's also more information at this reddit post, quoting: > > lsp rely on projectile or project.el now only for suggesting project root. Once you open new file in a project and start lsp it will provide several options(import project, blacklist project, select other directory root). Once you select a root it will be persisted and used for the next sessions. > > Then there is a command: > > > `lsp-workspace-folders-add` \- Add workspace folder > > Finally under configuration: > > > `lsp-session-file` \- Automatically guess the project root using projectile/project. --- Tags: lsp-mode, lsp ---
thread-60056
https://emacs.stackexchange.com/questions/60056
How does one access the actual arguments to an Emacs Lisp function from the `*Backtrace*`?
2020-08-11T03:08:01.077
# Question Title: How does one access the actual arguments to an Emacs Lisp function from the `*Backtrace*`? I am trying to debug a problem in some elisp and don't understand how to access the information I want from the Emacs Debugger. Specifically, my backtrace looks like: ``` ⋮ #f(compiled-function (hover) #<bytecode 0x26f7872a3e8bae1>)(#<hash-table equal 1/1 0x1fe85528cbdf>) apply(#f(compiled-function (hover) #<bytecode 0x26f7872a3e8bae1>) #<hash-table equal 1/1 0x1fe85528cbdf>) #f(compiled-function (&rest args) #<bytecode 0xe8a92e4d3997328>)(#<hash-table equal 1/1 0x1fe85528cbdf>) #f(compiled-function (result) #<bytecode -0xd842d2c46378a2f>)(#<hash-table equal 1/1 0x1fe859656ddf>) #f(compiled-function (result) #<bytecode -0x6d44600f4b68ed1>)(#<hash-table equal 1/1 0x1fe859656ddf>) funcall(#f(compiled-function (result) #<bytecode -0x6d44600f4b68ed1>) #<hash-table equal 1/1 0x1fe859656ddf>) ⋮ ``` and I want to examine those `#<hash-table…>` values. How do I access those? That is, if I wanted to call `(hash-table-keys #<hash-table…>)`, how would I do that from the `*Backtrace*` buffer? (At least some of the functions are generated by complicated macros, so I can't just use `Edebug`—at least not easily.) # Answer Load the source file (`*.el`, not `*.elc`) that defines the function you're interested in. E.g., `M-x load-file` or `M-x load-library` (but be sure to specify `.el`). Then use `M-x debug-on-entry`, to enter the debugger when that function is called. Step through the debugger with `d` (or `c` to skip through a step you're not interested in). Use `e` to evaluate any sexp (e.g. the value of an argument) at any time. If the function you want has no name then you can, alternatively, insert `(debug)` anywhere in its source code, to create a break point, which will open the debugger at that point. You can also insert `(debug nil SEXP1 SEXP2...)`, where each `SEXPN` is something you want evaluated and printed when the debugger opens. > 3 votes --- Tags: debugging, backtrace ---
thread-60051
https://emacs.stackexchange.com/questions/60051
Is there command to cause emacs to rescan the buffer to determine mode?
2020-08-10T20:36:02.000
# Question Title: Is there command to cause emacs to rescan the buffer to determine mode? Apologies if this has been asked before (I couldn't find an answer to this.) Frequently, when I open an existing file or create a new file with emacs, the mode is determined correctly based on the file extension (text following the last "." in the file name). However, this doesn't work when I create a script that has a "shebang" ("#!") on the first line. For example, ``` #!/usr/bin/env python ``` Emacs doesn't put the buffer into python mode unless I save the file (save-file) and open it again (find-file). Is there a way to rescan the buffer to determine the mode without saving the file? Another scenario where this would come in handy is when the buffer has: ``` ; -*- <MODE> -*- ``` on the first line. # Answer I believe the command you want is `normal-mode`. > 4 votes # Answer `normal-mode` (cited by @Omar in the alternative answer) calls, in part, `set-auto-mode`. The *non*-interactive function `set-auto-mode`, which can be evaluated by typing `M-:` and then `(set-auto-mode)`, or by typing `M-x eval-expression RET (set-auto-mode) RET`, places the buffer in the proper `major-mode` based upon the shebang line provided that said line matches the expected format ... (*infra*). `normal-mode`; however, is *interactive* and contains some additional goodies such as killing all local variables, running certain hooks, etc. The variable `auto-mode-interpreter-regexp`, defined in `files.el` has a default value of: ``` "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)" ``` We note that there is *no space* between the `#` and the `!` symbol, whereas the O.P. is using a space between the aforementioned symbols; i.e., `# !/usr/bin/env python`. Emacs is unable to match the shebang line of the O.P. against the default regexp because of the aforementioned unexpected space between the `#` and `!` symbols at the outset of said shebang line. The doc-string for the above-mentioned variable provides as follows: ``` Regexp matching interpreters, for file mode determination. This regular expression is matched against the first line of a file to determine the file’s mode in ‘set-auto-mode’. If it matches, the file is assumed to be interpreted by the interpreter matched by the second group of the regular expression. The mode is then determined as the mode associated with that interpreter in `interpreter-mode-alist`. ``` > 3 votes # Answer `M-x revert-buffer` works too as it calls `normal-mode` internally, though `normal-mode` does exactly what you want. > 0 votes --- Tags: major-mode ---
thread-60053
https://emacs.stackexchange.com/questions/60053
Why does `term-emulate-terminal` get executed every time `read-from-minibuffer` gets executed?
2020-08-10T21:01:40.670
# Question Title: Why does `term-emulate-terminal` get executed every time `read-from-minibuffer` gets executed? Why does `term-emulate-terminal` get executed every time I execute `counsel-switch-buffer` if and only if the `*terminal*` buffer is open in a window. If the `*terminal*` buffer is not in a window `term-emulate-terminal` does not get called. I can't seem to pinpoint why `ivy`/`counsel` is causing this behavior, as it is screwing up my buffer workflow. Is it because of `ivy-read`? --- This is the update I get from `debug-on-entry` for `term-emulate-terminal`. And I'm not quite sure how to decipher all of this since I usually use `edebug` for my debugging: ``` Debugger entered--entering a function: (if (or inhibit-debug-on-entry debugger-jumping-flag) nil (let ((inhibit-debug-on-entry t)) (funcall debugger (quote debug)))) debug--implement-debug-on-entry(#<process terminal> "\015\033[K\033[01;32mi@debord\033[00m:\033[01;34m~\033[00m$ ") apply(debug--implement-debug-on-entry (#<process terminal> "\015\033[K\033[01;32mi@debord\033[00m:\033[01;34m~\033[00m$ ")) term-emulate-terminal(#<process terminal> "\015\033[K\033[01;32mi@debord\033[00m:\033[01;34m~\033[00m$ ") read-from-minibuffer("Switch to buffer: " nil (keymap (keymap (11 . ivy-switch-buffer-kill)) keymap (up . ivy-previous-line) (down . ivy-next-line) (jd:M-ret . jd:preview-function) (jd:M-bks . ivy-switch-buffer-kill) (jd:C-bks . jd:delete-word-backward) (jd:tab . ivy-partial) (jd:ret . ivy-alt-done) (C-M-k . ivy-next-history-element) (C-M-i . ivy-previous-history-element) (M-u . beginning-of-line) (M-o . end-of-line) (M-l . ivy-alt-done) (M-k . ivy-next-line) (M-j . counsel-up-directory) (M-i . ivy-previous-line) (M-\; . swiper-recenter-top-bottom) (C-u . ivy-beginning-of-buffer) (C-o . ivy-end-of-buffer) (C-k . jd:ivy-scroll-up-command) (C-i . jd:ivy-scroll-down-command) (C-g . minibuffer-keyboard-quit) (36 . ivy-magic-read-file-env) (3 keymap (19 . ivy-rotate-sort) (1 . ivy-toggle-ignore) (15 . ivy-occur)) (33554464 . ivy-restrict-to-matches) (15 . hydra-ivy/body) (22 . ivy-scroll-up-command) (prior . ivy-scroll-down-command) (next . ivy-scroll-up-command) (7 . minibuffer-keyboard-quit) (right . ivy-forward-char) (32 . self-insert-command) (18 . ivy-reverse-i-search) (remap keymap (describe-mode . ivy-help) (kill-ring-save . ivy-kill-ring-save) (kill-whole-line . ivy-kill-whole-line) (kill-line . ivy-kill-line) (scroll-down-command . ivy-scroll-down-command) (scroll-up-command . ivy-scroll-up-command) (end-of-buffer . ivy-end-of-buffer) (beginning-of-buffer . ivy-beginning-of-buffer) (kill-word . ivy-kill-word) (forward-char . ivy-forward-char) (delete-char . ivy-delete-char) (backward-kill-word . ivy-backward-kill-word) (backward-delete-char-untabify . ivy-backward-delete-char) (delete-backward-char . ivy-backward-delete-char) (previous-line . ivy-previous-line) (next-line . ivy-next-line)) (9 . ivy-partial-or-done) (10 . ivy-alt-done) (nil keymap (1 . ivy-read-action) (15 . ivy-dispatching-call) (111 . ivy-dispatching-done) (25 . ivy-insert-current-full) (105 . ivy-insert-current) (106 . ivy-yank-word) (114 . ivy-toggle-regexp-quote) (97 . ivy-toggle-marks) (16 . ivy-previous-line-and-call) (14 . ivy-next-line-and-call) (118 . ivy-scroll-down-command) (112 . ivy-previous-history-element) (110 . ivy-next-history-element) (10 . ivy-immediate-done) (13 . ivy-call)) (mouse-3 . ivy-mouse-dispatching-done) (mouse-1 . ivy-mouse-done) (down-mouse-1 . ignore) (13 . ivy-done)) nil ivy-history) (condition-case err (read-from-minibuffer prompt (progn (or (and (memq (type-of ivy-last) cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list (quote ivy-state) ivy-last))) (aref ivy-last 5)) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if (equal err (quote (error "Selecting deleted buffer"))) nil (signal (car err) (cdr err))))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null (cdr ivy--all-candidates))) (progn (progn (or (and (memq (type-of ivy-last) cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list (quote ivy-state) ivy-last))) (let* ((v ivy-last)) (aset v 23 (car ivy--all-candidates)))) (setq ivy-exit (quote done))) (condition-case err (read-from-minibuffer prompt (progn (or (and (memq (type-of ivy-last) cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list (quote ivy-state) ivy-last))) (aref ivy-last 5)) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if (equal err (quote (error "Selecting deleted buffer"))) nil (signal (car err) (cdr err)))))) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height (ivy--height caller)) (resize-mini-windows (if (display-graphic-p) nil (quote grow-only)))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null (cdr ivy--all-candidates))) (progn (progn (or (and (memq (type-of ivy-last) cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list (quote ivy-state) ivy-last))) (let* ((v ivy-last)) (aset v 23 (car ivy--all-candidates)))) (setq ivy-exit (quote done))) (condition-case err (read-from-minibuffer prompt (progn (or (and (memq ... cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list ... ivy-last))) (aref ivy-last 5)) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if (equal err (quote (error "Selecting deleted buffer"))) nil (signal (car err) (cdr err)))))) (if (eq ivy-exit (quote done)) (progn (ivy--update-history hist)))) (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height (ivy--height caller)) (resize-mini-windows (if (display-graphic-p) nil (quote grow-only)))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null (cdr ivy--all-candidates))) (progn (progn (or (and (memq ... cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list ... ivy-last))) (let* ((v ivy-last)) (aset v 23 (car ivy--all-candidates)))) (setq ivy-exit (quote done))) (condition-case err (read-from-minibuffer prompt (progn (or (and ... t) (signal ... ...)) (aref ivy-last 5)) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if (equal err (quote ...)) nil (signal (car err) (cdr err)))))) (if (eq ivy-exit (quote done)) (progn (ivy--update-history hist))))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height (ivy--height caller)) (resize-mini-windows (if (display-graphic-p) nil (quote grow-only)))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null (cdr ivy--all-candidates))) (progn (progn (or (and ... t) (signal ... ...)) (let* (...) (aset v 23 ...))) (setq ivy-exit (quote done))) (condition-case err (read-from-minibuffer prompt (progn (or ... ...) (aref ivy-last 5)) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if (equal err ...) nil (signal ... ...))))) (if (eq ivy-exit (quote done)) (progn (ivy--update-history hist))))) (remove-hook (quote minibuffer-setup-hook) setup-hook)) (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history (quote ivy-history))) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height (ivy--height caller)) (resize-mini-windows (if (display-graphic-p) nil (quote grow-only)))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null (cdr ivy--all-candidates))) (progn (progn (or ... ...) (let* ... ...)) (setq ivy-exit (quote done))) (condition-case err (read-from-minibuffer prompt (progn ... ...) (make-composed-keymap keymap ivy-minibuffer-map) nil hist) (error (if ... nil ...)))) (if (eq ivy-exit (quote done)) (progn (ivy--update-history hist))))) (remove-hook (quote minibuffer-setup-hook) setup-hook))) (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist (or history ...)) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height (ivy--height caller)) (resize-mini-windows (if ... nil ...))) (if (and ivy-auto-select-single-candidate ivy--all-candidates (null ...)) (progn (progn ... ...) (setq ivy-exit ...)) (condition-case err (read-from-minibuffer prompt ... ... nil hist) (error ...))) (if (eq ivy-exit (quote done)) (progn (ivy--update-history hist))))) (remove-hook (quote minibuffer-setup-hook) setup-hook))) (let ((session (or (plist-get extra-props :session) (if (or (minibufferp) (null ...) (eq ... ...)) nil caller)))) (if session (progn (progn (or (and (memq ... cl-struct-ivy-state-tags) t) (signal (quote wrong-type-argument) (list ... ivy-last))) (let* ((v ivy-last)) (aset v 27 (plist-put extra-props :ivy-data ...)))) (ivy--alist-set (quote ivy--sessions) session ivy-last)))) (ivy--cleanup)) (let* ((ivy-recursive-last (and (active-minibuffer-window) ivy-last)) (ivy--display-function (if (or ivy-recursive-last (not (window-minibuffer-p))) (progn (ivy-alist-setting ivy-display-functions-alist caller))))) (setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist caller))) (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller))) (setq ivy-last (make-ivy-state :prompt (ivy--update-prompt prompt) :collection collection :predicate predicate :require-match require-match :initial-input initial-input :history history :preselect preselect :keymap keymap :update-fn (if (eq update-fn (quote auto)) (function (lambda nil (let (...) (save-current-buffer ...)))) update-fn) :sort sort :action (ivy--compute-extra-actions action caller) :multi-action multi-action :frame (selected-frame) :window (selected-window) :buffer (current-buffer) :unwind unwind :re-builder re-builder :matcher matcher :dynamic-collection dynamic-collection :display-transformer-fn (ivy-alist-setting ivy--display-transformers-alist caller) :directory default-directory :extra-props extra-props :caller caller :def def)) (ivy--reset-state ivy-last) (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook (quote minibuffer-setup-hook) setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* ((hist ...) (minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) (ivy-height ...) (resize-mini-windows ...)) (if (and ivy-auto-select-single-candidate ivy--all-candidates ...) (progn ... ...) (condition-case err ... ...)) (if (eq ivy-exit ...) (progn ...)))) (remove-hook (quote minibuffer-setup-hook) setup-hook))) (let ((session (or (plist-get extra-props :session) (if (or ... ... ...) nil caller)))) (if session (progn (progn (or (and ... t) (signal ... ...)) (let* (...) (aset v 27 ...))) (ivy--alist-set (quote ivy--sessions) session ivy-last)))) (ivy--cleanup)) (ivy-call)) (progn (let ((init-fn (ivy-alist-setting ivy-init-fns-alist caller))) (if init-fn (progn (funcall init-fn)))) (if (equal overriding-local-map (quote (keymap))) (progn (keyboard-quit))) (setq caller (or caller this-command)) (let* ((ivy-recursive-last (and (active-minibuffer-window) ivy-last)) (ivy--display-function (if (or ivy-recursive-last (not (window-minibuffer-p))) (progn (ivy-alist-setting ivy-display-functions-alist caller))))) (setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist caller))) (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller))) (setq ivy-last (make-ivy-state :prompt (ivy--update-prompt prompt) :collection collection :predicate predicate :require-match require-match :initial-input initial-input :history history :preselect preselect :keymap keymap :update-fn (if (eq update-fn (quote auto)) (function (lambda nil (let ... ...))) update-fn) :sort sort :action (ivy--compute-extra-actions action caller) :multi-action multi-action :frame (selected-frame) :window (selected-window) :buffer (current-buffer) :unwind unwind :re-builder re-builder :matcher matcher :dynamic-collection dynamic-collection :display-transformer-fn (ivy-alist-setting ivy--display-transformers-alist caller) :directory default-directory :extra-props extra-props :caller caller :def def)) (ivy--reset-state ivy-last) (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil (remove-hook ... setup-hook) (funcall fun)))) (unwind-protect (progn (add-hook (quote minibuffer-setup-hook) setup-hook) (let* (... ... ... ... ...) (if ... ... ...) (if ... ...))) (remove-hook (quote minibuffer-setup-hook) setup-hook))) (let ((session (or (plist-get extra-props :session) (if ... nil caller)))) (if session (progn (progn (or ... ...) (let* ... ...)) (ivy--alist-set (quote ivy--sessions) session ivy-last)))) (ivy--cleanup)) (ivy-call))) (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) (quote (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :multi-action :unwind :re-builder :matcher :dynamic-collection :extra-props :caller :allow-other-keys))) (setq --cl-keys-- (cdr (cdr --cl-keys--)))) ((car (cdr (memq ... --cl-rest--))) (setq --cl-keys-- nil)) (t (error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :multi-action :unwind :re-builder :matcher :dynamic-collection :extra-props :caller)" (car --cl-keys--)))))) (progn (let ((init-fn (ivy-alist-setting ivy-init-fns-alist caller))) (if init-fn (progn (funcall init-fn)))) (if (equal overriding-local-map (quote (keymap))) (progn (keyboard-quit))) (setq caller (or caller this-command)) (let* ((ivy-recursive-last (and (active-minibuffer-window) ivy-last)) (ivy--display-function (if (or ivy-recursive-last (not ...)) (progn (ivy-alist-setting ivy-display-functions-alist caller))))) (setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist caller))) (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller))) (setq ivy-last (make-ivy-state :prompt (ivy--update-prompt prompt) :collection collection :predicate predicate :require-match require-match :initial-input initial-input :history history :preselect preselect :keymap keymap :update-fn (if (eq update-fn (quote auto)) (function (lambda nil ...)) update-fn) :sort sort :action (ivy--compute-extra-actions action caller) :multi-action multi-action :frame (selected-frame) :window (selected-window) :buffer (current-buffer) :unwind unwind :re-builder re-builder :matcher matcher :dynamic-collection dynamic-collection :display-transformer-fn (ivy-alist-setting ivy--display-transformers-alist caller) :directory default-directory :extra-props extra-props :caller caller :def def)) (ivy--reset-state ivy-last) (unwind-protect (let ((fun (function ivy--minibuffer-setup)) setup-hook) (setq setup-hook (function (lambda nil ... ...))) (unwind-protect (progn (add-hook ... setup-hook) (let* ... ... ...)) (remove-hook (quote minibuffer-setup-hook) setup-hook))) (let ((session (or ... ...))) (if session (progn (progn ... ...) (ivy--alist-set ... session ivy-last)))) (ivy--cleanup)) (ivy-call)))) (let* ((predicate (car (cdr (plist-member --cl-rest-- (quote :predicate))))) (require-match (car (cdr (plist-member --cl-rest-- (quote :require-match))))) (initial-input (car (cdr (plist-member --cl-rest-- (quote :initial-input))))) (history (car (cdr (plist-member --cl-rest-- (quote :history))))) (preselect (car (cdr (plist-member --cl-rest-- (quote :preselect))))) (def (car (cdr (plist-member --cl-rest-- (quote :def))))) (keymap (car (cdr (plist-member --cl-rest-- (quote :keymap))))) (update-fn (car (cdr (plist-member --cl-rest-- (quote :update-fn))))) (sort (car (cdr (plist-member --cl-rest-- (quote :sort))))) (action (car (cdr (plist-member --cl-rest-- (quote :action))))) (multi-action (car (cdr (plist-member --cl-rest-- (quote :multi-action))))) (unwind (car (cdr (plist-member --cl-rest-- (quote :unwind))))) (re-builder (car (cdr (plist-member --cl-rest-- (quote :re-builder))))) (matcher (car (cdr (plist-member --cl-rest-- (quote :matcher))))) (dynamic-collection (car (cdr (plist-member --cl-rest-- (quote :dynamic-collection))))) (extra-props (car (cdr (plist-member --cl-rest-- (quote :extra-props))))) (caller (car (cdr (plist-member --cl-rest-- (quote :caller)))))) (progn (let ((--cl-keys-- --cl-rest--)) (while --cl-keys-- (cond ((memq (car --cl-keys--) (quote ...)) (setq --cl-keys-- (cdr ...))) ((car (cdr ...)) (setq --cl-keys-- nil)) (t (error "Keyword argument %s not one of (:predicate :require-match :initial-input :history :preselect :def :keymap :update-fn :sort :action :multi-action :unwind :re-builder :matcher :dynamic-collection :extra-props :caller)" (car --cl-keys--)))))) (progn (let ((init-fn (ivy-alist-setting ivy-init-fns-alist caller))) (if init-fn (progn (funcall init-fn)))) (if (equal overriding-local-map (quote (keymap))) (progn (keyboard-quit))) (setq caller (or caller this-command)) (let* ((ivy-recursive-last (and (active-minibuffer-window) ivy-last)) (ivy--display-function (if (or ivy-recursive-last ...) (progn ...)))) (setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist caller))) (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller))) (setq ivy-last (make-ivy-state :prompt (ivy--update-prompt prompt) :collection collection :predicate predicate :require-match require-match :initial-input initial-input :history history :preselect preselect :keymap keymap :update-fn (if (eq update-fn ...) (function ...) update-fn) :sort sort :action (ivy--compute-extra-actions action caller) :multi-action multi-action :frame (selected-frame) :window (selected-window) :buffer (current-buffer) :unwind unwind :re-builder re-builder :matcher matcher :dynamic-collection dynamic-collection :display-transformer-fn (ivy-alist-setting ivy--display-transformers-alist caller) :directory default-directory :extra-props extra-props :caller caller :def def)) (ivy--reset-state ivy-last) (unwind-protect (let ((fun ...) setup-hook) (setq setup-hook (function ...)) (unwind-protect (progn ... ...) (remove-hook ... setup-hook))) (let ((session ...)) (if session (progn ... ...))) (ivy--cleanup)) (ivy-call))))) ivy-read("Switch to buffer: " internal-complete-buffer :keymap (keymap (11 . ivy-switch-buffer-kill)) :preselect "ivy.el" :action ivy--switch-buffer-action :matcher ivy--switch-buffer-matcher :caller ivy-switch-buffer) ivy-switch-buffer() (let ((ivy-update-fns-alist (quote ((ivy-switch-buffer . counsel--switch-buffer-update-fn)))) (ivy-unwind-fns-alist (quote ((ivy-switch-buffer . counsel--switch-buffer-unwind))))) (ivy-switch-buffer)) counsel-switch-buffer() funcall-interactively(counsel-switch-buffer) call-interactively(counsel-switch-buffer nil nil) (prog1 (call-interactively cmd record-flag keys) (if (and (symbolp cmd) (get cmd (quote byte-obsolete-info)) (not (get cmd (quote command-execute-obsolete-warned)))) (progn (put cmd (quote command-execute-obsolete-warned) t) (message "%s" (macroexp--obsolete-warning cmd (get cmd (quote byte-obsolete-info)) "command"))))) (cond ((arrayp final) (if record-flag (progn (setq command-history (cons (list (quote execute-kbd-macro) final prefixarg) command-history)) (if (and (numberp history-length) (> history-length 0)) (progn (let (...) (if ... ...)))))) (execute-kbd-macro final prefixarg)) (t (prog1 (call-interactively cmd record-flag keys) (if (and (symbolp cmd) (get cmd (quote byte-obsolete-info)) (not (get cmd (quote command-execute-obsolete-warned)))) (progn (put cmd (quote command-execute-obsolete-warned) t) (message "%s" (macroexp--obsolete-warning cmd (get cmd ...) "command"))))))) (let ((final cmd)) (while (progn (setq final (indirect-function final)) (if (autoloadp final) (setq final (autoload-do-load final cmd))))) (cond ((arrayp final) (if record-flag (progn (setq command-history (cons (list ... final prefixarg) command-history)) (if (and (numberp history-length) (> history-length 0)) (progn (let ... ...))))) (execute-kbd-macro final prefixarg)) (t (prog1 (call-interactively cmd record-flag keys) (if (and (symbolp cmd) (get cmd (quote byte-obsolete-info)) (not (get cmd ...))) (progn (put cmd (quote command-execute-obsolete-warned) t) (message "%s" (macroexp--obsolete-warning cmd ... "command")))))))) (if (and (symbolp cmd) (get cmd (quote disabled)) disabled-command-function) (run-hooks (quote disabled-command-function)) (let ((final cmd)) (while (progn (setq final (indirect-function final)) (if (autoloadp final) (setq final (autoload-do-load final cmd))))) (cond ((arrayp final) (if record-flag (progn (setq command-history (cons ... command-history)) (if (and ... ...) (progn ...)))) (execute-kbd-macro final prefixarg)) (t (prog1 (call-interactively cmd record-flag keys) (if (and (symbolp cmd) (get cmd ...) (not ...)) (progn (put cmd ... t) (message "%s" ...)))))))) (let ((prefixarg (if special nil (prog1 prefix-arg (setq current-prefix-arg prefix-arg) (setq prefix-arg nil) (if current-prefix-arg (progn (prefix-command-update))))))) (if (and (symbolp cmd) (get cmd (quote disabled)) disabled-command-function) (run-hooks (quote disabled-command-function)) (let ((final cmd)) (while (progn (setq final (indirect-function final)) (if (autoloadp final) (setq final (autoload-do-load final cmd))))) (cond ((arrayp final) (if record-flag (progn (setq command-history ...) (if ... ...))) (execute-kbd-macro final prefixarg)) (t (prog1 (call-interactively cmd record-flag keys) (if (and ... ... ...) (progn ... ...)))))))) command-execute(counsel-switch-buffer) ``` --- Even eliminating the extra arguments passed to `read-from-minibuffer` doesn't prevent `read-from-minibuffer` to somehow trigger `term-emulate-terminal`. ``` ... term-emulate-terminal(#<process terminal> "\015\033[K\033[01;32mi@debord\033[00m:\033[01;34m~\033[00m$ ") read-from-minibuffer("Switch to buffer: ") ... ``` # Answer > 1 votes I suspect the *reason* for this is: * Calling `counsel-switch-buffer` is triggering a window configuration change. * `window-configuration-change-hook` contains `window--adjust-process-windows` to "Update process window sizes to match the current window configuration", which calls `set-process-window-size` for each process in each affected window, which talks to the process in question. * If the process talks back, that's going to invoke the process filter (which is what `term-emulate-terminal` is, for `term` buffers). * Per `(elisp)Accepting Output`, output from processes is normally handled "only while Emacs is waiting for some sort of external event, such as elapsed time or terminal input". In the scenario in question, the first such opportunity is when `read-from-minibuffer` is called and awaiting user input. --- Tags: ivy, term, counsel ---
thread-60038
https://emacs.stackexchange.com/questions/60038
How to completely remove truncation symbol (default '$') from truncated lines when no fringes?
2020-08-10T10:19:48.307
# Question Title: How to completely remove truncation symbol (default '$') from truncated lines when no fringes? In a GUI Emacs **without fringes**, I would like to get rid of the '$' at the end of truncated lines such that lines can use the fill width of the window. I've tried: 1. `(set-display-table-slot standard-display-table 'truncation 0)` : this replaced `$` with a space (or an empty slot). 2. `(set-display-table-slot standard-display-table 'truncation nil)` : this fall back to `$` My question is thus how to display truncated lines without any truncation symbol on the right? Here is a small mockup: ``` a) |Truncated lin$| -> Normal behavior b) |Truncated lin…| -> Truncation symbol set to ?\… c) |Truncated lin | -> Truncation symbol set to 0 d) |Truncated line| -> What I would like to obtain ``` # Answer > 2 votes I found a solution by "abusing" the display table. In the below solution, msg is a string whose length is window width +1 (such as to display the truncation character). I then set the truncation character to the last character of the string. ``` (set-display-table-slot (window-display-table (minibuffer-window)) 'truncation (make-glyph-code (string-to-char (substring msg -1)))) (message msg) ``` --- Tags: line-truncation, buffer-display-table ---
thread-60036
https://emacs.stackexchange.com/questions/60036
tooltip-functions not working?
2020-08-10T08:31:27.953
# Question Title: tooltip-functions not working? Years ago, when Emacs was at 21.\*, I had a function that displayed a tooltip when I hovered the mouse on certain words in the buffer. Now, in 26.3, I want to use that function again, but it does not work any more, apparently because Emacs is not passing mouse movement events to it. Minimal example that worked fine in Emacs 21 but does nothing in Emacs 26: ``` (defun my-tooltip (event) (interactive "e") (tooltip-show "got mouse movement event") t) (progn (tooltip-mode) (set (make-local-variable 'track-mouse) t) (setq tooltip-functions nil) (add-hook 'tooltip-functions 'my-tooltip)) ``` One more thing: when I did `M-x describe-key` and moved the mouse, older Emacs versions used to tell me which command, if any, was bound to `mouse-movement`. In the same situation, Emacs 26 does nothing — it obviously does not see that I am moving the mouse, even when I set `track-mouse` to `t` globally. Running Emacs with `-Q` does not change anything. How should I catch mouse movement events in Emacs 26? # Answer Not exactly an answer, but a dirty workaround: give up using `tooltip-functions` and bind the function directly to `mouse-movement`, like this: ``` (defun my-tooltip (event) (interactive "e") (tooltip-show "got mouse movement event") t) (tooltip-mode) (set (make-local-variable 'track-mouse) t) (local-set-key (kbd "<mouse-movement>") 'my-tooltip) ``` > 1 votes --- Tags: mouse, events ---
thread-59554
https://emacs.stackexchange.com/questions/59554
How do I disable Centaur Tabs in ispell Choices buffer
2020-07-09T17:31:21.107
# Question Title: How do I disable Centaur Tabs in ispell Choices buffer I need to disable the Centaur-Tabs in the Choices buffer of ispell/flyspell. In Centaur Tab's site it says to add a hook, so I tried this: ``` (add-hook 'ispell-choices-buffer 'centaur-tabs-local-mode) ``` But I still get the tabs, and I can't see the words: I'm using Emacs 27.0.91 in Windows 10. # Answer Emacs 26.3 contains an `ispell-update-post-hook` within `ispell-command-loop`; however, that hook runs in the *working* buffer just *after* the `ispell-choices-buffer` is created. I have never installed and/or used `centaur-tabs`, but it is my understanding (based upon a brief review of that library) that most of the code was copied straight from the original `tabbar.el` written by David Ponce. As such, `centaur-tabs` almost certainly relies upon the `header-line-format` variable to generate the view of tabs. Although the following code is untested, perhaps it will suffice to answer the question: ``` (add-hook 'ispell-update-post-hook (lambda () (with-current-buffer ispell-choices-buffer (setq header-line-format nil)))) ``` > 1 votes # Answer This is a slight improvement to lawlist's answer (which quite did not work for me). One could instead just call `centaur-tabs-local-mode` on the `ispell-choices-buffer` in the `ispell-update-post-hook`: ``` (add-hook 'ispell-update-post-hook (lambda () (with-current-buffer ispell-choices-buffer (centaur-tabs-local-mode)))) ``` > 1 votes --- Tags: ispell, tabs ---
thread-60066
https://emacs.stackexchange.com/questions/60066
dired: copy a symlink'd file
2020-08-11T22:15:53.973
# Question Title: dired: copy a symlink'd file `dired-do-copy` copies a symlink as a symlink. Sometimes I want to copy the actual file of a symlink, not make a copy of the symlink. Is there already a way to do that? I can write some elisp code but seems this must be already builtin to dired. # Answer > 1 votes Not that I can see. You could use: `!` `cp -L ? <newname>` `RET` If you want to roll your own, `C-h``f` `file-truename` is the elisp function that chases symlinks to return the fully-dereferenced file name. --- Tags: dired ---
thread-60064
https://emacs.stackexchange.com/questions/60064
Making Emacs see ♥ as punctuation
2020-08-11T18:39:19.337
# Question Title: Making Emacs see ♥ as punctuation I'm trying to get emacs to understand ♥ as punctuation. `(modify-syntax-entry ?♥ "." text-mode-syntax-table)` I'm not sure what the issue is. (That is a unicode heart.) `(modify-syntax-entry ?\u2665 "." text-mode-syntax-table)` For purposes of recognizing that a new sentence starts after "Hi!♥" How can I troubleshoot this? ## Examples: ``` Lorem impsum dolor.♥ Sit amet.| ``` (where the pipe indicates the starting cursor position.) Hitting M-a moves the cursor to the left of "Lorem". ``` Lorem impsum dolor♥. Sit amet.| ``` Hitting M-a moves the cursor to the left of "Sit". I want both cases for it to move to the left of "Sit". In some modes. # Answer > 2 votes Sentence movement functions use the regexp returned by the `(sentence-end)` function to find the end of a sentence. The `(sentence-end)` function returns the value of the `sentence-end` variable if it is not nil. (The function and variable share the same name). You can modify the value of the `sentence-end` variable to any regexp you want. In order to maintain all other functionallity provided by the defaults for sentence movement, I recommend you set the value of `sentence-end` to be a regexp matching either ♥ or the default return value of the `(sentence-end)` function. Below is a function that sets the local value of the `sentence-end` variable as described. ``` (defun my-setup-sentence-end () "Modify the local value of the `sentence-end' variable to be a regexp matching either ♥ or the default regexp returned by the `sentence-end' function." (setq-local sentence-end (rx (or "♥" (eval (let ((sentence-end nil)) (sentence-end))))))) ``` Once you have this function you can add it as a hook to any mode you would like. ``` ;; For example, you can add this behavior to `text-mode' like so (add-hook 'text-mode-hook 'my-setup-sentence-end) ``` Now you can use `(forward-sentence)`, `(backward-sentence)` and other text movemnt functions to navigate to ♥ characters. This regexp may not fit your exact use case, but should provide the basic understanding for you to create your own. Take a look at the paragraph.el source file for more information about the modification of `sentence-end`. --- Tags: syntax-table ---
thread-60062
https://emacs.stackexchange.com/questions/60062
Ubuntu 27.1 install needs X libraries
2020-08-11T16:08:30.067
# Question Title: Ubuntu 27.1 install needs X libraries Getting this on running `./configure` on Ubuntu 20.04 for the new 27.1 install ``` ... checking for X... no checking for X... true configure: error: You seem to be running X, but no X development libraries were found. You should install the relevant development files for X and for the toolkit you want, such as Gtk+ or Motif. Also make sure you have development files for image handling, i.e. tiff, gif, jpeg, png and xpm. If you are sure you want Emacs compiled without X window support, pass --without-x to configure. ``` I've been running 26.3 just fine with X. I should have all the necessary libs from that install. What should I do here? # Answer > 2 votes As @rpluim comments: > `apt build-dep emacs` should get you quite a way there. It will probably be missing some things which are both desirable and new for 27.1 however, such as `libjansson-dev`. I'm not sure about Ubuntu 20.04 but on my 18.04 machine my manual prerequisite list of packages for building Emacs is: > autoconf automake g++ gcc gnu-standards libdbus-1-dev libfreetype6-dev libgif-dev libgnutls-dev libgnutls28-dev libjpeg-dev libmagickcore-dev libmagickwand-dev libncurses-dev libpng-dev librsvg2-dev libtiff-dev libxaw7-dev libxft-dev libxml2-dev libxpm-dev libz-dev libjansson-dev make ncurses-term texinfo ttf-ancient-fonts (I expect that I can remove the `libmagick*` packages at this point, as from 27.1 Emacs no longer defaults to using Image Magick.) I'll note that I build Emacs `--with-x-toolkit=lucid` rather than using the default GTK; but I expect that `apt build-dep emacs` would provide all the necessary GTK packages. YMMV, and I recommend that you pay attention to the final summary output from `configure`, and review anything you're unsure of. --- Tags: install, libraries, emacs27 ---
thread-60071
https://emacs.stackexchange.com/questions/60071
Emacsclient not loading init file changes
2020-08-12T02:17:59.563
# Question Title: Emacsclient not loading init file changes Context: I just updated Emacs via homebrew; I don't remember the steps I followed to get Emacs to run via daemon originally, but since the update it doesn't seem to be using it anymore (i.e. quitting and rerunning Emacs takes several seconds, loading a lot of stuff). I added the Emacs plugin to zsh, which basically runs Emacs using `emacsclient`, and this works -- but now it doesn't seem to load my init file properly (located in `.emacs.d/init.el`) Specifically, 1. the final command I have in init.el `(find-file ..)` that I use to always start on a certain org-mode page, is ignored in place of starting with only the `*scratch*` buffer 2. various variables set in the init file are done so correctly 3. any changes to init I've attempted to make since the Emacs update aren't recognized either, as if it is operating on a snapshot of the init file from before the update Not sure how to run `--debug-init` under emacsclient, but if I disable it and run `emacs --debug-init` no errors come up. How do I go about investigating/fixing this? Thanks in advance! Edit: original issue 4) "`Wrong type argument: stringp, nil` error occurs when attempting to save a change to a variable via the customize option buffer" -- ended up being unrelated to the above; apparently has to do with evil-mode escaping after editing a value field under insert mode in a Customize Option buffer while still in the value field (but moving outside of the field before escaping insert mode allows for successful apply and save) # Answer > 3 votes `emacs` loads your init file. This is one of the potentially time-consuming parts of starting Emacs. `emacsclient` just connects to a running Emacs server. It doesn't load your init file, because it's not starting emacs. This is one of the reasons why it's fast. To make Emacs see your changes you can either evaluate the elisp directly, or you can kill the server and start a new one. --- Tags: init-file, emacsclient, customize, emacs-daemon ---
thread-60039
https://emacs.stackexchange.com/questions/60039
Possible to access the second-last clipboard contents (clipboard history)
2020-08-10T11:23:43.483
# Question Title: Possible to access the second-last clipboard contents (clipboard history) Is there a way to access the second last value of the clipboard in Emacs? I assume it's possible to make this work within Emacs. * Intercept the copy function. * Read the clipboard and add it to a list. * Set the clipboard as expected. --- Note, the reason I'm asking this is I'd like to make a shortcut to paste the second last item in the clipboard, so I can copy things while keeping access to what was already in the clipboard. # Answer You're in luck; this is already built in. `C-y` yanks the last thing that you've killed or copied, and `M-y` replaces it with the next item from the `kill-ring`, which contains everything you've killed or copied in your current Emacs session. > 3 votes # Answer This can be done by advising the function that sets the clipboard. ``` ;; Clipboard history. (defvar my-clipboard-history-limit 10) (defvar my-clipboard-history--list nil) (defun my-clipboard-history-paste (&optional index) (insert (nth (or index 0) my-clipboard-history--list))) (defun my-clipboard-history-paste-penultimate () (interactive) (my-clipboard-history-paste)) (defun my-clipboard-history--gui-set-selection (orig-fn type data) (when (eq type 'CLIPBOARD) (let ((old-data (gui-get-selection type))) (when old-data (let ((trim-number (- (length my-clipboard-history--list) my-clipboard-history-limit))) (when (> 0 trim-number) (nbutlast my-clipboard-history--list trim-number))) (push old-data my-clipboard-history--list)))) (funcall orig-fn type data)) ;;;###autoload (define-minor-mode my-clipboard-history-mode "Highlight block under the cursor." :global t :lighter "" (cond (my-clipboard-history-mode (advice-add 'gui-set-selection :around #'my-clipboard-history--gui-set-selection)) (t (advice-remove 'gui-set-selection #'my-clipboard-history--gui-set-selection)))) (provide 'my-clipboard-history-mode) ``` You can bind this to `Alt-P` in evil mode, for example: ``` (define-key evil-normal-state-map (kbd "M-p") 'my-clipboard-history-paste-penultimate) (define-key evil-insert-state-map (kbd "M-p") 'my-clipboard-history-paste-penultimate) ``` > 1 votes --- Tags: yank, clipboard ---
thread-7792
https://emacs.stackexchange.com/questions/7792
Can I make links in Org Mode that contain brackets, [ or ]?
2015-01-29T19:45:50.100
# Question Title: Can I make links in Org Mode that contain brackets, [ or ]? Is there someway to escape brackets (`[` and `]`) so that they can be included in the *description* of an Org mode link? The following link doesn't work, for example: ``` [[http://mathoverflow.net/questions/195203/automorphisms-of-ideals-of-mathbbct][Automorphisms of ideals of C[t]]] ``` I hoped using a backslash (`\[`) would work or that there would be an org-entity, but that doesn't seem to be the case. # Answer A working solution, not so pretty though, is to use the org mode Macros. The below macros are replaced by the ASCII codes of the `[` and `]` when exporting to html or latex. ``` # Square Bracket Open [ #+MACRO: BO @@latex:\char91@@ @@html:&#91;@@ # Square Bracket Close ] #+MACRO: BC @@latex:\char93@@ @@html:&#93;@@ [[http://emacs.stackexchange.com][{{{BO}}}Emacs SE{{{BC}}}]] ``` Reference > 5 votes # Answer Below is the modified version of `org-make-link-regexp` which will allow one nesting level of square brackets inside description: ``` (defun org-make-link-regexps () "Update the link regular expressions. This should be called after the variable `org-link-types' has changed." (setq org-link-types-re (concat "\\`\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):") org-link-re-with-space (concat "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" "\\([^" org-non-link-chars " ]" "[^" org-non-link-chars "]*" "[^" org-non-link-chars " ]\\)>?") org-link-re-with-space2 (concat "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" "\\([^" org-non-link-chars " ]" "[^\t\n\r]*" "[^" org-non-link-chars " ]\\)>?") org-link-re-with-space3 (concat "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" "\\([^" org-non-link-chars " ]" "[^\t\n\r]*\\)") org-angle-link-re (concat "<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" "\\([^" org-non-link-chars " ]" "[^" org-non-link-chars "]*" "\\)>") org-plain-link-re (concat "\\<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):" (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)")) ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)") org-bracket-link-regexp ;; "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]" "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^[]*?\\[[^]]*?\\][^]]*?\\|[^][]+\\)\\]\\)?\\]" org-bracket-link-analytic-regexp (concat "\\[\\[" "\\(\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):\\)?" "\\([^]]+\\)" "\\]" "\\(\\[" "\\([^[]*?\\[[^]]*?\\][^]]*?\\|[^]]+\\)" "\\]\\)?" ;; "\\(\\[" "\\([^]]+\\)" "\\]\\)?" "\\]") org-bracket-link-analytic-regexp++ (concat "\\[\\[" "\\(\\(" (mapconcat 'regexp-quote (cons "coderef" org-link-types) "\\|") "\\):\\)?" "\\([^]]+\\)" "\\]" "\\(\\[" "\\([^]]+\\)" "\\]\\)?" "\\]") org-any-link-re (concat "\\(" org-bracket-link-regexp "\\)\\|\\(" org-angle-link-re "\\)\\|\\(" org-plain-link-re "\\)"))) ``` But as noted above, this doesn't solve the problem of editing links (Org will still want to replace brackets with braces.) This also can only handle one nesting level of one bracketed group. > 3 votes # Answer URL encode seems OK. I just use it for an url with brackets: `[http://www.example.com/Array%5Bi%5D][Your description]` Left Square Bracket ("\["):5B Right Square Bracket ("\]") 5D HTH > 2 votes --- Tags: org-mode ---
thread-60077
https://emacs.stackexchange.com/questions/60077
Cannot paste text copied from Emacs to synchronous subprocess
2020-08-12T08:29:52.923
# Question Title: Cannot paste text copied from Emacs to synchronous subprocess # TL;DR --- When trying to paste text copied/killed in Emacs to another program while Emacs is waiting for a synchronous subprocess to finish, the target program hangs until Emacs becomes responsive again. # Reproducing the issue --- This happens to me especially when running `M-x shell-command git commit`. 1. Kill/copy some text to be used in the commit message inside Emacs. 2. Run `M-x shell-command git commit --all` 3. Try to paste the text. If the editor registered with git has means for cancelling the paste (e.g. `C-g` when using `emacs -Q` as editor), this state can be recovered from, but generally the editor effectively crashes. Is it possible to fix this behavior? The current behavior looks like Emacs is not actually putting the text into the clipboard, but rather a reference to internal state. This behavior occurs on both Linux and Windows. # Workarounds --- 1. Paste the text to a separate program, and cut it there, before running `M-x shell command`. This places the text in a buffer, that is separate from Emacs, which I want Emacs to do in the first place. 2. Run the command asynchronously, e.g. `M-x shell-command git commit --all &`. # Answer There are several ways of copying text between programs on Linux. I'm just guessing that you're using Linux, but I don't think that this problem could occur on Windows or OSX. I also surmise that you're running Emacs as an X Windows application, not inside a terminal, else you wouldn't have this problem. The first is by selecting text in program A and pasting it into program B. This is called the "primary selection", but the "secondary selection" is used so rarely that the name is becoming obsolete. When you select text, program A sends a message saying that the user has selected some text in one of its windows. All other programs hear this message and cancel any selections you might have made in their windows. When you paste, the current program sends a message to the program where the selection is asking it to send the text over to be pasted. By convention, you paste from the primary selection by clicking the middle mouse button. The second is called the clipboard. When you copy some text in program A, it sends the text to the clipboard manager right away. Later, when you paste from the clipboard into program B, program B asks the clipboard manager for the text to be inserted. By convention, you paste from the clipboard with a keyboard shortcut or by selecting the action from a menu. There's also a third method called cut buffers, but it's obsolete and you're probably not using it. I surmise that you have selected some text in Emacs, and want to paste it into the editor launched by `git commit`. That editor could be any program, but might be another instance of Emacs. Then you're running `M-x shell-command git commit`, which synchronously executes `git commit`. Then you try to paste into the new editor, but it fails. This is to be expected, because you selected text in Emacs, but then made Emacs synchronously execute some program. No program can respond to messages while taking any synchronous action, so of course the other editor might hang while waiting for the reply. There are two ways to fix this. You already know that running `git commit` asynchronously will fix it. You can also fix it by explicitly copying the text after selecting it. In the default configuration, Emacs sends whatever you copy to the clipboard as well as to the kill ring whenever you copy or kill text, so just hit `M-w` (`kill-ring-save`) before running git. Then, in the other editor, paste from the clipboard rather than the primary selection. Chapter 12.3 "Cut and Paste" Operationson Graphical Displays covers all the details if you want even more information. > 2 votes --- Tags: git, copy-paste, shell-command, subprocess, call-process ---
thread-60080
https://emacs.stackexchange.com/questions/60080
Is the GPG signature of Emacs 26.3 still valid?
2020-08-12T09:38:07.523
# Question Title: Is the GPG signature of Emacs 26.3 still valid? I was trying to install Emacs on my Windows 8.1 machine (thus WSL is not an option). I downloaded the file from a mirror (emacs-26.3-x86\_64.zip), along with his signature (emacs-26.3-x86\_64.zip.sig). However, when I try to verify it with Cygwin, I get this: ``` $ gpg --verify emacs-26.3-x86_64.zip.sig emacs-26.3-x86_64.zip gpg: Signature made 08/30/19 14:04:16 ope gpg: using RSA key 84930FFB79B645F7DEA29AD0AC6DD3FFD1D046BD gpg: Good signature from "Phillip Lord <phillip.lord@newcastle.ac.uk>" [expired] gpg: aka "Phillip Lord <phillip.lord@russet.org.uk>" [expired] gpg: WARNING: This key has been revoked by its owner! gpg: This could mean that the signature is forged. gpg: reason for revocation: No reason specified gpg: revocation comment: Revocation Certification produced at generation time gpg: Note: This key has expired! Primary key fingerprint: 8493 0FFB 79B6 45F7 DEA2 9AD0 AC6D D3FF D1D0 46BD ``` Now, is this file safe to install? # Answer > 0 votes No, the key has been revoked. It does say that the signature matched what was expected, but if the key was stolen then the signature could be forged. The Emacs community really should get together to verify the binaries and then resign them. Update: I happened to notice that Windows binaries of Emacs 27 have been posted to https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-27/. This release is newer than the one you've got, and it's signed with a different key. Perhaps if you tried it you'll get better results. --- Tags: microsoft-windows, emacs26, cygwin, pgp ---
thread-60081
https://emacs.stackexchange.com/questions/60081
Can I make emacs recognize double-quoted strings in sql-mode?
2020-08-12T09:39:54.307
# Question Title: Can I make emacs recognize double-quoted strings in sql-mode? I am looking for a way to make `sql-mode` highlight double-quoted strings in the same way as single-quoted strings. Setting the product to `MySQL` (which is the correct product for me) did not achieve this result. # Answer Maybe this? ``` (let* ((mysql (alist-get 'mysql sql-product-alist)) (syntax (plist-get mysql :syntax-alist))) (plist-put mysql :syntax-alist (cons '(?\" . "\"") syntax))) ``` > 2 votes --- Tags: sql-mode ---
thread-60074
https://emacs.stackexchange.com/questions/60074
Paste into org-mode: utf-8-unix cannot encode \207 for á, \222 for í
2020-08-12T05:07:01.600
# Question Title: Paste into org-mode: utf-8-unix cannot encode \207 for á, \222 for í I'm learning emacs (on spacemacs) and focusing on orgmode. When I paste into an org-mode buffer from a non-english language that contains accents and other signs (in my case italian and spanish) I get: > These default coding systems were tried to encode text In the buffer... : utf-8-unix (2291 . 4194183) (2330 . 4194194) (2334 . 4194194) (2353 . 4194194) (2367 . 4194194) (2397 . 4194199) (2400 . 4194240) (2403 . 4194183) (2449 . 4194204) (2463 . 4194199) (2519 . 4194198)) However, each of them encountered characters it couldn't‚be encode: utf-8-unix cannot encode these: á í í í í ó ¿ á ú ó ... Is there a way to convert the characters when pasting? Thanks in advance. # Answer The following solved it (I pasted it in the init part of my spacemacs configuration): ``` (prefer-coding-system 'utf-8) (set-default-coding-systems 'utf-8) (set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (set-terminal-coding-system 'utf-8) (setq buffer-file-coding-system 'utf-8) (setq erc-server-coding-system '(utf-8 . utf-8)) (setq locale-coding-system 'utf-8) ;; Treat clipboard input as UTF-8 string first; compound text next, etc. (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) (setenv "LANG" "fr_FR.UTF-8") (setenv "LC_ALL" "fr_FR.UTF-8") ``` > 0 votes --- Tags: org-mode, copy-paste ---
thread-25019
https://emacs.stackexchange.com/questions/25019
TBLFM insert new row with current time
2016-08-02T13:02:27.693
# Question Title: TBLFM insert new row with current time I want to insert a new row at line 2 in a table (preferably using TBLFM), and I want it to be prefilled with the current date (col 1) and time (col 2). How do I insert a new row (something like `#+TBLFM: @2..@-1=@#-1`?) ? Here is my current table: ``` | date | start | end | lunch | total | expected | + time | |------------------+-------+-------+-------+----------+----------+-----------| | [2016-08-02 Tue] | 08:58 | 17:00 | 0:15 | 07:47:00 | 07:30:00 | 00:17:00 | | [2016-08-01 Mon] | 08:37 | 16:12 | 0:15 | 07:20:00 | 07:30:00 | -00:10:00 | |------------------+-------+-------+-------+----------+----------+-----------| | | | | | | | 00:07:00 | #+TBLFM: @2$5..@-1$5=$3-$2-$4;T::@2$7..@-1$7=$5-$6;T::@>$7=vsum(@2$7..@-1$7);T ``` # Answer > 1 votes The following line inserts a new row, but with the content of cell 1 "#ERROR". ``` #+TBLFM: @2$1='(let ((org-table-fix-formulas-confirm 0)) (org-table-insert-row)) ``` The part with setting `org-table-fix-formulas-confirm` to 0 is so that it doesn't update all the indices in the formulae. So using two formulae, the following works: ``` | date | start | end | |------------------+-------+-------| | [2016-08-01 Mon] | 08:00 | 16:00 | |------------------+-------+-------| #+TBLFM: @2$1='(let ((org-table-fix-formulas-confirm 0)) (org-table-insert-row)) #+TBLFM: @2$1='(format-time-string "[%Y-%m-%d %a]")::@2$2='(format-time-string "%H:%M") #+TBLFM: @2$3='(format-time-string "%H:%M") ``` # Answer > 0 votes > **Note:** My answer is derived directly from `Pål GD`'s great answer. I only figured out how to prevent the `#ERROR` message. ### Call the elisp functions inside `let` declaration section and return the date string. Like this `(let ((org-table-fix-formulas-confirm 0) (x (format-time-string "[%Y-%m-%d %a]")) (y (org-table-insert-row))) x)` Below is complete example for your answer code ``` | date | start | end | |------------------+-------+-------| | [2020-08-12 Wed] | 09:10 | 09:10 | | [2016-08-01 Mon] | 08:00 | 16:00 | |------------------+-------+-------| #+TBLFM: @3$1='(let ((org-table-fix-formulas-confirm 0) (x (format-time-string "[%Y-%m-%d %a]")) (y (org-table-insert-row))) x)::@3$2='(format-time-string "%H:%M")::@3$3='(format-time-string "%H:%M") ``` Thank you for asking this question! --- > **This answer was tested using:** > > --- > > **emacs version:** GNU Emacs 25.2.1 (x86\_64-unknown-cygwin, GTK+ Version 3.22.10) > **org-mode version:** Org mode version 9.1.2 --- Tags: org-mode, org-table ---
thread-60087
https://emacs.stackexchange.com/questions/60087
Differences between "helm-follow-mode" and "follow-mode"
2020-08-12T12:56:56.403
# Question Title: Differences between "helm-follow-mode" and "follow-mode" "helm-follow-mode" vs. "follow-mode" Basically: what is the difference between their behaviours? # Answer They are two different, not related things. (emacs) Follow Mode: > “Follow mode” is a minor mode that makes two windows, both showing the same buffer, scroll as a single tall virtual window. `C-h f helm-follow-mode`: > Execute persistent action every time the cursor is moved. > 1 votes --- Tags: helm, follow-mode ---
thread-53589
https://emacs.stackexchange.com/questions/53589
Choose where org-agenda-tree-to-indirect-buffer window opens
2019-11-06T16:01:37.637
# Question Title: Choose where org-agenda-tree-to-indirect-buffer window opens If I have an org file open: ``` +----------------------------------------+ | | | | | | | org file | | | | | | | | | | | | | +----------------------------------------+ ``` And open the Agenda view: ``` +----------------------------------------+ | | | | | | | | | | org file | agenda | | | | | | | | | | | | | | | | | | | +------------------+---------------------+ ``` And then hit TAB on a todo item, it does `(org-agenda-goto)` and jumps to the item in the original window: ``` +----------------------------------------+ | | | | | | | | | | org file | agenda | | jumped to | | | item | | | | | | | | | | | | | | +------------------+---------------------+ ``` Which is great. If I do `(org-agenda-tree-to-indirect-buffer)`, however, it opens in a teeny window below the agenda: ``` +----------------------------------------+ | | | | | | | | | | org file | agenda | | | | | | | | | | | | | | +---------------------+ | | org item i.b. | +------------------+---------------------+ ``` What I'd like to happen is: ``` +----------------------------------------+ | | | | | | | | | | org item i.b. | agenda | | | | | | | | | | | | | | | | | | | +------------------+---------------------+ ``` I *could* do this by just typing `TAB , s b`, which isn't so bad, but out of general interest I'm wondering how do I control the placement of the new window that `org-agenda-tree-to-indirect-buffer` creates? # Answer I agree with this request. Here's a workaround: In org-agenda.el I found the function: org-agenda-tree-to-indirect-buffer and changed the line which calls "split-window". I added the parameters `nil 't` to the `split-window` call: Before: ``` (unwind-protect (unless (and indirect-window (window-live-p indirect-window)) (setq indirect-window (split-window agenda-window))) ``` After: ``` (unwind-protect (unless (and indirect-window (window-live-p indirect-window)) (setq indirect-window (split-window agenda-window nil 't))) ``` It's a hack, and may mess up other functionality but it works for me. > 0 votes --- Tags: org-mode, org-agenda, window-splitting ---
thread-60097
https://emacs.stackexchange.com/questions/60097
`cl-incf` returns inconsistent values
2020-08-12T18:56:40.197
# Question Title: `cl-incf` returns inconsistent values ``` (setq ali '()) >>> nil (cl-incf (alist-get 'a ali 0)) >>> ((a . 1)) (setf (alist-get 'b ali) 0) >>> ((b . 0) (a . 1)) (cl-incf (alist-get 'b ali 0)) >>> 1 ``` As you can see, `cl-incf` returns different kinds of values in the second and the fourth expressions. `cl-incf` per documentation is supposed to return "the incremented value of PLACE", however as we can see with the key `'a` it returns the whole `ali` structure. If we macroexpand it a few times, it's clear what's happening: ``` (let* ((p (if (and nil (not (eq nil 'eq))) (assoc 'a ali nil) (assq 'a ali))) (v (+ (if p (cdr p) 0) 1))) (if p (setcdr p v) (setq ali (cons (setq p (cons 'a v)) ali)))) ``` The last `setq` is applied to `ali`, so it returns the new value of `ali`. It seems to be a bug in the alist generalized variable definition. Am I correct? If so, how to report it? If not, what's the idiomatic way to work around it, preferably not calling `alist-get` two times? # Answer > 2 votes Yep, the behavior for the second sexp, `(cl-incf (alist-get 'a ali 0))` looks wrong. I think the last part of the expansion should be something like this: ``` (if p (setcdr p v) (setq ali (cons (setq p (cons 'a v)) ali)) v) ``` IOW, after updating `ali` it should return `v`, not `ali`. In all cases it should return `v`. I filed Emacs bug #42837 for this. In the future, you can do it yourself via `report-emacs-bug`. But it turns out this has already been fixed in Emacs 27.1, which has just been released. --- Tags: setf ---
thread-56070
https://emacs.stackexchange.com/questions/56070
Add timestamp to file name in org export
2020-03-11T18:33:18.353
# Question Title: Add timestamp to file name in org export How can I create a time stamped file name with the org header arg: `#+export_file_name: <timestamp-var> + File name` There is a variable `org-time-stamp`, is there a way to append it to the static file name to create files with time stamp at time of export in the file name? Thanks # Answer Add this to your init file: ``` (add-hook 'before-save-hook 'time-stamp) ``` and this to the Org file: ``` # Local Variables: # time-stamp-format: "%04y-%02m-%02d_%f" # time-stamp-pattern: "^#\\+export_file_name: %%$" # End: ``` The value of `#+export_file_name:` should update every time the file is saved. > 2 votes # Answer It seems like ``` (org-export-to-file 'pdf (concat "success_" (format-time-string #%FT%H:%M:%S") ".pdf")) ``` is close to right. The call to concat seems to work, but the call to org-export-to-file doesn't. Even if I had made this work, I'm not sure how to insert it so that it's run automatically by the exporter. Help? > 1 votes --- Tags: org-mode, org-babel ---
thread-60092
https://emacs.stackexchange.com/questions/60092
flush-lines fails in script but works when called otherwise
2020-08-12T15:25:49.220
# Question Title: flush-lines fails in script but works when called otherwise I'm very new to programming in Elisp so maybe the mistake is there but I'm completely stuck right now. I wanted to make a small, simple Elisp function to remove the AUTOs from my Verilog files so I don't commit those lines to our git repository since the rest of my team doesn't use Emacs. I thought this would be a very simple task but for the life of me, I can't get `flush-lines` to work properly. The regular expression I'm trying to use is `\/\*AUTO\w+\*/`. When I do `M-x flush-lines RET \/\*AUTO\w+\*/ RET` this works. So I would think the regular expression works. But when I try to do it in either my .emacs or by doing `M-: (flush-lines "\/\*AUTO\w+\*/" nil (buffer-size) t) RET`, it just outputs a `nil`. I also tried `(flush-lines "\/\*AUTO\w+\*/")` and `(flush-lines "\/\*AUTO\w+\*/" nil (buffer-size))` and they both just output `nil` and don't remove the matching lines. My point is set to the top of the buffer, so I don't understand what the issue is. I can't seem to find anywhere any resources that could point me in the right direction. The closest I found was this post from a couple years ago but it goes far beyond the simple task I'm trying to do, and I seem to be suffering from a different issue than that user was. # Answer The syntax for escaping elements of regular expressions can be confusing. Once you find an interactive solution that works, a handy tip is to look at Emacs' command history: ``` M-x command-history ``` With the command given in the question, the command history shows: ``` (flush-lines "\\/\\*AUTO\\w+\\*/" nil nil t) ``` That gives the Elisp that will work. The reason all the extra escaping is necessary can be found in the following doc: Special Characters in Regular Expressions The character `\` has special meaning both in regexp and in the Lisp reader. > 2 votes --- Tags: regular-expressions, backslash ---
thread-60094
https://emacs.stackexchange.com/questions/60094
Prompt for stdin via `shell-command`
2020-08-12T17:07:00.480
# Question Title: Prompt for stdin via `shell-command` Sometimes when I copy+paste into my spacemacs over SSH, I get some random garbage that seems to be due to spacemacs interpreting some of the pasted content as commands. In vim, my workaround is to run `r! cat`, paste what I want into the `cat` command, then `Ctrl-D` to exit. When I run `M-x shell-command ENTER cat ENTER`, however, I get `(shell command succeeded with no output)` immediately, and no prompt. What is the right way to get the equivalent of `r! cat` from emacs (or spacemacs, in particular)? # Answer > 0 votes Doing that with cat is a real kludge; the right solution is to turn on bracketed paste mode in your terminal emulator. Your terminal emulator knows when you are pasting, so it is supposed to send an escape sequence at the start of the paste and another at the end. Emacs can then treat the text in the middle as raw text rather than commands. Every terminal emulator has a different way of configuring this, but Emacs should auto-detect it once you do. --- Tags: spacemacs, copy-paste, shell-command ---
thread-59611
https://emacs.stackexchange.com/questions/59611
How to disable `clean-aindent-mode` in spacemacs configuration
2020-07-13T16:09:24.053
# Question Title: How to disable `clean-aindent-mode` in spacemacs configuration I noticed that `clean-aindent-mode` is messing up the indentation as I am writing python files. Hence, I wanted to disable this mode, at least when using python mode. I can manually disable this mode, but I was wondering what the correct code was to disable `clean-aindent-mode` in my spacemacs configuration file? I imagine it is something simple, but I don't really know emacs lisp. Thanks. # Answer > 1 votes It seems to have been added to a recent Spacemacs dev branch. Press `SPC-f-e-d` to open your config file, find the `*/init` section as shown below, and add in the one liner to disable. ``` (defun dotspacemacs/init () "Initialization: This function is called at the very beginning of Spacemacs startup, before layer configuration. It should only modify the values of Spacemacs settings." ... ;; If non nil activate `clean-aindent-mode' which tries to correct ;; virtual indentation of simple modes. This can interfer with mode specific ;; indent handling like has been reported for `go-mode'. ;; If it does deactivate it here. ;; (default t) dotspacemacs-use-clean-aindent-mode nil ... ) ``` --- Tags: spacemacs, indentation ---
thread-60111
https://emacs.stackexchange.com/questions/60111
Reverting a hunk without refreshing in Magit Diff
2020-08-13T12:44:10.997
# Question Title: Reverting a hunk without refreshing in Magit Diff Typing `v` in Magit Diff mode causes an often slow and uncecessary refresh. Can this be avoided? For example when looking at a diff between a range of commits (say `origin/mater...HEAD`). Typing `v` (A.K.A. `M-x magit-revert-no-commit`) applies the reversed hunk to the worktree. The diff between the commits has not changed, but Magit still refreshes the entire buffer. Even if the diff does change, I often would still like to avoid refreshes when I have large diffs that take minutes to refresh. # Answer > 2 votes No, unfortunately Magit isn't smart enough to notice that there's no need to refresh (and there is not setting to just suppress refreshing altogether). I plan to implement intelligent refresh *one day*™ but better don't hold your breath. --- Tags: magit ---
thread-60032
https://emacs.stackexchange.com/questions/60032
How to change the default transient level temporarily? ("Show hidden magit commands")
2020-08-09T22:05:00.143
# Question Title: How to change the default transient level temporarily? ("Show hidden magit commands") Many commands that are rarely used in magit are hidden by default. Magit uses the transient.el library for popups and the visibility of infix and suffix commands are controlled by `transient-default-level`. For example: At the default level (`4`), `magit-branch` transient hides orphan, worktree, and shelving suffix commands (levels `6`,`5`,&`7` respectively). I want to invoke the "new orphan" command, but I don't want to persist the visibility of that command or other commands (even for the remainder of the current session). **How can I conveniently change the default transient level temporarily, so that I can invoke a hidden command once?** The two ways I know of are: 1. Change the transient level for the command using `C-x``l` (`transient-set-level`), invoke it, and then change it back. 2. Change `transient-default-level` programmatically (ex: `(setq transient-default-level 6)`), invoke the command, and change `transient-default-level` back. # Answer **Update:** I have now implemented this. The key binding is `C-x a` I \[as the author of this package\] did not consider this feature but it sounds potentially useful and doable but it doesn't exist yet. I've added this idea to my TODO list but for now you'll have to stick to your workarounds. I am not aware of any existing solution. > 11 votes --- Tags: magit, commands, visibility, transient-library ---
thread-59698
https://emacs.stackexchange.com/questions/59698
git-blame with spacemacs
2020-07-17T23:25:50.957
# Question Title: git-blame with spacemacs I'm trying invoke magit-blame in spacemacs. If I do: ``` SPC g b ``` Then I see a "git-blame" section at the bottom which says: ``` Press [_b_] again to blame further in the history, [_q_] to go up or quit. ``` But if I hit `b`, I see the error message: ``` Unbound suffix: 'b' ``` ON the other hand, if I invoke magit blame instead by doing: ``` M-x magit-blame ``` And then I hit `b`, it works. # Answer > 0 votes This is implemented in Spacemacs and #13643 Add Git Blame Transient State sounds like it would probably fix this, on `develop`. --- Tags: spacemacs, magit ---
thread-59552
https://emacs.stackexchange.com/questions/59552
Magit forge: updating the branch of a pull request
2020-07-09T15:53:45.033
# Question Title: Magit forge: updating the branch of a pull request Does forge support updating the branch of a PR? Suppose that I checked out a PR branch with `b y`, and afterwards there were additional commits into this PR. It seems that I cannot pull these new commits with `magit-pull`, because `pushRemote` is not set, and upstream is set to `master`. The only way I see to update the branch is to delete the PR's branch, and then check it out again with `b y`. Am I right on this one? Is there a more convenient way to do this? # Answer > 0 votes You might have to begin by fetching everything using `f a`. > `pushRemote` is not set The push remote *is* configured. Check the rebase popup it; it should show that this is the case. > Is there a more convenient way to do this? What I do is to first fetch everything and then do either a hard-reset, if I did not change anything locally, or I rebase onto push target otherwise. --- Tags: magit ---
thread-60117
https://emacs.stackexchange.com/questions/60117
How to insert text and activate the mark in the same function
2020-08-13T13:36:31.790
# Question Title: How to insert text and activate the mark in the same function I am trying to write a function where I insert some text, and then activate the mark at the end of the function. I have several use-cases where I would like to use this. I cannot figure out how do make it work. I have the following expression which I am using to test the behavior: ``` (progn (set-mark-command nil) (save-excursion (insert "hi")) (forward-line 2) (activate-mark)) ``` Evaluating this expression does not activate the mark; however, if I comment out the save-excursion part which inserts some text, the mark is activated. Why isn't the mark being activated, and what can I do to make the expression work as expected? # Answer > 0 votes My question is a duplicate of this question and this one. Quick recap: From the answers in those threads, it seems certain commands will deactivate the mark. `Insert` appears to be such a command. We can fix this issue in two ways: 1. Change the first line ``` - (progn + (let (deactivate-mark) (set-mark-command nil) (save-excursion (insert "hi")) (forward-line 2) (activate-mark)) ``` This sets the variable `deactivate-mark` to `nil`. This was the first time I had seen a `let` with a variable without assigning it a value. You can read more about this here. 2. Unset the variable `deactivate-mark` at the end of our function ``` (progn (set-mark-command nil) (save-excursion (insert "hi")) (forward-line 2) (activate-mark) + (setq deactivate-mark nil)) ``` --- Tags: mark, insert ---
thread-56162
https://emacs.stackexchange.com/questions/56162
Package for live inline rendering for markdown/org mode text with css styling?
2020-03-15T05:37:25.450
# Question Title: Package for live inline rendering for markdown/org mode text with css styling? Currently, I use Typora (a markdown editor) for all my personal notes and documentation. After seeing the capabilities of emacs in a colleague's spacemacs setup, I am very interested in switching from writing personal documentation in markdown to org-mode. But are there are emacs packages/plugins that can match the following two Typora features? 1. Is there an emacs plugin for live, inline rendering of org-mode or markdown text with css themes? By "inline" rendering, I mean markup is rendered in the same window that you type in (see gif below) 2. Is there a way to render images inline in org-mode documentation? # Answer The answer to question 2 is yes! If you have an image `cat.png` in the same folder as you org file, you can insert it using simply `[[./cat.png]]` and toggle inline display with `C-c C-x C-v`. Here's a link to the relevant org documentation. If you want inline images to be displayed by default, as suggested in this answer you can add the following line to your init file: ``` (setq org-startup-with-inline-images t) ``` Question 1 is not as simple. Strictly speaking, I don't think you can use CSS to control the display of text in an Emacs buffer. However, there are extensive visual customisation options for Emacs in general and for `org-mode` in particular which allow us to get an aesthetic similar to that of Typora. For an example of what is possible, see the screenshot below by Abhinav Tushar, described in detail here, or the following Reddit thread. Below I will try to provide an `org-mode` customisation that makes it visually similar to the Typora example. First, here's how the example text looks in a vanilla Emacs 27 setup (no customisations) on Ubuntu 20.04. As you can see, we have hyperlinks by default as well as boldface and italic text. However, emphasis markers (`*, /`) are still displayed, there is no word wrap, a fixed-width font is used throughout and the title is the same size as the main text. --- **Basic customisation: no emphasis markers, word wrap and clean UI** We start with simple settings that don't require any additional packages: we hide emphasis markers such as `*` or `/`, enable word wrapping by default in `org-mode` and hide the toolbar, menu bar and scroll bar. ``` ;; hide emphasis markers (setq org-hide-emphasis-markers t) ;; word wrap (with-eval-after-load 'org (add-hook 'org-mode-hook #'visual-line-mode)) ;; disable toolbar, menu bar and scroll bar (tool-bar-mode -1) (menu-bar-mode -1) (toggle-scroll-bar -1) ``` Emacs now looks as follows: --- **Changing fonts, removing asterisks, increasing line spacing and changing list markers** The most obvious difference between our example and Typora is now the font. The font in the Typora example looks like a clone of the classic Palatino. Due to Palatino's popularity, some version of this font is available in most systems. However, to make this answer as general as possible, we will use the TeX Gyre Pagella font, a Palatino clone developed primarily with LaTeX in mind and which therefore has good math support. It's available in PS Type 1 and OTF formats and free to download and use. After we install Pagella on our system, we can configure `org-mode` to use it for text while using a monospaced font for code, tables, etc. (I tend to use Adobe's Source Code Pro, which is also free and available on GitHub). We could do this by changing `org-mode`'s settings ourselves but it's easier to have the `mixed-pitch` package handle this for us. When using external packages, it's convenient to set MELPA as the default repository and have `use-package` take care of the package configuration, so we start by adding the following lines to the start of our init file: ``` ;; set up MELPA package repo (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (package-initialize) ;; use-package to simplify package loading (unless (package-installed-p `use-package) (package-refresh-contents) (package-install `use-package)) (eval-when-compile (require 'use-package)) ``` We can now add the relevant code for changing fonts: ``` ;; set fixed-width font (set-face-font 'default "Source Code Pro-12") ;; set variable-width font (set-face-font 'variable-pitch "TeX Gyre Pagella-13") ;; set org-mode to use variable width fonts smartly (use-package mixed-pitch :ensure t :hook (text-mode . mixed-pitch-mode)) ``` To improve the aesthetics further, we can make the header font larger and bold, hide the asterisk using the `org-bullets` package, use black squares (Unicode character U+25AA) instead of hyphens as list markers (following Diego Zamboni) and increase the line spacing: ``` ;; increase header font size and weight (custom-set-faces '(org-level-1 ((t (:height 1.3 :weight bold)))) '(org-level-2 ((t (:height 1.2 :weight bold)))) '(org-level-3 ((t (:height 1.1 :weight bold))))) ;; hide asterisks in headers (use-package org-bullets :ensure t :config (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))) (setq org-bullets-bullet-list '("\u200b"))) ;; change list markers from hyphens to squares (font-lock-add-keywords 'org-mode '(("^ *\\([-]\\) " (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "▪")))))) ;; increase line spacing (setq-default line-spacing 0.5) ``` This gives us the following appearance: --- **Finishing touches: emulating Typora's Focus Mode** Typora provides two interesting modes for displaying text which can be used either jointly or separately: with Focus Mode, paragraphs other than the current one (where the cursor is) are displayed in a dim grey colour; and with Typewriter Mode, the cursor is always centred vertically on the page. We can emulate the behaviour of Typora's Focus Mode with the `focus` package. After installing and loading the package, we can turn on `focus-mode` with `M-x focus-mode`. For Typewriter Mode, things are more complicated: the `centered-cursor-mode` package implements this behaviour but is still under development and is not available on the MELPA repository. However, you can modify Emacs settings to achieve a similar functionality if you wish. Going beyond these two modes, I would also recommend the lovely `olivetti` package: it increases the text's side margins, making it easier and more pleasant to read. We add the following lines to our init file: ``` ;; focus mode (use-package focus :ensure t) ;; olivetti for wider margins (use-package olivetti :ensure t) ``` Finally, we can set a new theme such as `doom-tomorrow-day` (this has the advantage of changing the colour of the text dimmed by `focus` to grey rather than dark red as in the default theme) and remove the modeline: ``` ;; hide modeline (setq-default mode-line-format nil) ;; change theme (use-package doom-themes :ensure t :config ;; Global settings (defaults) (setq doom-themes-enable-bold t ; if nil, bold is universally disabled doom-themes-enable-italic t) ; if nil, italics is universally disabled (load-theme 'doom-tomorrow-day t) ; theme (doom-themes-org-config)) ; corrects (and improves) org-mode's native fontification ``` Our Emacs now looks like this: And that's it! As you can see, Emacs can do most of what you might want out of a text editor and more. ;) > 8 votes --- Tags: spacemacs, package, markdown ---
thread-60121
https://emacs.stackexchange.com/questions/60121
Is it possible to run one emacs but from two terminals?
2020-08-13T16:00:34.243
# Question Title: Is it possible to run one emacs but from two terminals? I was thinking about how I work normally on services. Where I might write code in an editor via Emacs in a terminal view, and in another terminal run the code, and yet still in another view `tail` the log. I'd like to do something similar but with Emacs. For instance, write some code in elisp which updates a buffer that's something like a log, but I'd like to put that log/view on another window in another terminal altogether, but controlled from one Emacs. Is this possible? If so how? # Answer > 2 votes It sounds like this would be addressed by running Emacs in daemon mode. For instance, when I start up I run: ``` emacs --daemon ``` Then I can start a new client with ``` emacsclient -nw my/file ``` And in another terminal open a client with no file with ``` emacsclient -nw ``` (`-nw` = use console rather than opening a GUI window, but also avoids needing to provide a file.) Both clients share the same set of buffers; it's like opening a new frame in a GUI version of Emacs. I have an idiosyncratic config for server mode, but I believe this will work as described out of the box, as it were. You can read in more detail at https://www.emacswiki.org/emacs/EmacsAsDaemon --- Tags: terminal-emacs ---
thread-60125
https://emacs.stackexchange.com/questions/60125
Disable Prettify-Symbols for C-mode
2020-08-13T23:31:50.010
# Question Title: Disable Prettify-Symbols for C-mode I'm using doom emacs. It enables prettify-symbols in all modes (I think) by default, although I would like to disable it in c-mode. I have placed the following in my config.el file: ``` (add-hook 'c-mode-hook (lambda () (prettify-symbols-mode -1))) ``` I have also tried this: ``` (add-hook 'c-mode-hook (lambda () (setq prettify-symbols-alist '()))) ``` Nothing has worked, but I am able to disable it manually with `M-x prettify-symbols-mode`, but I find this tedious to do every time I want to edit a c file. Any help is appreciated. Edit: I tried Phils's answer, to no avail. I also tried putting ``` (global-prettify-symbols-mode -1) ``` before that answer. I also did that, but changing the function definition to: ``` (prettify-symbols-mode -1) ``` Edit: Per Phils's comment I used `M-x debug-on-entry RET prettify-symbols-mode` and then opened a C file and the following traceback occurred: ``` Debugger entered--entering a function: * global-prettify-symbols-mode(-1) my-c-mode-hook() run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c-mode-hook) apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c-mode-hook)) run-mode-hooks(c-mode-hook) c-mode() set-auto-mode-0(c-mode nil) #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>)() apply(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) nil) #f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set)() apply(#f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set) nil) so-long--set-auto-mode(#f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set)) apply(so-long--set-auto-mode #f(advice-wrapper :after #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x14884ef2754764cc>) auto-minor-mode-set) nil) set-auto-mode() normal-mode(t) #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>)(t t) apply(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) (t t)) (if (setq doom-large-file-p (and buffer-file-name (not doom-large-file-p) (file-exists-p buffer-file-name) (condition-case nil (progn (> (nth 7 (file-attributes buffer-file-name)) (* 1024 1024 (assoc-default buffer-file-name doom-large-file-size-alist ...)))) (error nil)))) (prog1 (apply orig-fn args) (if (memq major-mode doom-large-file-excluded-modes) (setq doom-large-file-p nil) (if (fboundp 'so-long-minor-mode) (progn (so-long-minor-mode 1))) (message "Large file detected! Cutting a few corners to impr..."))) (apply orig-fn args)) doom--optimize-for-large-files-a(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) t t) apply(doom--optimize-for-large-files-a #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) (t t)) #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a)(t t) apply(#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) (t t)) #f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) doom-first-file-hook-h)(t t) apply(#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode 0x68a5324eea0fe54>) doom--optimize-for-large-files-a) doom-first-file-hook-h) (t t)) after-find-file(t t) find-file-noselect-1(#<buffer wueygfqweu.c> "c:/Users/Username/wueygfqweu.c" nil nil "c:/Users/username/wueygfqweu.c" nil) find-file-noselect("wueygfqweu.c" nil nil nil) find-file("wueygfqweu.c") evil-edit("wueygfqweu.c" nil) funcall-interactively(evil-edit "wueygfqweu.c" nil) call-interactively(evil-edit) evil-ex-call-command(nil #("e" 0 1 (ex-index 1)) #("wueygfqweu.c" 0 1 (ex-index 3) 1 2 (ex-index 4) 2 3 (ex-index 5) 3 4 (ex-index 6) 4 5 (ex-index 7) 5 6 (ex-index 8) 6 7 (ex-index 9) 7 8 (ex-index 10) 8 9 (ex-index 11) 9 10 (ex-index 12) 10 11 (ex-index 13) 11 12 (ex-index 14))) eval((evil-ex-call-command nil #("e" 0 1 (ex-index 1)) #("wueygfqweu.c" 0 1 (ex-index 3) 1 2 (ex-index 4) 2 3 (ex-index 5) 3 4 (ex-index 6) 4 5 (ex-index 7) 5 6 (ex-index 8) 6 7 (ex-index 9) 7 8 (ex-index 10) 8 9 (ex-index 11) 9 10 (ex-index 12) 10 11 (ex-index 13) 11 12 (ex-index 14)))) evil-ex-execute(#("e wueygfqweu.c" 0 1 (ex-index 1) 1 2 (ex-index 2) 2 3 (ex-index 3) 3 4 (ex-index 4) 4 5 (ex-index 5) 5 6 (ex-index 6) 6 7 (ex-index 7) 7 8 (ex-index 8) 8 9 (ex-index 9) 9 10 (ex-index 10) 10 11 (ex-index 11) 11 12 (ex-index 12) 12 13 (ex-index 13) 13 14 (ex-index 14))) #f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat (cond ((and (evil-visual-state-p) evil-ex-visual-char-range (memq (evil-visual-type) '(inclusive exclusive))) "`<,`>") ((evil-visual-state-p) "'<,'>") (current-prefix-arg (let ((arg (prefix-numeric-value current-prefix-arg))) (cond ((< arg 0) (setq arg (1+ arg))) ((> arg 0) (setq arg (1- arg)))) (if (= arg 0) "." (format ".,.%+d" arg))))) evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>)(nil) apply(#f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil) (let ((completion-in-region-function #'completion--in-region)) (apply orig-fn args)) +ivy--inhibit-completion-in-region-a(#f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil) apply(+ivy--inhibit-completion-in-region-a #f(compiled-function (&optional initial-input) (interactive (list (let ((s (concat ... evil-ex-initial-input))) (and (> (length s) 0) s)))) #<bytecode -0x1f4f683ad84e3442>) nil) evil-ex(nil) funcall-interactively(evil-ex nil) call-interactively(evil-ex nil nil) command-execute(evil-ex) ``` # Answer > 1 votes I *presume* you have `global-prettify-symbols-mode` enabled, which is a *globalized* minor mode. They can be a bit tricky. Calling `(prettify-symbols-mode -1)` in `c-mode-hook` wouldn't work because the mode isn't being enabled until *later*. Using `(setq prettify-symbols-alist '())` in `c-mode-hook` *might* work? It won't prevent the buffer-local mode being enabled, but it might stop it *doing* anything? `turn-on-prettify-symbols-mode` decides whether to enable the buffer-local mode, and it checks `(local-variable-p 'prettify-symbols-alist)`; so rather than setting the local value to an empty list, you might instead want to `(kill-local-variable 'prettify-symbols-alist)` Don't use lambdas in hooks, though -- you might leave the old code in the hook inadvertently. I suggest purging your existing functions from the hook, and then making a named function. Untested, but try this: ``` (defun my-c-mode-hook () "Custom `c-mode' behaviours." ;; Inhibit `global-prettify-symbols-mode'. (kill-local-variable 'prettify-symbols-alist)) (add-hook 'c-mode-hook #'my-c-mode-hook :append) ``` Whether it actually works might depend on exactly what is setting that alist in the first place; but if it's another use of `c-mode-hook`, then hopefully the APPEND argument is sufficient to ensure that you act later than it does. --- Tags: hooks, prettify-symbols-mode, doom, c-mode ---
thread-60138
https://emacs.stackexchange.com/questions/60138
Can a transient suffix have a value like an infix?
2020-08-14T09:47:59.973
# Question Title: Can a transient suffix have a value like an infix? I'm writing a transient for invoking debchange. It has a number of regular options like `--multimaint` which I am adding infixes for, and then a handful of mutually exclusive options like `--append` of which one must be specified. I would like to make these suffixes without defining a whole pile of wrappers like `(debchange-append)`; can I somehow give the suffix a value so that I can use the same `(debchange-run)` command for all of them? # Answer I did this: ``` (defclass dd-suffix-switch (transient-suffix) ((argument :initarg :argument))) (cl-defmethod transient-infix-value ((obj dd-suffix-switch)) (oref obj argument)) ``` which I can then use as: ``` ("a" "Append" dd-dch :class dd-suffix-switch :argument "--append") ``` EDIT: Whoops, this doesn't work after all, I get *all* of my suffixes. > 1 votes --- Tags: transient-library ---
thread-60136
https://emacs.stackexchange.com/questions/60136
How to check if the cursor is inside an org-mode "src" block?
2020-08-14T08:22:06.400
# Question Title: How to check if the cursor is inside an org-mode "src" block? I'd like to know if a `point` is inside an org-mode `src` block, so I can disable spell checking. Is there a fast way to programmatically check this? # Answer EDIT: As @jagrg points out in a comment, there is a function for that: `org-in-src-block-p` whose doc string says: > (org-in-src-block-p &optional INSIDE) > > Whether point is in a code source block. When INSIDE is non-nil, don’t consider we are within a source block when point is at #+BEGIN\_SRC or #+END\_SRC. Use this method instead of the following answer (which I hope is still useful, so I'll leave it around unless there are objections). Note that if point is on an empty line after a source block, `org-in-src-block-p` still returns t. That is not important for the OP's use (turning off spell checking in `src` block), but it may be important in other cases. If it *is* important, you'll have to do some extra checking, e.g. by using `org-src--on-datum-p`: ``` (and (org-src--on-datum-p (org-element-at-point)) (org-in-src-block-p)) ``` --- \[Original answer follows: basically (unnecessarily) implements `org-in-src-block-p` as described above using lower-level primitives, although the real `org-in-src-block-p` is slightly more complicated than what I describe below.\] Use `org-element-at-point` to parse the local region around point and then make a decision based on what it returns. If I eval `(org-element-at-point)` in a src block, I get a result like this: ``` (src-block (:language "emacs-lisp" :switches nil :parameters nil :begin 135 :end 197 :number-lines nil :preserve-indent nil :retain-labels t :use-labels t :label-fmt nil :value " (setq foo 'bar) " :post-blank 3 :post-affiliated 135 :parent nil)) ``` So all you need to do is check that the first element is `src-block`: ``` (defun org-at-src-block-p () (eq (nth 0 (org-element-at-point)) 'src-block)) ``` Note that if `point` is on empty lines after a src block, it will still return `t`, but when it is on a line with something else on it, it will return `nil`. And of course, you can use the same method to identify other places that you are at, by replacing `src-block` with something else: `example-block`, `verse-block` etc. You can even try `table` or `table-row` to check whether you are in a table, but in that case, you should use the built-in function `org-at-table-p`: the empty line problem mentioned above would need more attention in this case. > 5 votes --- Tags: org-mode ---
thread-47483
https://emacs.stackexchange.com/questions/47483
Org mode bullets
2019-01-29T15:07:16.943
# Question Title: Org mode bullets I am using org-bullets package but the rendering of unicode bullets doesn't seem correct to me. I tried changing the to different fonts without any success. Also I can't find anything related to this issue on internet. Please help me fix this issue. OS : Windows 10 Emacs version : GNU Emacs 26.1 (build 1, x86\_64-w64-mingw32) of 2018-05-30 # Answer I found a thread that has some information about improving the smoothness of fonts on Windows. It sounds like you want to look for a TrueType font. I use Source Code Pro and it looks great on Mac and Linux. > 0 votes # Answer I also had this issue. Perhaps installing source code pro to fix it would work but *why*? My bullets also looked like OPs screenshot and that level of fuzz is far beyond font smoothness issues. It looks like the bullets are a totally different font and indeed I think that is the true problem: The bullets are not being rendered with the default emacs fonts. --- What ended up working for me was customizing the `org-bullets-face-name` option to the actual default font I was using with emacs. For some reason org-bullets was not drawing from the default font/face used in my emacs setup and looks like that is what was happening with OP too. > 0 votes --- Tags: org-mode, microsoft-windows, fonts, unicode ---
thread-60144
https://emacs.stackexchange.com/questions/60144
When working on elisp where to show intermediate values?
2020-08-14T17:55:43.930
# Question Title: When working on elisp where to show intermediate values? I've only recently started diving deeper into elisp. I've been using `message` a lot in the past, much like println or print when in other languages. The trouble I have is that I'm writing elisp to operate on another file in another buffer, and I intend to eventually bind an interactive function which I'd then use when in similar buffers. The problem is then I'm dealing with three buffers in emacs: target buffer, elisp buffer, and the mini-buffer where `message` output goes. The mini-buffer is way to small sometimes. And I'm suspecting there are better ways of doing this kind of work. Is there more of an idiomatic way of developing elisp for new interactive functions? # Answer > 3 votes If you are using messages to yourself while developing then: * That's fine - nothing wrong with using `message`. * You can also define a wrapper for such uses of `message`, which respects a global variable you define. That gives you a quick way to turn such messages on/off or otherwise affect them. * An alternative is to use `debug`, to use the Emacs debugger: + `M-x debug-on-entry` open the debugger whenever a given function is invoked. + `M-x toggle-debug-on-error` toggles whether to enter the debugger when an error is raised. + You can place `(debug)` at various places in your code to create breakpoints there. When that's encountered it opens the debugger at that place. If you use `(debug nil ARG1 ARG2...)` then when the debugger opens it prints the values of the arguments, `ARG1`, etc. Otherwise, you can just use `e` to evaluate any sexp in the debugger. Use `C-h m` in the debugger to learn more about it. * `edebug` is an alternative to `debug`. For more info about `debug` see the Elisp manual, node Invoking the Debugger for more info. For a broader view, see its parent node, Debugger. For more info about `edebug` see the Elisp manual, node Edebug. You can access the Elisp manual from Emacs, using `C-h i m el TAB RET`. --- Tags: debugging, message, edebug, debug ---
thread-55760
https://emacs.stackexchange.com/questions/55760
How do I prevent the deletion of ~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~ files?
2020-02-25T01:01:46.170
# Question Title: How do I prevent the deletion of ~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~ files? I recently upgraded to Emacs 26.3 from a much older version of Emacs (22.x). One of the many changes I've noticed with Emacs 26.3 is that the `~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~` files are being deleted even when the emacs process is terminated with a SIGHUP, such as when I lose my connection to the remote server where Emacs is running. Is there a way to prevent that? I only want the `~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~` file to be deleted if I intentionally quit Emacs. That is how it worked in older versions of Emacs. I rely on the existence of the `~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~` file to restore my session (i.e., re-open all of the files I had opened previously) whenever my emacs process is terminated. I have a `restart-session.el` that I've been using for over a decade that does this. # Answer > 0 votes I looked through the code, and it's not possible. I submitted a bug report to the Emacs developers about this (bug#39791), but the one that replied didn't seem inclined to agree with me that `~/.emacs.d/auto-save-list/.saves-PID-HOSTNAME~` files should be retained on `SIGHUP`. Another developer suggested I try `desktop-save-mode` instead of relying on these files to restore my terminated sessions. --- Tags: auto-save, emacs26 ---
thread-60150
https://emacs.stackexchange.com/questions/60150
Why can't TRAMP assume current host for `sudo::`?
2020-08-15T01:54:17.583
# Question Title: Why can't TRAMP assume current host for `sudo::`? **Are there any technical reasons or use cases for why `sudo::` in TRAMP cannot use the rightmost host to the left of it, instead of localhost?** When I do `/ssh:myname@my-remote-hostname.example.com|sudo::/tmp/file`, I would expect the `sudo::` to implicitly use `root@my-remote-hostname.example.com`. More generally, when multiple SSH hops are chained together, such as in`/ssh:jumpbox.example.com|ssh:remote.example.com|sudo::/tmp/file`, I would expect the `sudo::` to always use the rightmost host to the left of the `sudo::`. I expect this because **from a user interface and experience perspective**, to me this seems like the obviously more **intuitive** and most **convenient** behavior for it to do. But this does not happen. Instead, `sudo::` seems to always implicitly use root @ the local host. I understand that this is how it is. What I don't understand is why? Are there **technical reasons** for why implementing this would be difficult, or common **use cases** I am not imagining that would be broken if this was implemented? # Answer > 2 votes You'll be happy to learn that in more recent tramp releases (first included in Emacs 27.1) the `::` case will work the way you want it to, such that `/ssh:you@remotehost|sudo::` will re-use `remotehost` rather than your own local hostname, so you won't end up with a bad proxy entry. In addition, the likes of `/ssh:you@remotehost|sudo:localhost:` are detected and flagged as user errors. Of course, if you are liable to use a mixture of Emacs versions, you should continue to treat `::` as unsafe when multi-hopping in general, to avoid potential mishap. -- https://stackoverflow.com/questions/2177687/open-file-via-ssh-and-sudo-with-emacs/16408592#comment94821206\_16408592 --- Tags: tramp ---
thread-60154
https://emacs.stackexchange.com/questions/60154
Why does mousing over one button also highlight adjacent buttons?
2020-08-15T09:10:23.367
# Question Title: Why does mousing over one button also highlight adjacent buttons? I'm using some buttons, and want to arrange them in a row. That is, some will be directly next to each other. I don't want whitespace between them. This is easy enough to do: However, when I do this, mousing over either of them highlights both. I would expect only the moused-over button to be highlighted. Using this code: ``` (progn (insert ?\n) (insert-text-button "one") (insert " ") (insert-text-button "two") (insert " ") (insert-text-button "three") (insert-text-button "four")) ``` Here is a screenshot of what happens when I mouse over a button with whitespace after it. Notice that only "one" is highlighted. And here is a screenshot of what happens when I mouse over a button with a button immediately after it. It highlights the button "three", which is expected, but also the button "four", which is not. How can I make Emacs only highlight "three", the button being moused over? # Answer Buttons are based on text properties. Each character in a buffer has its own properties. Emacs doesn't record start and end positions for properties: properties are not intervals. When it needs to know where a property starts and ends, it looks for the previous or next change in property. Likewise, buttons don't have a recorded start and end: instead all the characters that make up the button have the same button-related properties. Buttons are highlighted when the mouse cursor hovers over them because they have the `mouse-face` property set to `highlight`. Emacs highlights the text extent around the character under the mouse cursor that has the same value for the `mouse-face` property. In your example, when the cursor is over the `h`, the whole text `threefour` gets highlighted since that's as far as the `mouse-face` property has the same value that it has for the `h`. If you want to separate two buttons without having a visual separation, insert a zero-width space between them. ``` (progn (insert ?\n) (insert-text-button "one") (insert " ") (insert-text-button "two") (insert " ") (insert-text-button "three") (insert "\u200b") (insert-text-button "four")) ``` > 7 votes --- Tags: highlighting, text-properties, buttons ---
thread-27079
https://emacs.stackexchange.com/questions/27079
Emacs freezes when minimizing frame on OSX
2016-09-15T00:47:57.667
# Question Title: Emacs freezes when minimizing frame on OSX I have had the issue that emacs will lock up (and need to be force quit) on occasion when I minimize it. I am almost always in org-mode, but otherwise I can see any pattern, except that it happens while it is minimized. I have scoured the world for a fix to this. Does anyone know how to fix this, or at least how to figure out why it is happening? I'm on OSX 10.11 with Emacs 24.5 # Answer I have been using the \`\`not yet stable'' 25-rc2 build of Emacs for a month without any lockup issues. So it seems @lawless is correct, and this did fix the issue. > 2 votes # Answer The issue still exists in the latests stable Emacs 27.1 version. It has been reproduced using a linux machine under the following conditions: * Emacs 27.1 built with Lucid toolkit * Desktop manager: any running Gnome Shell * From your Emacs GUI session hit `C-z` * Comeback to the minimized frame: it is unresponsive The reason is that Mutter, starting from this commit , do not unmap minimized windows. Note that Muffin WM follows the same approach as Mutter; that means, you might see the same issue with Linux Mint. Emacs has applied a patch that will be available in the next release (27.2). > 0 votes --- Tags: osx ---
thread-60107
https://emacs.stackexchange.com/questions/60107
Include lines in tangled source code but not in executed code block
2020-08-13T06:44:05.547
# Question Title: Include lines in tangled source code but not in executed code block The title might be slightly confusing. What I mean is this. Let's say I have a code block which has some error checking code. If there is an error, the (tangled) program should not continue past that point. Let's say I work with python. If I have a source code like this ``` if len(dummy_list) == 0: print("Error!!!") sys.exit(0) ``` Executing this in a code block makes EMACS hang. So I don't want this line to be executed in my source block. But I want this line to be present in the tangled source code. Moreover, it would be great if there was a way to destroy the current running session when I counter an error. Is there a way to achieve this? # Answer You can set the error checking code in a separate code block with headers set to something like ``` :tangle myfile.py :eval never ``` This works because code blocks with the same `:tangle` path are concatenated sequentially into the resulting file. If you are running your Python code in `python` or `ipython` sessions then the evaluations should work even though they are in multiple code blocks. > 2 votes --- Tags: org-mode, org-babel, python ---
thread-58521
https://emacs.stackexchange.com/questions/58521
Org Mode - Use remote table reference in constants
2020-05-15T08:53:13.917
# Question Title: Org Mode - Use remote table reference in constants In https://orgmode.org/manual/References.html remote references are mentioned. Also there are constants for a local environment of a table. I would like to retrieve the value for a constant from the calculations of another table. In a sense it would not be a constant any longer, but in the scope of the table, it would still be a constant. Is such a thing possible? I tried: ``` #+CONSTANTS: hours=remote(other-table-name, @>$5) ``` But it does not seem to work and gives an error in the cell, where I use the constant. # Answer > 2 votes # Defining Constant Values from Remote Org-Table Cell for Use in `#+TBLFM:` ## Initial Setup Create Named Table, e.g. `other-table-name` ``` #+NAME: other-table-name | S | M | T | W | H | F | S | |---+---+---+---+---+---+---| | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ``` ## Method 1 - Dynamically Define `#+CONSTANTS:` using `SRC` Block Results In this example, the programming language used is elisp but `org-mode` can be configured to run source blocks in over 30 programming languages so pick another language you like, if you don't don't want to use elisp. The only requirements for `SRC` block are: 1. `SRC` block `#+RESULTS:` must provide valid `#+CONSTANTS:` declaration, e.g. `#+CONSTANTS: constantname=constantvalue` 2. Add `:results drawer` or `:results raw` headers to `SRC` block so that `org-mode` can interpret the `#+RESULTS:` as org syntax. 3. The constant value must be fetched from cell in named table, e.g. `other-table-name` In this specific example, I used Indexable Variable Values syntax, i.e. `constant-value=other-table-name[2,4]`, to fetch constant value from a specific cell in table. ``` #+NAME: define-constant-with-src-block #+BEGIN_SRC elisp :var constant-name="HOURS" :var constant-value=other-table-name[2,4] :results drawer (format "#+CONSTANTS: %s=%s" constant-name constant-value) #+END_SRC #+RESULTS: define-constant-with-src-block :results: #+CONSTANTS: HOURS=4 :end: #+name: example-table-method-1 | Value of $HOURS from CONSTANTS generated by SRC Block | 4 | #+TBLFM: @1$2=$HOURS ``` ## Method 2 - Use `org-table` Advanced features syntax to create local table constant with value fetched using `remote(other-table-name, @>$5)` ``` #+name: example-table-method-2 | # | Value of $hours fetched from other-table-name | 4 | | $ | | hours=4 | #+TBLFM: @1$3=$hours::@2$3='(format "hours=%s" remote(other-table-name, @>$5)) ``` --- Thank you for asking your question! --- > **The code in this answer was validated using the following:** > **emacs version:** GNU Emacs 27.1 > **org-mode version:** 9.3.7 --- Tags: org-mode, org-table, remote, spreadsheet ---
thread-60007
https://emacs.stackexchange.com/questions/60007
How copy current line to the clipboard?
2020-08-08T09:53:08.710
# Question Title: How copy current line to the clipboard? This Emacs Wiki page says: ``` ‘C-a C-SPC C-e M-w’ copies the current line without the newline. ``` But it doesn't work to me. I'm using Emacs 26. Is there some other shortcut? P.S. I use CUA keys in my Emacs # Answer > 1 votes The function ``` (defun my-line-save () (interactive) (let ((l(substring (thing-at-point 'line)0 -1))) (kill-new l) (message "saved : %s" l))) ``` can do the trick, just assign the keys of your choice ``` (local-set-key (kbd "C-c w") #'my-line-save) ``` or whatever keys you like. # Answer > 3 votes `C-a C-SPC C-e M-w` does work in all versions of Emacs. The only reason it doesn't work for you is that you've changed the key bindings. If you're using a GUI Emacs, you can use `home S-end C-insert` or `Home S-End M-w` instead. This may or may not work in a terminal, depending on how the terminal passes function keys to Emacs. > I'm can't use C-a because this select whole content of buffer This indicates that you're using some third-party package that emulates common line editing packages, badly. Selecting the whole buffer is an extremely uncommon action. It is bad interface design to bind it to an easily-accessible key. I recommend that you stop using this package. If you want Windows-like key bindings like `C-c/C-x/C-v` for copy/cut/paste, Emacs provides CUA mode. I don't recommend using this package because it deviates from standard Emacs key bindings (in particular, `C-c` and `C-x` have very fundamental roles in Emacs), but at least it's a decent interface design, just different from Emacs. # Answer > 0 votes ### Use Shift Key Tip from the manual > To enter an Emacs command like `C-x` `C-f` while the mark is active, use one of the following methods: either **hold Shift together with the prefix key**, e.g., `S-C-x` `C-f`, or quickly type the prefix key twice, e.g., `C-x` `C-x` `C-f`. For your specific example: * **Original Key Chords** `C-a` `C-SPC` `C-e` `M-w` * **Updated Key Chords** `S-C-a` `C-SPC` `C-e` `M-w` --- Tags: text-editing, clipboard ---
thread-60104
https://emacs.stackexchange.com/questions/60104
org export interanl [[links]] to keep link text
2020-08-13T05:47:19.347
# Question Title: org export interanl [[links]] to keep link text When exporting a document such as: ``` * Title Link to [[Title]] ``` The link text is converted to the section number. I.e. > # 1. Title > > Link to **1** Is there a way to keep the link text e.g.: > # 1. Title > > Link to **Title** Without having to write each link as `[[Title][Title]]`? # Answer I don't see an easy way to do this other than by copying the `org-html-link` function from ox-html.el. :-( Find the text `What description to use?`. That's where you want to change the logic: ``` ;; What description to use? (desc ;; Case 1: Headline is numbered and LINK has no ;; description. Display section number. (if (and (org-export-numbered-headline-p destination info) (not desc)) (mapconcat #'number-to-string (org-export-get-headline-number destination info) ".") ;; Case 2: Either the headline is un-numbered or ;; LINK has a custom description. Display LINK's ;; description or headline's title. (or desc (org-export-data (org-element-property :title destination) info))))) ``` This is hacky but you can change this to: ``` ;; What description to use? (desc ;; Case 1: Headline is numbered and LINK has no ;; description. Display section number. (if (and nil ; ← **note the change here** (org-export-numbered-headline-p destination info) (not desc)) (mapconcat #'number-to-string (org-export-get-headline-number destination info) ".") ;; Case 2: Either the headline is un-numbered or ;; LINK has a custom description. Display LINK's ;; description or headline's title. (or desc (org-export-data (org-element-property :title destination) info))))) ``` and then it will never use case 1 (section number) and always use case 2 (link text). > 2 votes --- Tags: org-mode, org-export, org-link ---
thread-60160
https://emacs.stackexchange.com/questions/60160
Getting Helm describe-function/describe-variable’s secondary to work like helm-M-x?
2020-08-15T21:39:34.490
# Question Title: Getting Helm describe-function/describe-variable’s secondary to work like helm-M-x? When you use Helm for `M-x`, you can quickly check the documentation for an `interactive` command before calling it, it using the secondary key (usually `C-z` or `C-j`; I use the latter below). It brings up a background help buffer so you can be sure this is the command you want and you know how any arguments are used. Helm’s help line shows this: `C-j: Describe this command (keeping session)`. It’s a fantastic quality-of-life feature. Unfortunately, it only works for *`interactive` commands*; not for non-interactive functions or variables. When you use `describe-function` (`C-h f`) or `describe-variable` (`C-h v`), this functionality goes away, replaced by nothing. (Literally: the Helm help line reads `C-j: DoNothing (keeping session)`.) I think I understand the motivation for this design: since you’re *in the middle of running* the interactive command to describe a function or variable, the alternate function also describing the function or variable seems redundant. But in reality, when I’m doing Elisp coding, I frequently have used Helm to narrow down my choices of functions or variables to a manageable, but still significant number (say, eight or ten) and I’m not sure which one I want. I’d like to press my secondary key on each to “preview” its documentation¹ before picking the one I want. But instead, my only avenue seems to be using `RET` to complete the describe command, then repeating the search with `C-h f M-p` and navigating to the next one, and so on. (If the thing I’m looking for is a buffer-local variable whose value I’m interested in, that requires even a few more keystrokes.) If you have a number of choices and you really have no idea which one is right, it’s easy to lose track of your place (particularly after you’ve looked at a few) and repeat one you’ve already looked at—or inadvertently skip one—since you have to start at the top of the list again each time. In Helm’s GitHub issues, there was a query about this, but the solution proposed—of simply assigning the describe function to the secondary key—results in an (interruptible) hang from infinite recursion. So how can I achieve this? --- ¹ A “preview” sounds like I may want something different from what you get from the description—a synopsis (as you can get from interactives’ doc strings). But I just want to see the description in another buffer while keeping the Helm session open. # Answer > 1 votes You should use `M-x helm-apropos` (in the `helm-elisp.el` library), which you can use to describe commands, functions, variables and faces. Pressing `C-j` shows a preview of the documentation. --- Tags: helm, customize, help, documentation ---
thread-60166
https://emacs.stackexchange.com/questions/60166
`org-bibtex` is no longer found automatically
2020-08-16T05:05:15.117
# Question Title: `org-bibtex` is no longer found automatically I am getting the following warning message since I have upgraded to GNU Emacs 27 on Mac. I have been using Emacs for `org-mode`. It's my understanding that `org-bibtex` should be a part of GNU Emacs, I don't know why `org-bibtex` cannot be loaded. ``` Warning (initialization): An error occurred while loading ‘/Users/euijeong/.emacs’: File is missing: Cannot open load file, No such file or directory, org-bibtex ``` # Answer > 3 votes In version 9.3 `org-bibtex` has been renamed `ol-bibtex` with all the link-related libraries, see this commit in the source code repository. You have to make the same change in your `.emacs`, if you want to support different org versions you have to check the value of the variable `org-version`. --- Tags: org-mode, org-export, emacs27 ---
thread-60120
https://emacs.stackexchange.com/questions/60120
Debugging ELPA and Emacs connection issues behind a corporate proxy
2020-08-13T15:51:42.037
# Question Title: Debugging ELPA and Emacs connection issues behind a corporate proxy I'm having trouble getting to ELPA behind our corporate proxy. I see proxy traffic attempting to `CONNECT` to the ELPA domain which then fails. How can I turn on debugging to see the exact URL that Emacs is trying to access? `-debug-init` didn't work for me with Emacs 27.1 # Answer There is a variable for debugging URL calls, `url-debug`, set it to true: ``` (setq url-debug t) ``` Use the function `url-retrieve-synchronously`, this will create a debug buffer called ***URL-DEBUG\*** and there you can see all the debug output from the call: ``` (url-retrieve-synchronously (url-generic-parse-url "https://elpa.gnu.org/")) ``` > 1 votes --- Tags: package-repositories, proxy ---
thread-60171
https://emacs.stackexchange.com/questions/60171
Function to undo point excursion
2020-08-16T13:33:32.373
# Question Title: Function to undo point excursion I know that I can use `save-excursion` to avoid changes to `(point)`, is there a similar function to revert excursion based on the value of BODY. For example: ``` (revert-excursion BODY) ``` would revert the excursion if `BODY` evaluates to `nil` otherwise the new value of `(point)` is maintained. I could of course do this by saving the previous `(point)` and using `(goto-char)` conditionally, or by executing `BODY` twice (one to evaluate its value and the second to actually move `(point)`. But I am wondering if there are better ways. # Answer I think your first idea is the best: ``` ... (goto-char (let ((pt (point))) (save-excursion (if BODY (point) pt))))) ``` You could probably write a macro for it. Evaluating BODY twice is not a good idea: it may have side-effects that make it non-idempotent, and/or it may be expensive to evaluate. > 1 votes --- Tags: point, save-excursion ---
thread-60175
https://emacs.stackexchange.com/questions/60175
parse-time-string: doesn't accept ISO 8601 string contrary to what the documentation claim
2020-08-16T16:51:43.913
# Question Title: parse-time-string: doesn't accept ISO 8601 string contrary to what the documentation claim The documentation suggests that `parse-time-string` can be fed ISO 8601 string, such as "1998-09-12T12:21:54-0200". However, `(parse-time-string "1998-09-12T12:21:54-0200")` returns `(nil nil nil nil nil nil nil nil nil)`. > — Function: `parse-time-string string` > > This function parses the time-string string into a list of the following form: > > `(sec min hour day mon year dow dst tz)` > > The format of this list is the same as what decode-time accepts (see Time Conversion), and is described in more detail there. Any element that cannot be determined from the input will be set to nil. The argument string should resemble an RFC 822 (or later) or **ISO 8601 string**, like “Fri, 25 Mar 2016 16:24:56 +0100” or “**1998-09-12T12:21:54-0200**”, but this function will attempt to parse less well-formed time strings as well. Related question: Parsing formatted time string (inverse of format-time-string) **EDIT**: GNU Emacs 26.3 (build 1, x86\_64-pc-linux-gnu, GTK+ Version 3.24.8, cairo version 1.16.0) of 2020-01-13 # Answer EDIT: This bug was reported as bug 39001 and fixed in this commit in upstream emacs. The patch to apply can be found here. Workaround: The function `parse-iso8601-time-string` does parse ISO8601 string but eventually encode it with `encode-time`. The following snippet does what `parse-time-string` was supposed to do. ``` (decode-time (parse-iso8601-time-string "1998-09-12T12:21:54-0200")) ``` returns `(54 21 16 12 9 1998 6 t 7200)` **Note**: The value returned is partially wrong (the last three fields) because ``` (format-time-string "%Y" (decode-time (parse-iso8601-time-string "1998-09-12T12:21:54-0200"))) ``` is evaluated as `1970`. **TODO**: advice `parse-time-string` to check if its argument `string` matches `parse-time-iso8601-regexp`, if it does, apply the snippet above. > 1 votes --- Tags: time-date, parse-time ---
thread-60182
https://emacs.stackexchange.com/questions/60182
Don't show "." and ".." in counsel-find-file
2020-08-16T22:19:45.383
# Question Title: Don't show "." and ".." in counsel-find-file I have a thing where I just don't like editing directories in emacs, and I never want to enter dired mode. Any time anything might want to put me into dired mode, I would prefer it not do that and instead do something else useful or else do nothing at all (perhaps there could be some obscure keypress to edit the directory). In particular one thing that annoys me about the otherwise excellent ivy / `counsel-find-file` is that it always shows "`.`" and "`..`" as the first two entries in any completion buffer. If I happen to hit `TAB` twice (maybe I'm over-zealously completing from the last directory) it will open dired on the local directory. Ideally I'd like way to tell `counsel-find-file` it should never open a directory (maybe unless I use immediate-open). But if not that, I'd at least like a way to tell it to never display the "`.`" and "`..`" entries. These take up useful screen space that could be showing actual files I might want to visit. Or if not that, then at least sort those entries at the bottom of the list instead of the top. How can I do this? # Answer You can hide those entries with `(setq ivy-extra-directories nil)`. > 5 votes --- Tags: find-file, ivy, counsel ---
thread-60186
https://emacs.stackexchange.com/questions/60186
Error running timer (wrong-number-of-arguments equals 3)
2020-08-17T10:26:11.603
# Question Title: Error running timer (wrong-number-of-arguments equals 3) I am trying to automatically change my Emacs theme according to time set (Thanks to answer provided by Dan). My code looks like this: ``` (setq emacs-curr-theme nil) (setq emacs-light-theme 'faff) (setq emacs-dark-theme 'atom-one-dark) (defun emacs-synchronize-theme () (let ((hour nil) (now nil)) (progn (setq hour (string-to-number (substring (current-time-string) 11 13))) (if (member hour (number-sequence 7 13)) (setq now emacs-light-theme) (setq now emacs-dark-theme)) (if (equal now emacs-curr-theme now) nil (progn (setq emacs-curr-theme now) (load-theme emacs-curr-theme t)))))) (defun emacs-set-theme () ;; Load theme only when using GUI (when (display-graphic-p) (run-with-timer 0 900 'emacs-synchronize-theme))) ``` When I am calling the function `emacs-set-theme` from my `init.el`, I am getting this error - ``` Error running timer 'emacs-synchronize-theme': (wrong-number-of-arguments equal 3) ``` I have no clue what I am doing wrong here. I have checked documentation for `run-with-timer`, but unable to figure out the problem by myself. # Answer > 0 votes Your error is: `(equal now emacs-curr-theme now)` As `equal` takes two arguments, not three. I used `M-x` `toggle-debug-on-error` before running your code to find that quickly: ``` Debugger entered--Lisp error: (wrong-number-of-arguments equal 3) (equal now emacs-curr-theme now) (if (equal now emacs-curr-theme now) nil (progn (setq emacs-curr-theme now) (load-theme emacs-curr-theme t))) (progn (setq hour (string-to-number (substring (current-time-string) 11 13))) (if (member hour (number-sequence 7 13)) (setq now emacs-light-theme) (setq now emacs-dark-theme)) (if (equal now emacs-curr-theme now) nil (progn (setq emacs-curr-theme now) (load-theme emacs-curr-theme t)))) (let ((hour nil) (now nil)) (progn (setq hour (string-to-number (substring (current-time-string) 11 13))) (if (member hour (number-sequence 7 13)) (setq now emacs-light-theme) (setq now emacs-dark-theme)) (if (equal now emacs-curr-theme now) nil (progn (setq emacs-curr-theme now) (load-theme emacs-curr-theme t))))) emacs-synchronize-theme() apply(emacs-synchronize-theme nil) timer-event-handler([t 24378 24806 149715 900 emacs-synchronize-theme nil nil 39000]) ``` --- Tags: timers, error ---
thread-60188
https://emacs.stackexchange.com/questions/60188
How do I stop magit popups on commit?
2020-08-17T12:15:21.547
# Question Title: How do I stop magit popups on commit? When I do a commit, magit popups the diff in a separate wm window. I'd like it to show the diff in the same wm window and just split into a different wm window. I've tried this answer, but it hasn't worked. magit 20200805.1104 emacs 26.3 # Answer > 1 votes I think you are looking for the `magit-display-buffer-function` option. --- Tags: magit, popup ---
thread-60183
https://emacs.stackexchange.com/questions/60183
How to append spaces to align by next word in the line above
2020-08-17T03:42:26.430
# Question Title: How to append spaces to align by next word in the line above I am looking for a function helping indenting imports. I noticed following pattern. Origin file: ``` import A.B.C (x, y, z) ``` Result file: ``` import qualified A.B.C (x, y, z) import Z.X.Y (a, b, c) ``` After typing import I need to insert arbitrary number of spaces to align Z.X.Y with A.B.C and parenthesis expressions with line above. Doing this manually is tedious. I could spend a day to write such function, but I bet it must be already implemented by somebody. # Answer If you know where Z.X.Y and the parenthesis are going to appear, you can do e.g. ``` (setq tab-stop-list '(20 40)) ``` and then use `M-i` to insert spaces until you've reached a position in that list. If you want to make this context dependent, then something like the following would work: ``` (save-excursion (goto-char (point-min)) (let (tsl) (while (re-search-forward " [^ ]" (point-at-eol) t) (push (- (point) 2) tsl)) (when tsl (setq tab-stop-list (reverse tsl))))) ``` Adjust the `goto-char` bit as necessary to ensure you're looking at the right line. > 1 votes --- Tags: indentation ---
thread-60127
https://emacs.stackexchange.com/questions/60127
How can I find my Emacs init file?
2020-08-14T00:00:06.900
# Question Title: How can I find my Emacs init file? I have read the guide found here: How Emacs Finds Your Init File I cannot find any `.emacs` directory in my home directory. I have `show hidden files` selected. I also cannot find the `init.el` file in Emacs home directory. Since I have been unable to find the `init.el` file, is it reasonable to think there isn't one? I am using Emacs 27.1 on Windows 10. Except for Emacs home directory I installed with the defaults. I used no command-line options during install. I seem to remember I have once read a post which explained Emacs has an internal variable which is used to hold the value of the location of where Emacs found the `init.el` file after it starts, but after searches I have been unable to find what that variable is. How can I find my `init.el` file, having failed to locate it in the locations mentioned in the manual? Does a variable exist which says where the `init.el` file was found? If so, what is it? # Answer This answer specifically address the question of how/where to find Emacs' `user-init-file` on Microsoft Windows. ## HOME and Startup Directories on MS-Windows Here is the relavent section from the Emacs manual (available via `C-h i`) Emacs \> Microsoft Windows \> Windows Home > The Windows equivalent of `HOME` is the `user-specific application data directory`. The actual location depends on the Windows version; ... `C:\Users\USERNAME\AppData\Roaming` on Windows Vista and later ... If this directory does not exist or cannot be accessed, Emacs falls back to `C:\` as the default value of ‘HOME’. This location is stored in the environment variable that windows refers to as `%APPDATA%`. See this question and answer on `superuser` You can try to find the location of your `user-init-file` by doing `C-h v` and then `user-init-file [RET]`. You will see an output similar to ``` ~/.emacs ``` On Windows this isn't particularly helpful. We can now find out what Emacs means by `~` doing one of the following: `C-x C-f` \> `~` \> `[backspace]` The `echo` area at the bottom of your Emacs screen will expand to show you what Emacs currently consider to be HOME. (Note that this works on Windows and according to @NickD doesn't work on GNU/Linux) OR more generally (quoting from the Emacs manual) > You can always find out what Emacs thinks is your home directory’s location by typing `C-x d ~/ <RET>`. This should present the list of files in the home directory, and show its full name on the first line. Likewise, to visit your init file, type `C-x C-f ~/.emacs <RET>` (assuming the file’s name is `.emacs`). --- ## Setting up the `init.el` on Windows Instead of keeping a `.emacs` file most emacs users now use an `init.el` file stored in your `user-emacs-directory`. This directory defaults to `~/.emacs.d` and in your case `%APPDATA%/.emacs.d/`. Assuming you don't already have a `.emacs` file stored in `%APPDATA%/` You can now go ahead and create an `init.el` file *inside* the `.emacs.d` directory. Put some sample configuration in your `init.el` file and see if Emacs picks it up when you re-start Emacs. Also see this this answer on Emacs Stackexchange. > 14 votes # Answer The variable is `user-init-file`. Its doc string says: > File name, including directory, of user’s initialization file. If the file loaded had extension ‘.elc’, and the corresponding source file exists, this variable contains the name of source file, suitable for use by functions like ‘custom-save-all’ which edit the init file. While Emacs loads and evaluates any init file, value is the real name of the file, regardless of whether or not it has the ‘.elc’ extension. EDIT: If the value of the variable is non-nil, as in your case, it means that it actually found the file `~/.emacs` somewhere, somehow. I don't know much about Windows, but if you look in what you think is your home directory and cannot find a file called `.emacs`, it might be that some translation is going on. ISTR, that in some cases, on Windows, the file name was `_emacs`, but that was a long time ago, in a universe far, far away, and I may very well be wrong. See if this link helps: it describes how the HOME directory is determined on Windows. Also, the method that @minibuffer describes in a comment might well be the best way to find the file: do `C-x C-f ~/ RET` and look at the pathname at the top of the directory listing (this is slightly different from what the comment describes, but I couldn't get the `backspace` method to work for me: it just deletes the `~` in the prompt - but this is on Linux, and Windows may behave differently). > 8 votes # Answer You can create or open an an existing init file when opening ~/.emacs or ~/.emacs.d/init.el. ~ is a macro character which expand to the correct directory. On a fresh install you have to create an init file. > 1 votes --- Tags: init-file ---
thread-60195
https://emacs.stackexchange.com/questions/60195
How can I get swiper to remember the last search I ran?
2020-08-17T16:57:57.240
# Question Title: How can I get swiper to remember the last search I ran? Sometimes I do a search with swiper and navigate to a location in the code that seems like what I was searching for, only to find it wasn't. This is more common with a symbol name that is a little too generic. I'd like to simply restart the search, but I have to type the full symbol again. I could copy/yank the symbol, which would be fine, but even that could be automated, as in: "search for thing under point." I'd probably want that too, but first thing: I'd just like to repeat the previous search. How can I do that without having to re-type the criteria? Or have swiper remember the last search? # Answer `C-s` after calling swiper will bring up the last search. `M-p` will iterate back through the search history. `M-n` will do the same the other way. If you followed the installation instructions and used the proposed bindings, `swiper-isearch` is bound to `C-s`, so `C-s C-s` will do what you want with zero effort. As @NickD pointed, Swiper is an isearch replacement, most you did using isearch, will work with swiper. On the secondary question, searching for "*thing at point*", you can choose between: * using `C-s M-j` (assuming that `C-s` calls swiper), it'll insert the current subword in the minibuffer. * writing a custom function which is basically a matter of using `thing-at-point` over what you find more useful, putting it into the completion list then `funcall` swiper or the other commands. `Swiper`'s author provided the example code here Finally, reading the docs always worth the time spent doing it, usually saves unnecesary headaches. > 1 votes --- Tags: search, swiper ---
thread-60202
https://emacs.stackexchange.com/questions/60202
Error "Unknown option `AUTO' for package `fontspec-luatex' " when exporting from org to pdf with lualatex
2020-08-18T08:22:24.303
# Question Title: Error "Unknown option `AUTO' for package `fontspec-luatex' " when exporting from org to pdf with lualatex When exporting a org file to pdf with `lualatex`, I get the message *PDF file produced with errors.* in my minibuffer. Upon inspection, I find ``` ! LaTeX Error: Unknown option `AUTO' for package `fontspec-luatex' ``` in my LaTeX output. Why is that? In my configuration, I have `(setq org-latex-compiler "lualatex")` and there is `("AUTO" "fontspec" t ("xelatex" "lualatex")` in `org-latex-packages-alist`. From what I understand, whatever option should passed to fontspec should be determined automatically. # Answer > 1 votes AFAIK, `AUTO` is only used in two cases: for the package `inputenc` where it is replaced by the appropriate coding system, and for the package `babel` (or `polyglossia`) where it is replaced by the appropriate language. It is not a general method of "automaticaly determining options" to an arbitrary package. Try replacing it with the empty string (or the actual `fontspec` options) in `org-latex-packages-alist`. In no case, should the resulting `.tex` file *ever* contain `AUTO` as an option to a package. --- Tags: org-mode, org-export, latex ---
thread-60204
https://emacs.stackexchange.com/questions/60204
org-mode: Set maximum image width limit
2020-08-18T13:15:49.597
# Question Title: org-mode: Set maximum image width limit Using `org-image-actual-width` will both downscale and upscale. I just want to downscale big images to fit the current width. Any ideas? # Answer > 0 votes The doc string for `org-image-actual-width` says (among other things): > When set to nil, try to get the width from an #+ATTR.\* keyword and fall back on the original width if none is found. So set it to nil and specify the width with an `#+ATTR` keyword only for the big images that you want to downscale. More info can be found in the manual in the `Exporting` chapter, in section Images for HTML export and section Images in LaTeX export. --- Tags: org-mode, images, inline-image ---
thread-38480
https://emacs.stackexchange.com/questions/38480
Diminish flyspell
2018-01-30T22:58:34.387
# Question Title: Diminish flyspell How can I diminish flyspell-mode (the one built-in to emacs)? With use-package, none of the following work: ``` (use-package flyspell-mode :diminish) (use-package flyspell-mode :diminish 'flyspell-mode) (use-package flyspell-mode :config (eval-after-load "flyspell". '(diminish 'flyspell-mode))) ``` I would like to diminish flyspell-mode everywhere, but particularly in org buffers. This is the full package configuration: ``` (use-package flyspell-mode :init (setq flyspell-issue-message-flag nil) :hook ; Enable flyspell in specific modes (text-mode org-mode change-log-mode-hook log-edit-mode-hook) :diminish 'flyspell-mode ) ``` # Answer > 1 votes I was also trying to find a solution to this problem. It appears that adding this to my init solves it: ``` (setq flyspell-mode-line-string nil) ``` Inspecting `minor-mode-alist`, it turns out that for `flyspell-mode` its value is set to `flyspell-mode-line-string`. ``` Value: ((diff-minor-mode " Diff") (flyspell-mode flyspell-mode-line-string) (ispell-minor-mode " Spell") (highlight-indent-guides-mode #1="") ``` I think this "confuses" `diminish`, and hence, the mode is not "diminished". # Answer > 1 votes Use the following: ``` (use-package flyspell :diminish 'flyspell-mode) ``` It wants the mode that is provided by `flyspell`, which is called `flyspell-mode`. Without `use-package`: ``` (require 'flyspell) (diminish 'flyspell-mode) ``` --- Tags: mode-line ---
thread-60209
https://emacs.stackexchange.com/questions/60209
trouble installing some packages from MELPA... premature EOF parsing tar file
2020-08-18T20:42:27.740
# Question Title: trouble installing some packages from MELPA... premature EOF parsing tar file I am running into trouble installing `smart-mode-line` and `ox-hugo`. I use `M-x list-packages`, select package I want with `I`, and then execute with `X`. The error in Messages buffer looks like: ``` Contacting host: melpa.milkbox.net:80 Parsing tar file... Warning: premature EOF parsing tar file package-untar-buffer: Package does not untar cleanly into directory smart-mode-line-20190527.1156/ ``` But, I didn't have a problem updating `org` package. I tried this with Emacs 26.3 and 27.1.1 (both from emacsformacosx.com) on macOS. The problem is similar to one reported here almost a year ago. Any suggestions please? # Answer > 1 votes I was just now able to install that package, so everything seem fine to me. However, I notice that you've configured Emacs to contact `melpa.milkbox.net`. That url was replaced with just `melpa.org` about five years ago. You'll probably want to revise your configuration: ``` (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) ``` --- Tags: package-repositories, install ---
thread-60119
https://emacs.stackexchange.com/questions/60119
Auto insert include guard in cpp header when inside projectile project
2020-08-13T14:44:45.677
# Question Title: Auto insert include guard in cpp header when inside projectile project I am currently learning C++ and I came across include guards to avoid double inclusion. Now I would like to use the google's style convention like this : ``` // project/src/app.hpp #ifndef PROJECT_SRC_APP_HPP_ #define PROJECT_SRC_APP_HPP_ ... #endif // PROJECT_SRC_APP_HPP_ ``` and also ``` // project/src/util/test.hpp #ifndef PROJECT_SRC_UTIL_TEST_HPP_ #define PROJECT_SRC_UTIL_TEST_HPP_ ... #endif // PROJECT_SRC_UTIL_TEST_HPP_ ``` So the macro name is basically the path of the header file in the current project. My goal is to automate this task of writing the include guards each time I create a new `.hpp` file. I looked at the emacs auto insert mode which looks adapted to the situation but the question is the following : I am using projectile so how can I get the full path from the root directory of the current project to construct the macro name? Can anyone point me into the right direction? (btw I am using spacemacs) # Answer Thanks to f-sasa, I was able to write my own yasnippet file in order to construct the include guard. With the help of this yasnippet example and also this thread about getting the projectile file path : ``` # key: include_guard # name: C++ auto header include guard in project # -- #ifndef ${1:`(upcase (concat (projectile-project-name) "_" (subst-char-in-string ?/ ?_ (file-relative-name (file-name-sans-extension buffer-file-name) (projectile-project-root)))))`_HPP_} #define $1 $0 #endif /* $1 */ ``` > 3 votes --- Tags: spacemacs, projectile, c++, auto-insert, file-header ---
thread-60199
https://emacs.stackexchange.com/questions/60199
C-x C-f, Cannot complete file name for desktop folders
2020-08-17T21:17:53.370
# Question Title: C-x C-f, Cannot complete file name for desktop folders I am new to Emacs. I am trying to access a file in the `"Emacs"` folder on my desktop. I run the `C-x C-f` command, then type `~/Desktop/Em`. I then hit `TAB`, but there's no completion. Emacs says `[No Match]`. Could someone please explain why the file name doesn't complete? I am working on Mac OS 10.15.6. # Answer Following from Drew's response (which also works). I found another answer that solved my issue using Emacs from the Mac launcher bar: https://apple.stackexchange.com/questions/371888/restore-access-to-file-system-for-emacs-on-macos-catalina > 0 votes --- Tags: osx, find-file ---
thread-60215
https://emacs.stackexchange.com/questions/60215
Default font selection behaves strangely
2020-08-19T01:28:02.047
# Question Title: Default font selection behaves strangely After upgrading to Emacs 27.1, my default font changed to adobe courier. I would like to use Anonymous Pro or Inconsolata, but attempts to change it using `M-x customize-face RET default` fail. I am at a loss to describe the behavior as it seems to me irregular and I am not sure where to begin. Setting it to Anonymous Pro or Inconsolata, which so far as I can tell are in fact installed on my system and go by those names, causes the font to fall back to a serif font that looks like times. I am using the KDE Font Management utility to see what fonts are installed. Running `xfontsel` to look at which fonts are installed gives a different list, but entering information from it produces indeterminate effects---the font does change, but I can't tell if it's falling back to courier or a default serif font. So far as I can tell, it usually does make the right change, which I can test for instance if I use `etl` for the foundry and `fixed` for the family. The emacs font matches what that font looks like in the xfontsel menu. So---as should be clear---not sure where to begin troubleshooting. I'm using Emacs 27.1, on OpenSuse Leap 15.2, KDE. # Answer > 0 votes I found a "solution"---the problem has been fixed, although I don't know why. Maybe this will help someone else experiencing this kind of instability. Tinkering, I used `S-down mouse-1` as instructed at the EmacsWiki Set Fonts page. Emacs crashed when I selected Anonymous Pro. I deleted the desktop on general principle. After I restarted emacs, I could select Anonymous Pro using `S-down mouse-1` to change the face in a buffer. Then I could set it persisently as the default face using customize. --- Tags: fonts, emacs27 ---
thread-60198
https://emacs.stackexchange.com/questions/60198
font-lock-add-keywords is not working
2020-08-17T19:19:28.457
# Question Title: font-lock-add-keywords is not working So I've been trying to add custom syntax highlighting for digits using `font-lock-add-keywords` and regex. I've been looking at all the Emacs resources to do this, and while I have been able to successfully define a face, `font-lock-add-keywords` has not been working for any apparent reason. I have even copied the examples from different sources and directly tried to get them to work with no apparent success. I can't seem to figure out what's wrong with my code. I'm not receiving any errors, but when I try to eval the `font-lock-add-keywords` (with `C-x C-e`), it prints `nil` in the `*Messages*` buffer. **Update** I took Gilles advice and created a minor mode, set `font-lock-add-keywords` to that custom minor mode, and used a quote for the face. While I can see the minor mode in the mode line and know that it's working, `font-lock-add-keywords` still does not seem to work. Here is my updated code: ``` (defgroup gio-group nil "Group for customization" :prefix "gio-") (defface gio-highlight-numbers-face '((t :inherit (default) :foreground "#ffff00")) "Face for numbers" :group 'gio-group ) (define-minor-mode gio-minor-mode "Minor mode for customizaion" :init-value t :lighter " GioMode" :global t :group 'gio-group) (font-lock-add-keywords 'gio-minor-mode '(("[0-9]+" . 'gio-highlight-numbers-face))) ``` I'm running GNU Emacs 26.3 (build 1, x86\_64-w64-mingw32) on Windows 10. Any help is much appreciated! Thank you! # Answer > 2 votes With further research and some help from comments from Gilles and Lindydancer, I discovered that you cannot add Font Lock keywords to minor modes. Instead, you have to add and remove the keywords to the major mode when the minor mode is loaded and unloaded. Here is the working code that highlights the keywords using a minor mode: ``` (defgroup gio-group nil "Group for customization" :prefix "gio-") (defface gio-highlight-numbers-face '((t :inherit (default) :foreground "#ffff00")) "Face for numbers" :group 'gio-group ) (defvar gio-keywords '(("\\(\\b\\|[-]\\)\\([-]?\\([0-9]+\\)\\(\\.?[0-9]\\)*\\)\\b" . 'gio-highlight-numbers-face)) ;; Integers & Decimals "Keywords for gio-minor-mode highlighting") (define-minor-mode gio-minor-mode "Minor mode for customization" :init-value 1 :lighter " GioMode" :group 'gio-group (when (bound-and-true-p gio-minor-mode) (font-lock-add-keywords nil gio-keywords) (font-lock-fontify-buffer)) (when (not (bound-and-true-p gio-minor-mode)) (font-lock-remove-keywords nil gio-keywords) (font-lock-fontify-buffer))) (define-globalized-minor-mode gio-global-minor-mode gio-minor-mode gio-minor-mode :group 'gio-group) (gio-global-minor-mode 1) ``` # Answer > 1 votes `font-lock-add-keywords` adds keywords for a specific major mode, such as Lisp mode or C mode or HTML mode. Since `font-lock-mode` is not a major mode `(font-lock-add-keywords 'font-lock-mode …)` never has any effect. If you really want font lock keywords that apply in every major mode, you need to define a minor mode. That's how Whitespace mode works. A lot of Whitespace mode is more complicated than what you need. You could perhaps add a “digit highlight” setting to whitespace mode, but it might be easier to define your own mode. The convenience function `define-minor-mode` helps, but you still need to add and remove the keywords manually when the mode is turned on or off, by calling `(font-lock-add-keywords nil …)` and `(font-lock-remove-keywords nil …)`. See Can I add highlighting in a minor mode? for instructions. In addition, there's a gotcha in how faces work: a face name is a symbol which is not a variable. The `(MATCHER . FACESPEC)` form of `font-lock-keywords` requires `FACESPEC` to be an expression whose value specifies a face. `custom-faces-highlight-numbers-face` doesn't work because it isn't a valid expression since the symbol `custom-faces-highlight-numbers-face` is not bound. There are two solutions to this. The traditional solution is to define a variable with the same name as the face; that's how it works for the faces that Font Lock mode defines, but > Note that in new code, in the vast majority of cases there is no need to create variables that specify face names. Simply using faces directly is enough. Font-lock is not a template to be followed in this area. The recommended but cumbersome solution is to quote the symbol. ``` (font-lock-add-keywords 'gyo-highlight-numbers-mode '(("[0-9]+" . 'custom-faces-highlight-numbers-face))) ``` --- Tags: font-lock, syntax-highlighting ---
thread-60219
https://emacs.stackexchange.com/questions/60219
How to set org-mode header properties globally?
2020-08-19T12:20:13.173
# Question Title: How to set org-mode header properties globally? I am trying to set the following org-mode tangle property (mkdirp), which > creates parent directories for tangled files if the directory does not exist. A ‘yes’ value enables directory creation whereas ‘no’ inhibits it. Apparently, it makes sense to set it for all relevant code blocks. My question is: *Is there a way to set a header property/argument like this globally for the entire .org file?* # Answer > 12 votes File-level properties can be set like this: `#+PROPERTY: header-args :mkdirp yes` Language-specific arguments can be set with this syntax (setting property `p1` to value `v1`): `#+PROPERTY: header-args:lang :p1 v1` If you want to add properties without resetting everything else to default, use `lang+`, as in the following - it doesn't modify the previously set `p1` when setting `p2`. Without the `+`, `p2` would be set, but `p1` would revert to the default value `#+PROPERTY: header-args:lang+ :p2 v2`. File-level properties need to be evaluated (`C-c C-c` on the line, or close and re-open the buffer) to take effect. Finally, rather than file-level, you can set properties at each `* Header` level with the `PROPERTIES` drawers: ``` * Header :PROPERTIES: :header-args:lang: :property_1 v1 :property_2 v2 :header-args:lang+: :property_n value_n :END: ``` These take effect immediately, and do not need to be evaluated. See https://orgmode.org/manual/Property-Syntax.html for details --- Tags: org-mode ---
thread-51812
https://emacs.stackexchange.com/questions/51812
company-lsp complains about void function lsp--client-completion-in-comments
2019-07-24T04:25:34.037
# Question Title: company-lsp complains about void function lsp--client-completion-in-comments my emacs lsp-python setup is pretty standard: ``` (require 'lsp-mode) (add-hook 'python-mode-hook #'lsp) (require 'company-lsp) (push 'company-lsp company-backends) (add-hook 'after-init-hook 'global-company-mode) ``` but if set debug-on-error to t, i got the following whenever pausing during typing (guess it's when company is called up). what's causing this problem? ``` Debugger entered--Lisp error: (void-function lsp--client-completion-in-comments\?) (lsp--client-completion-in-comments\? (progn (or (and (memq (type-of it) cl-struct-lsp--workspace-tags) t) (signal (quote wrong-type-argument) (list (quote lsp--workspace) it))) (aref it 6))) (setq needle (lsp--client-completion-in-comments\? (progn (or (and (memq (type-of it) cl-struct-lsp--workspace-tags) t) (signal (quote wrong-type-argument) (list (quote lsp--workspace) it))) (aref it 6)))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? (progn (or (and (memq (type-of it) cl-struct-lsp--workspace-tags) t) (signal (quote wrong-type-argument) (list (quote lsp--workspace) it))) (aref it 6))))) (let ((it (car list))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? (progn (or (and (memq ... cl-struct-lsp--workspace-tags) t) (signal (quote wrong-type-argument) (list ... it))) (aref it 6)))))) (while (and list continue) (let ((it (car list))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? (progn (or (and ... t) (signal ... ...)) (aref it 6)))))) (setq it-index (1+ it-index)) (setq list (cdr list))) (let ((list (lsp-workspaces)) (continue t) (it-index 0)) (while (and list continue) (let ((it (car list))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? (progn (or ... ...) (aref it 6)))))) (setq it-index (1+ it-index)) (setq list (cdr list)))) (let (needle) (let ((list (lsp-workspaces)) (continue t) (it-index 0)) (while (and list continue) (let ((it (car list))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? (progn ... ...))))) (setq it-index (1+ it-index)) (setq list (cdr list)))) needle) (or (let (needle) (let ((list (lsp-workspaces)) (continue t) (it-index 0)) (while (and list continue) (let ((it (car list))) (if (not (not needle)) (setq continue nil) (setq needle (lsp--client-completion-in-comments\? ...)))) (setq it-index (1+ it-index)) (setq list (cdr list)))) needle) (not (company-in-string-or-comment))) (and (and (boundp (quote lsp-mode)) lsp-mode) (lsp--capability "completionProvider") (or (let (needle) (let ((list (lsp-workspaces)) (continue t) (it-index 0)) (while (and list continue) (let ((it ...)) (if (not ...) (setq continue nil) (setq needle ...))) (setq it-index (1+ it-index)) (setq list (cdr list)))) needle) (not (company-in-string-or-comment))) (or (company-lsp--completion-prefix) (quote stop))) (cond ((eql command (quote interactive)) (company-begin-backend (function company-lsp))) ((eql command (quote prefix)) (and (and (boundp (quote lsp-mode)) lsp-mode) (lsp--capability "completionProvider") (or (let (needle) (let ((list ...) (continue t) (it-index 0)) (while (and list continue) (let ... ...) (setq it-index ...) (setq list ...))) needle) (not (company-in-string-or-comment))) (or (company-lsp--completion-prefix) (quote stop)))) ((eql command (quote candidates)) (or (company-lsp--cache-item-candidates (company-lsp--cache-get arg)) (and company-lsp-async (cons :async (function (lambda (callback) (company-lsp--candidates-async arg callback))))) (company-lsp--candidates-sync arg))) ((eql command (quote sorted)) t) ((eql command (quote no-cache)) (not (eq company-lsp-cache-candidates t))) ((eql command (quote annotation)) (lsp--annotate arg)) ((eql command (quote quickhelp-string)) (company-lsp--documentation arg)) ((eql command (quote doc-buffer)) (company-doc-buffer (company-lsp--documentation arg))) ((eql command (quote match)) (cdr (company-lsp--compute-flex-match arg))) ((eql command (quote post-completion)) (company-lsp--post-completion arg))) company-lsp(prefix) apply(company-lsp prefix) (if (functionp company-backend) (apply company-backend args) (apply (function company--multi-backend-adapter) company-backend args)) (condition-case err (if (functionp company-backend) (apply company-backend args) (apply (function company--multi-backend-adapter) company-backend args)) ((debug user-error) (user-error "Company: backend %s user-error: %s" company-backend (error-message-string err))) ((debug error) (error "Company: backend %s error \"%s\" with args %s" company-backend (error-message-string err) args))) company-call-backend-raw(prefix) apply(company-call-backend-raw prefix) (let ((value (apply fun args))) (if (not (eq (car-safe value) :async)) value (let ((res (quote trash)) (start (time-to-seconds))) (funcall (cdr value) (function (lambda (result) (setq res result)))) (while (eq res (quote trash)) (if (> (- (time-to-seconds) start) company-async-timeout) (error "Company: backend %s async timeout with args %s" backend args) (sleep-for company-async-wait))) res))) company--force-sync(company-call-backend-raw (prefix) company-lsp) company-call-backend(prefix) (let ((company-backend backend)) (company-call-backend (quote prefix))) (progn (let ((company-backend backend)) (company-call-backend (quote prefix)))) (if (company--maybe-init-backend backend) (progn (let ((company-backend backend)) (company-call-backend (quote prefix))))) (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn (let ((company-backend backend)) (company-call-backend (quote prefix))))) (company--multi-backend-adapter backend (quote prefix))) (setq prefix (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn (let ((company-backend backend)) (company-call-backend (quote prefix))))) (company--multi-backend-adapter backend (quote prefix)))) (let ((backend (car --dolist-tail--))) (setq prefix (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn (let ((company-backend backend)) (company-call-backend (quote prefix))))) (company--multi-backend-adapter backend (quote prefix)))) (if prefix (progn (if (company--good-prefix-p prefix) (progn (let ((ignore-case ...)) (setq company-prefix (company--prefix-str prefix) company-backend backend c (company-calculate-candidates company-prefix ignore-case)) (cond (... ...) (... ...) (t ... ... ... ...))))) (throw (quote --cl-block-nil--) c))) (setq --dolist-tail-- (cdr --dolist-tail--))) (while --dolist-tail-- (let ((backend (car --dolist-tail--))) (setq prefix (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn (let (...) (company-call-backend ...)))) (company--multi-backend-adapter backend (quote prefix)))) (if prefix (progn (if (company--good-prefix-p prefix) (progn (let (...) (setq company-prefix ... company-backend backend c ...) (cond ... ... ...)))) (throw (quote --cl-block-nil--) c))) (setq --dolist-tail-- (cdr --dolist-tail--)))) (let ((--dolist-tail-- (if company-backend (list company-backend) company-backends))) (while --dolist-tail-- (let ((backend (car --dolist-tail--))) (setq prefix (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn (let ... ...))) (company--multi-backend-adapter backend (quote prefix)))) (if prefix (progn (if (company--good-prefix-p prefix) (progn (let ... ... ...))) (throw (quote --cl-block-nil--) c))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (catch (quote --cl-block-nil--) (let ((--dolist-tail-- (if company-backend (list company-backend) company-backends))) (while --dolist-tail-- (let ((backend (car --dolist-tail--))) (setq prefix (if (or (symbolp backend) (functionp backend)) (if (company--maybe-init-backend backend) (progn ...)) (company--multi-backend-adapter backend (quote prefix)))) (if prefix (progn (if (company--good-prefix-p prefix) (progn ...)) (throw (quote --cl-block-nil--) c))) (setq --dolist-tail-- (cdr --dolist-tail--)))))) (let (prefix c) (catch (quote --cl-block-nil--) (let ((--dolist-tail-- (if company-backend (list company-backend) company-backends))) (while --dolist-tail-- (let ((backend (car --dolist-tail--))) (setq prefix (if (or ... ...) (if ... ...) (company--multi-backend-adapter backend ...))) (if prefix (progn (if ... ...) (throw ... c))) (setq --dolist-tail-- (cdr --dolist-tail--))))))) company--begin-new() (and (company--should-complete) (company--begin-new)) (or (and company-candidates (company--continue)) (and (company--should-complete) (company--begin-new))) company--perform() (let ((inhibit-quit nil)) (company--perform) company-candidates) (condition-case err (let ((inhibit-quit nil)) (company--perform) company-candidates) ((debug error) (message "Company: An error occurred in auto-begin") (message "%s" (error-message-string err)) (company-cancel)) ((debug quit) (company-cancel))) (let ((company-idle-delay (quote now))) (condition-case err (let ((inhibit-quit nil)) (company--perform) company-candidates) ((debug error) (message "Company: An error occurred in auto-begin") (message "%s" (error-message-string err)) (company-cancel)) ((debug quit) (company-cancel)))) (and company-mode (not company-candidates) (let ((company-idle-delay (quote now))) (condition-case err (let ((inhibit-quit nil)) (company--perform) company-candidates) ((debug error) (message "Company: An error occurred in auto-begin") (message "%s" (error-message-string err)) (company-cancel)) ((debug quit) (company-cancel))))) company-auto-begin() (if (company-auto-begin) (progn (company-input-noop) (let ((this-command (quote company-idle-begin))) (company-post-command)))) (and (eq buf (current-buffer)) (eq win (selected-window)) (eq tick (buffer-chars-modified-tick)) (eq pos (point)) (if (company-auto-begin) (progn (company-input-noop) (let ((this-command (quote company-idle-begin))) (company-post-command))))) company-idle-begin(#<buffer api.py> #<window 3 on api.py> 3087 5740) apply(company-idle-begin (#<buffer api.py> #<window 3 on api.py> 3087 5740)) timer-event-handler([t 23863 56381 505651 nil company-idle-begin (#<buffer api.py> #<window 3 on api.py> 3087 5740) nil 176000]) ``` # Answer There is a mismatch between lsp-mode and company-lsp version. In order to fix that you may delete the packages located in ~/.emacs.d/elpa to force re-downloading them. > 1 votes # Answer I ran into a similar problem with a similar setup; I also got the warning: > company-lsp is no longer supported, using company-capf Just updating all my packages did not solve the problem, however removing: ``` (push 'company-lsp company-backends) ``` from my configuration fixed the error and idle completion works again. > 1 votes --- Tags: python, company-mode, lsp-mode ---
thread-59842
https://emacs.stackexchange.com/questions/59842
magit status and git lfs files diff shows pointer diff
2020-07-27T10:26:43.480
# Question Title: magit status and git lfs files diff shows pointer diff When I call `magit-status` git lfs files are shown as follows. ``` modified src/myfile @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -size 4241 +oid sha256:9999999999999999999999999999999999999999999999999999999999999999 +size 4242 ``` Is it possible to tell magit to show me the diff of the contents instead of the lfs-pointers' diff? # Answer > 2 votes Here I found my answer. The command `git config diff.lfs.textconv cat` does the trick for me. Even though as mentioned by tarsius, this comes with a significant slowdown, that's what I needed # Answer > 1 votes Magit itself does not support this and I think it probably should not. In any case, you can probably tell `git diff` itself to display these differently and since Magit just uses `git diff` that would affect it too. It seems reasonable for `git` to *not* display diffs for lfs files; after all lfs is intended for huge files whose diffs are not useful and/or huge. If you manage to display the diffs, that could come with a significant slowdown. --- Tags: magit, git ---
thread-60229
https://emacs.stackexchange.com/questions/60229
Replace a character with a string as it is typed
2020-08-19T21:36:24.750
# Question Title: Replace a character with a string as it is typed I would like to do the following: activate some mode so that whenener I type the `$` character in my buffer, it immediately gets replaced by `<m>`. Even better: when I type `$` it puts `<m></m>` and places the cursor between the matching tag pair. I have no problem with the solution being quick and dirty, but I would need to be able to turn it on and off. **Context:** I've started using PreTeXt, which is basically "laTeX meets xml", to write a math text. It works very well, but having to type `<m>` all the time is damaging my productivity (I'm already enjoying `c-C ]` to close the tags.) # Answer This can be done using abbrev mode: ``` ;; Hook to go back N chars after completion. (defun my-abbrev-back-4-no-self-insert () (progn (forward-char -4) t)) (put 'my-abbrev-back-4-no-self-insert 'no-self-insert t) (define-abbrev-table 'global-abbrev-table (list (list "$" "<m></m>" 'my-abbrev-back-4-no-self-insert 0) ;; More typical examples of abbrev mode usage. (list "btw" "by the way" nil 3) (list "pov" "point of view" nil 1))) ;; Enable abbrev mode. (add-hook 'after-change-major-mode-hook (lambda () (when (or (derived-mode-p 'prog-mode) (derived-mode-p 'text-mode)) (abbrev-mode 1)))) ``` The above code block can be copy-pasted into your `emacs` init file. --- For more advanced templating you may want to look into: yasnippets. > 1 votes --- Tags: latex, completion, abbrev, nxml, dabbrev ---
thread-60232
https://emacs.stackexchange.com/questions/60232
org-time-stamp-custom-formats are just reformatting the date for the org files, not writing it as is
2020-08-20T05:20:56.823
# Question Title: org-time-stamp-custom-formats are just reformatting the date for the org files, not writing it as is I use dates in org-mode(`C-c .`) and the format is like this: ``` (setq-default org-display-custom-times t) (setq org-time-stamp-custom-formats '("<%Y-%m-%d>" . "<%Y-%m-%d %a %W %H:%M>")) ``` It parses the date in the format: ``` <2020-08-20> ``` On the other hand I open the org-mode files with different text editors and under the hood the format is: ``` <2020-08-20 чт> ``` Is this how it normally works? Is there any way to change the date format of org-mode's date `C-c .` to print without the day, just as seen as in the org file? # Answer That's how it normally works: Org mode has to have a given date format so that it can parse dates with the date parser that is built in to it, so you don't get any freedom on how the dates are *stored* in the file. OTOH, emacs allows overlays so dates can *appear* in a different format when you display the buffer. But that is purely for display and is not reflected in the storage format. There are ways to actually force the displayed format to be written to a file, but it may well happen that Org mode will not be able to parse the resulting file properly. See e.g. https://github.com/mneilly/Emacs-Persistent-Overlays for one such attempt. ISTR another such attempt mentioned here in Emacs SE, but I cannot find it ATM. > 1 votes --- Tags: org-mode ---
thread-17754
https://emacs.stackexchange.com/questions/17754
insert word under cursor in projectile search
2015-10-30T12:04:48.050
# Question Title: insert word under cursor in projectile search when typing in some `projectile` filter string for instance (eg `SPC p f`) in `spacemacs`, I often would like to reuse the word under the cursor. I know about `C-y` to paste. Which is the one to insert the word under the cursor? I stumbled on `C-w` but it's not that. And why does `C-w` does by the way?? (btw if there is something more `spacemacs`-y I'm interested) # Answer If you're using Helm (which I believe is the default in Spacemacs), you can insert the word at the point with `M-n` or `C-w`. From the Helm Wiki: > To yank the symbol at point from `helm-current-buffer` (i.e. buffer where a helm command originated): > > `M-n` > > Alternatively, customize `helm-yank-symbol-first` to enable > > `C-w` > > to always yank the whole symbol on first invocation. > 5 votes # Answer Below is some commands that operate text between current buffer and minibuffer in helm: * `C-w` (`helm-yank-text-at-point`) Append the next word at point into minibuffer, like `isearch`'s `C-w` * `M-n` (`next-history-element`) Move through the “future history” list (see manual Minibuffer History, the first element of it is the symbol at point in the beginning) * `C-c C-y` (`helm-yank-selection`) Set minibuffer contents to helm selection * `C-c C-k` (`helm-kill-selection-and-quit`) Save helm selection to kill-ring and quit helm * `C-c C-i` (`helm-copy-to-buffer`) Insert helm selection into the current buffer --- If you want `C-w` to insert from the beginning of word, not the cursor's position, you can try the following hack: ``` (defun helm-yank-text-at-point--move-to-beginning (orig-func &rest args) "Initialize `helm-yank-point' to the beginning of word at point." (unless helm-yank-point (setq helm-yank-point (with-helm-current-buffer (save-excursion (let ((fwd-fn (or helm-yank-text-at-point-function #'forward-word))) (funcall fwd-fn -1)) (point))))) (apply orig-func args)) (advice-add 'helm-yank-text-at-point :around #'helm-yank-text-at-point--move-to-beginning) ``` > 4 votes # Answer There is `SPC *` command that will do `SPC / [word_under_the_cursor]`. `SPC /` is a search project command. Edit: added `SPC /` explanation > 1 votes --- Tags: key-bindings, helm, spacemacs ---
thread-60233
https://emacs.stackexchange.com/questions/60233
Query-replace stops after first item in while
2020-08-20T11:13:05.480
# Question Title: Query-replace stops after first item in while Following this StackOverflow question, I coded this function to clean up text pasted from other sources, such as Google Docs: ``` (defun sanitize-md () "Replace characters." (interactive "*") (save-excursion (let ((replacement-list '( ("\\" . "/") ("fi" . "fi") ("“" . "\"") ("”" . "\"") ))) (while (let* ((pair (pop replacement-list)) (to-find (car pair)) (to-replace (cdr pair))) (message "%s %s" to-find to-replace) (query-replace to-find to-replace nil (point-min) (point-max)) ) replacement-list) ))) ``` My problem is the curly double quote , which I have in a document. When I run this function, I get this in the `*Messages*` buffer: ``` \ / Mark set Replaced 0 occurrences ``` If I remove the line on `query-replace`, then the `*Messages*` buffer shows all four pairs. And if I put the double-quote pair as the first element of the list, then it gets replaced. Why does `query-replace` stop at the first element of the `dolist`, and how can I code the replacement of all pairs? # Answer > 1 votes If you try to match the form `(while COND BODY)` to what you have above, you will see that COND matches ``` (let* ((pair (pop replacement-list)) (to-find (car pair)) (to-replace (cdr pair))) (message "%s %s" to-find to-replace) (query-replace to-find to-replace nil (point-min) (point-max)) ) ``` and BODY is just `replacement-list`. The `while` evaluates the `COND` and loops as long as its value is `t`. But in this case the value of the `COND` is the value of the last form in the `let*`, i.e. the value of `(query-replace ...)`: since that does not find anything to replace with the first pair, it returns `nil` \- so the value of the `COND` is `nil` and the `while` is done. It may be that you have misplaced some parentheses and you really meant to write this: ``` (while (let* ((pair (pop replacement-list)) (to-find (car pair)) (to-replace (cdr pair))) (message "%s %s" to-find to-replace) (query-replace to-find to-replace nil (point-min) (point-max)) replacement-list)) ``` # Answer > 1 votes You are using `while`, not `dolist`, `while` stops when the TEST condition returns nil, not sure about the value of `query-replace`, but it definitely does not do what you want. --- Tags: conditionals, iteration ---
thread-60238
https://emacs.stackexchange.com/questions/60238
Apply Python formatting rules to files not ending in .py
2020-08-20T14:21:30.133
# Question Title: Apply Python formatting rules to files not ending in .py I need to edit a few `.pyt` files, which are python code but specific to ESRI ArcGIS software. Is there a variable that lists the file ending that python formatting is applied to that I could add `.pyt` to in order to have those files formatted? Thanks # Answer view `auto-mode-alist` using: ``` M-x describe-variable RET auto-mode-alist ``` Then edit the list by adding to your init file: ``` (add-to-list 'auto-mode-alist '("\\.pyt\\'" . python-mode)) ``` Per the docs here > 3 votes --- Tags: python, formatting ---
thread-14863
https://emacs.stackexchange.com/questions/14863
Why does emacs use both property lists and association lists?
2015-08-19T14:21:16.697
# Question Title: Why does emacs use both property lists and association lists? http://www.gnu.org/software/emacs/manual/html\_node/elisp/Plists-and-Alists.html gives some supposed differences between plists and alists. Basically it comes down to: 1. Alists can be used as stacks, where values are updated by adding a cons cell, allowing to restore previous values by deleting the topmost cons cell. 2. Plists are faster for storing information about symbols because they are typically short compared to storing everything (for all symbols) in a single alist. The first point makes sense. While the implementation of `plist-get` allows using plists in such a stack-like manner, by adding new values with ``` (push VALUE PLIST) (push KEY PLIST) ``` removing such a pair would be more involved compared to alists where one can just write ``` (setq ALIST (delete (assq KEY ALIST) ALIST)) ``` though even that could be changed by defining a function for it. The second point however seems incorrect too me, as the same advantage would apply for alists, if there was a `symbol-alist` function instead of `symbol-plist`. Additionally, in my experience plists are typically a bit slower than alists of the same size. Hence I was wondering why emacs uses both conventions for storing key-value pairs, when using one would suffice. **Clarification** Since it was raised in the comments: It seems largely a historical issue (emacs lisp was able to do both well, so people did both), but I'd still be interested in whether there was some rationale in the development of emacs to include builtin functions for handling both. Of course my view may be strongly colored by the Zen of Python (13th line) here to even raise the question. # Answer > 2 votes Fundamentally the explanation is historical. Lisp 1 stored the definition of a function on the function symbol's plist, and stored the values of all dynamically scoped variables (the only kind) in a big alist. It could have been done in any of the other three ways. By convention, many people treat alists as persistent (mutation-free) whereas "disembodied" plists (that is, ones not attached to a symbol) are usually mutated. # Answer > 1 votes The Emacs Lisp Manual gives a good explanation. Here's a brief summary: * If you are associating info with something that is already a Lisp function or variable, plists are faster because they're usually smaller and tied directly to the symbol. But the plist of a symbol is a global namespace, so different packages might conflict. * If you are trying to have general purpose information, an alist works better since keys can be anything, you can use it as a stack, and because different packages can have their own alists. > Association lists (\*note Association Lists::) are very similar to property lists. In contrast to association lists, the order of the pairs in the property list is not significant, since the property names must be distinct. > > Property lists are better than association lists for attaching information to various Lisp function names or variables. If your program keeps all such information in one association list, it will typically need to search that entire list each time it checks for an association for a particular Lisp function name or variable, which could be slow. By contrast, if you keep the same information in the property lists of the function names or variables themselves, each search will scan only the length of one property list, which is usually short. This is why the documentation for a variable is recorded in a property named \`variable-documentation'. The byte compiler likewise uses properties to record those functions needing special treatment. > > However, association lists have their own advantages. Depending on your application, it may be faster to add an association to the front of an association list than to update a property. All properties for a symbol are stored in the same property list, so there is a possibility of a conflict between different uses of a property name. (For this reason, it is a good idea to choose property names that are probably unique, such as by beginning the property name with the program's usual name-prefix for variables and functions.) An association list may be used like a stack where associations are pushed on the front of the list and later discarded; this is not possible with a property list. --- Tags: association-lists, property-lists ---