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-12089
https://emacs.stackexchange.com/questions/12089
Show math formula in emacs when coding
2015-05-03T09:41:33.703
# Question Title: Show math formula in emacs when coding Is it possible that emacs shows real formulas in the editor if they are written in Latex or similiar? I am asking because it would be much more readable if you are coding (in lets say python or C++) and the comments contain real formulas instead of something like this ``` // Calculate average for $\mu_1 = \frac{1}{n} ~ \sum_{1=i}^n ~ x_i$ ``` Is there a plugin which compiles Latex code in a comment to a picture and display it in the editor? # Answer > 5 votes Yes. See `pretty-symbols` package. It can look like this, for example, when coding Python, or any other language: # Answer > 3 votes ~~TeXfrag~~ texfrag shows doxygen-formulas embraced by `\f[display formula\f]` or `\f$embedded formula\f$` as images. The regular expressions and also the functions for parsing the formulas can be customized. TeXfrag works by: 1. copying the formulas from the source code buffer to a (hidden) LaTeX buffer 2. running preview-document there and 3. moving the overlays back to the source code buffer. The context menus of `preview` work for the images in the source code buffer. There is also a minor-mode menu which allows you to generate the images for the full buffer or just the images around point. Example: The upper buffer shows a section of a doxygen-comment in a c-file with overlaid images for the equation fragments the lower buffer shows the same section with the overlays removed. EDIT: Note that `TeXfrag` has been renamed to `texfrag` to fulfill the requirements of `melpa`. `texfrag` has been reviewed and accepted by `melpa`. If you have `melpa` in `package-archives` you can install `texfrag` via `package-install`. # Answer > 1 votes It seems to me that an actual image would be more trouble than it's worth in `c++-mode` or `python-mode`. It could work in `org-mode` though, which has a mechanism for storing the images and refreshing them. Even then, it's awkward for scrolling if the image has a large height. But you can still fontify bits if you want. For instance, here's my setup for font-locking doxygen tags in C++: ``` (defface font-lock-doxygen-face '((nil (:foreground "SaddleBrown" :background "#f7f7f7"))) "Special face to highlight doxygen tags such as <tt>...</tt> and <code>...</code>." :group 'font-lock-highlighting-faces) (font-lock-add-keywords 'c++-mode '(("\\(<\\(?:code\\|tt\\)>\"?\\)\\([^<]*?\\)\\(\"?</\\(?:code\\|tt\\)>\\)" (0 (prog1 () (let* ((expr (match-string-no-properties 2)) (expr-len (length expr))) (if (eq 1 expr-len) (compose-region (match-beginning 0) (match-end 0) (aref expr 0)) (compose-region (match-beginning 1) (1+ (match-end 1)) (aref expr 0)) (compose-region (1- (match-beginning 3)) (match-end 3) (aref expr (1- expr-len))))))) (0 'font-lock-doxygen-face t)))) ``` It will replace `<tt>foo</tt>` and `<code>bar</code>` with colored symbols. # Answer > 1 votes Another option to consider is the `latex-math-preview` package. It allows one to view "real formulas in the editor" in a separate buffer (or to save the formula image to a file). Simply invoke `latex-math-preview-expression` while the point is on an expression. --- Tags: latex, display ---
thread-53703
https://emacs.stackexchange.com/questions/53703
how to bind custom commands to keys in existing mode map?
2019-11-12T22:42:54.883
# Question Title: how to bind custom commands to keys in existing mode map? I wrote some extra commands for Python mode: `python-insert-quote` and `python-insert-double-quote`. I want to have these commands be available in the minibuffer when `python-mode` is active. How can I add these custom functions into python-mode without write a new mode? I was thinking it might be nice to keep these additional functions saved in `~/.emacs.d/lisp/extra-python.el` I'm not sure how hooks work or if this would be the right time to use hooks. When I look at hooks, It says that hooks are used to change the behavior of a mode, giving this example: > `(add-hook 'text-mode-hook 'auto-fill-mode)` The example would seem antithetical to what I'm trying to do. I just what the functions to be callable form the mini-buffer only when in python-mode, not to be called when the mode is launched. --- GNU Emacs 26.1 saved in `~/.emacs.d/lisp/extra-python.el` ``` (defun python-insert-quote () "Inesert python single quote" (interactive) (let ((myline (thing-at-point 'line))) (while (string-match "\\([^ ].*\\)" myline ) ;; remove line (kill-whole-line) ;; add better line (insert (concat "'" (match-string 0 myline) "'" " ")) ;; fix indent (forward-line -1) (beginning-of-line) (indent-for-tab-command) (error "")))) ;(break) the equivalent (defun python-insert-double-quote () "Inesert python double quote" (interactive) (let ((myline (thing-at-point 'line))) (while (string-match "\\([^ ].*\\)" myline ) ;; remove line (kill-whole-line) ;; add better line (insert (concat "\"" (match-string 0 myline) "\"" " ")) ;; fix indent (forward-line -1) (beginning-of-line) (indent-for-tab-command) (error "")))) ;(break) the equivalent (provide 'extra-python) ``` saved in `~/.emacs.d/init.el` ``` ;; Add commands to python mode (add-hook 'python-mode-hook (lambda () (define-key python-mode-map [f6] 'python-insert-quote) (define-key python-mode-map [f5] 'python-insert-double-quote))) ``` # Answer The typical way this is done is by assigning the custom commands to keyboard shortcuts of a given major-mode; e.g., add to your Emacs init file ``` ;; Add commands to python mode (require 'extra-python) ``` and then either ``` (eval-after-load "python-mode" '(progn (define-key python-mode-map [f5] 'python-insert-quote) (define-key python-mode-map [f6] 'python-insert-double-quote)) ``` or ``` (add-hook 'python-mode-hook (lambda () (define-key python-mode-map [f5] 'python-insert-quote) (define-key python-mode-map [f6] 'python-insert-double-quote))) ``` One can store his/her custom commands wherever it makes sense in the opinion of the user. At the very bottom of `extra-python.el`, you can insert a statement `(provide 'extra-python)` and then ensure that the `~/.emacs.d/lisp/` directory has been added to the `load-path`. If the function definitions have been loaded and are `interactive` (they are commands), a user can always type: ``` M-x NAME-OF-COMMAND ``` > 0 votes --- Tags: major-mode, customize, functions, interactive ---
thread-53161
https://emacs.stackexchange.com/questions/53161
Why in dired+ mode some text is strikethrough?
2019-10-15T08:49:37.147
# Question Title: Why in dired+ mode some text is strikethrough? Windows 10, Emacs 26.1, Dired+ (download from here https://www.emacswiki.org/emacs/download/dired%2b.el) Open some directory: Here result: Why some text is strikethrough? # Answer > 3 votes They are displayed in the `diredp-omit-file-name` face defined in the very same file: ``` (defface diredp-omit-file-name (if (assq :inherit custom-face-attributes) ; Emacs 22+ '((((background dark)) (:inherit diredp-ignored-file-name :strike-through "#555555555555")) ; ~ dark gray (t (:inherit diredp-ignored-file-name :strike-through "#AAAAAAAAAAAA"))) ; ~ light gray '((((background dark)) (:foreground "#C29D6F156F15")) ; ~ salmon (t (:foreground "#00006DE06DE0")))) ; ~ dark cyan "*Face used for files whose names will be omitted in `dired-omit-mode'. This means file names that match regexp `diredp-omit-files-regexp'. \(File names matching `dired-omit-extensions' are highlighted with face `diredp-ignored-file-name' instead.)" ``` If you don't like the current appearance of the face, you can customize it using `customize-face`. # Answer > 2 votes Just remove the strike-throughs in lines 3839-3842 of dired+.el, to give ``` (defface diredp-omit-file-name ;; (if (assq :inherit custom-face-attributes) ; Emacs 22+ '((((background dark)) (:inherit diredp-ignored-file-name)) (t (:inherit diredp-ignored-file-name))) ``` Either rename the file or make a note of the change so you're not caught out in an update. --- Tags: dired, faces, font-lock ---
thread-53503
https://emacs.stackexchange.com/questions/53503
sudden let-alist feature failure
2019-11-01T09:39:45.213
# Question Title: sudden let-alist feature failure This morning, I wake up and restart my Emacs.app (26.3 GNU Emacs but the emacsformacosx.com version, from `brew cask`) and get stuck at this: ``` Eager macro-expansion failure: (error "Loading file /Users/erik/.emacs.d/elpa/let-alist-1.0.6/let-alist.elc failed to provide feature ‘let-alist’") [2 times] ``` The built-in version of `let-alist` was 1.0.5, upgraded to 1.0.6, to no avail. # Answer Looks like somehow during an `Emacs.app` upgrade via brew cask (or possibly for other reasons), the `let-alist` providing source file at `~/.emacs.d/elpa/let-alist-1.0.6/let-alist.el` ended up as empty. I fixed the issue by restoring its original/expected contents from http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-lisp/let-alist.el and restarting Emacs. Thank you @Tobias, for pointing out the obvious — to start by looking up what's inside `let-alist.el`. :) > 1 votes --- Tags: debugging, emacs26 ---
thread-35339
https://emacs.stackexchange.com/questions/35339
Random href ids in Org 9 exported HTML?
2017-09-07T09:55:23.157
# Question Title: Random href ids in Org 9 exported HTML? Something seems to have changed in the way HTML is exported from org mode between the 8 and 9 versions.One example, in the Table of Contents, I get entries with anchors like this: ``` a href="#orgfaf035e" ``` while earlier (version 8) I think I was getting ``` a href="#sec.1.1" ``` Those numbers seem to be completely random, so they differ every time I run the exporter again. The result is that if I make a change of one word only in the text, the diff between the new and the old file will be tens of lines of code. This is just noise for someone using a version control system. I wonder if there is an option to return to the old behaviour. # Answer > 1 votes I agree that this is an annoying change in Orgmode... The only workaround I've found is this hack: https://github.com/alphapapa/unpackaged.el#export-to-html-with-useful-anchors --- Tags: org-mode, org-export, html ---
thread-53711
https://emacs.stackexchange.com/questions/53711
How to set font-height for all future frames?
2019-11-13T16:14:04.820
# Question Title: How to set font-height for all future frames? I've set the font-family and font-size in a few different ways before, one of which was: ``` (custom-set-faces '(default ((t (:family "Liberation Mono" :height 150))))) ``` However, I learned that if you set it that way, future frames will not be able to use the values and they need something like: ``` (add-to-list 'default-frame-alist '(font . "Liberation Mono")) ``` But because I add set it from a variable, I do it like: ``` (add-to-list 'default-frame-alist `(font . ,custom-variable-font-family)) ``` I'm not able to find a way to set the font-height using this method. I did try to set `height`, but it ended up setting the height of the Emacs frame, just like it's mentioned in one of the documentation pages here. I also tried a few other keywords apart for `font` (some from the documentation and some from my own wild guesses), just like you can set the `background-color`, etc. But I haven't been able to do that. I wonder if it's even possible (I know it should be) to set the font-height across frames that way. # Answer > 1 votes `M-x customize-face default`, then set the `height` attribute to the value you want. --- There are several other approaches. Here's one involving `default-frame-alist`: Use `M-x customize-option default-frame-alist`, providing a full font name for the value of frame-parameter `font`. For example: this value uses a font height of 16 pixels: ``` "-*-Lucida Console-normal-r-*-*-16-*-*-*-c-*-iso8859-1" ``` That's an XLFD font name, the traditional method for specifying fonts under X Window. See (emacs) Fonts for a detailed description. In this case, the `16` is the `PIXELS` entry. That same Emacs-manual node also describes other ways to specify a font name. Customize is your friend. If you don't want to use it then just do what you were doing, but use a full (e.g., XLFD) font name, which specifies the font size. --- Tags: frames, fonts ---
thread-53715
https://emacs.stackexchange.com/questions/53715
How to schedule exclusively with the keyboard?
2019-11-13T18:30:27.753
# Question Title: How to schedule exclusively with the keyboard? If you look a the screenshot the cursor is locked in the echo area. If want to select the date, I have to click on one with the mouse. Do I, or there is a way to do with the keyboard? EDIT: Also the navigation key bindings don't work as they're supposed to. If I do `C-f`, it does not move one day forward whether in conjunction with `Shift` or not. # Answer > 10 votes Hold down the shift key while you use the arrows. Shift-right and left will move by days, Shift-up and down by weeks. Alt-Shift right and left will move by months, and Alt-Shift up and down will move by years. # Answer > 9 votes There is a lot of inputs you can give to specify a date or time. The whole overview is here. Just some notable examples: * Relative dates: + `+1` or just `+`: tomorrow + `+1w`: next week + `sat`: next saturday * Absolute dates are a bit weird. It uses ISO YMD format by default: `3-2-5` expands to `2003-02-05`. I prefer to use `23 jan 19` or `23 jan 2019` (equal to `19-1-23`) to use a DMY format. * To add a time to any date selection use `11am` or `11:00` Some Calendar movements also work. Shift+Arrows moves by days. `>` and `<` shift the months displayed, ... See Calendar motion and Scroll calendar of the Emacs Calendar manual. Here's a screenshot where I select the monday in two weeks at 11am by entering `+2mon 11am`. The date prompt gets updated to indicate my selected date `=> <2019-11-25 Mon 11:00>`. Press `Enter` to confirm and exit. # Answer > 2 votes @Daniel's answer should be the official solution. But I find you can still just `C-x o` to move the cursor to the calendar buffer, then move around as usual and hit RET to pick a date. Though you will not see the cursor because the org mode turns it off, you can get it back via `M-x (setq cursor-type t)`. --- Tags: org-mode, calendar ---
thread-50551
https://emacs.stackexchange.com/questions/50551
calling xref-find-definitions within lisp code
2019-05-16T12:24:28.987
# Question Title: calling xref-find-definitions within lisp code I want to call *xref-find-definitions* from within my own lisp code and I'm struggling. > (xref-find-definitions IDENTIFIER) > > Find the definition of the identifier at point. It wants a parameter but I don't understand what parameter to supply because if I call it directly it just reads the name of a function from (point) and finds the source code for me. As background, I maintain a private mark-ring with functions to (un)rotate-and-go and I want to combine *go-to-source-of-function-named-at-point* and *push-point-onto-private-mark-ring* as one key-combination. I'm aware of `bury-buffer` and wrote my own `unbury-buffer`. # Answer You can call `xref-find-definitions` programatically by ``` (xref-find-definitions (symbol-name (symbol-at-point))) ``` or if you want to be prompted for an identifier ``` (funcall-interactively #'xref-find-definitions (xref--read-identifier "Find definitions of: ")) ``` > 3 votes --- Tags: mark-ring, xref ---
thread-44841
https://emacs.stackexchange.com/questions/44841
How do I hit the equivalent of `C-u` (of normal emacs) in Spacemacs?
2018-09-20T08:26:28.710
# Question Title: How do I hit the equivalent of `C-u` (of normal emacs) in Spacemacs? According to the "Evilified modes" documentation \[1\], `C-u` gets moved to `C-U`, but when I try to hit that (Ctrl+Shift+u), my cursor still gets moved one page up, instead of starting a new long command. \[1\] - http://spacemacs.org/doc/DOCUMENTATION.html#evilified-modes # Answer That would be `SPC u` if memory serves me correctly. > 9 votes # Answer Read Universal argument in the documentation: > Spacemacs binds `C-u` to `scroll-up` and change the universal argument binding to `SPC u`. In insert mode, space will obviously insert space, so `C-u` needs to be typed after the command, before `RET`: > **Note**: `SPC u` is not working before `helm-M-x` (`SPC SPC`). Instead, call `helm-M-x` first, select the command you want to run, and press `C-u` before pressing `RETURN`. For instance: `SPC SPC org-reload C-u RET` > 2 votes --- Tags: spacemacs ---
thread-53730
https://emacs.stackexchange.com/questions/53730
Flycheck does not find .h file
2019-11-14T14:04:19.720
# Question Title: Flycheck does not find .h file I am using Flycheck for my syntax highlighting which have been working out great when working with all header and source files in one directory. I recently decided to add some unit tests to test my code which I added another directory for. The projects compiles and runs without problems. My problem is that in the `test/Formula-test.cpp` file when i `#include "Formula.h"` a header from the `src/Formula.h` folder flycheck can't seem to find it. I get the "error" `'Formula.h' file not found (c/c++-clang)`. My project structure looks like this: ``` . ├── build │ └── compile_commands.json ├── CMakeLists.txt ├── lib │ └── googletest ├── src │ ├── CMakeLists.txt │ ├── Formula.cpp │ ├── Formula.h │ ├── main.cpp └── test ├── CMakeLists.txt ├── Formula-test.cpp └── main.cpp ``` Is there any configuration or package that can fix this? Here is my full config file: https://github.com/Zeppan/configs/blob/master/.emacs # Answer > 1 votes Normally you may configure flycheck with what you need - see flycheck group of variables. But that may not be the best idea, since your path changes in another project. The package `cmake-ide` could instead manage all flycheck paths for your project and adds also compilation command. About a `.clang-complete` file, here it is my version: ``` -DDEBUG -I/Library/Developer/CommandLineTools/usr/include/c++/v1/ -I/Library/Developer/CommandLineTools/usr/include/ -I/usr/local/opt/boost/include/ -I/Users/your-name/Path-to-proj/ ``` I use the above and a .dir-locals.el file. The reason for me was that I use eglot + clangd, and this package (eglot) disable flycheck in favour of flymake (seems actually there is a wave of replacing flycheck with flymake...) --- Tags: flycheck, c ---
thread-53725
https://emacs.stackexchange.com/questions/53725
What does {:} in columnview specification mean?
2019-11-14T08:13:59.820
# Question Title: What does {:} in columnview specification mean? A `columnview` `org-columns` specification may look like this: ``` #+BEGIN: columnview :id local :format "%70ITEM(Task) %Effort{:} %CLOCKSUM{:}" #+END: ``` Sometimes you can see variations without the `{:}` part. What is the function of `{:}`? # Answer > 1 votes `{:}` is used to add to the parent nodes a sum of the times for each of the child nodes in the table for that column. In column views anything in `{` `}` is to specify the summary type for that column. `:` is specifically for times. See `SUMMARY-TYPE` in the column attributes docs for more info. --- Tags: org-mode, formatting, org-clock-table ---
thread-53738
https://emacs.stackexchange.com/questions/53738
Newbie to emacs. need help
2019-11-14T16:12:00.920
# Question Title: Newbie to emacs. need help Are there any good resources that anyone can suggest. I rate myself 3 out of 10 when it comes to using editors like vim # Answer I write up something like the canonical answer. If you have Emacs with graphical environment such as X11 or Windows just start Emacs and open the menu item `Help``Emacs Tutorial` with the help of your pointing device such as mouse or touchpad. If you only have the command line version of emacs start emacs with the following command line: `emacs -f help-with-tutorial` Then fight your way through the tutorial. PS: This answer is marked as community wiki. So do not hesitate to improve it in any way. > 1 votes --- Tags: linux, fedora ---
thread-53740
https://emacs.stackexchange.com/questions/53740
How to increment number in every matching line?
2019-11-14T16:37:37.870
# Question Title: How to increment number in every matching line? ``` [ { "id": 0, "finished": 1, "orgn": 17 }, { "id": 1, "finished": 2, "orgn": 17 }, { "id": 2, "finished": 3, "orgn": 17 }, { "id": 3, "finished": 4, "orgn": 17 } ] ``` I need to increment every field `finished` by 1 The result must be: ``` [ { "id": 0, "finished": 2, "orgn": 17 }, { "id": 1, "finished": 3, "orgn": 17 }, { "id": 2, "finished": 4, "orgn": 17 }, { "id": 3, "finished": 5, "orgn": 17 } ] ``` # Answer Use the following key sequence: `M-C-%` `\("finished":[[:space:]]*\)\([0-9]+\)` `RET` `\1\,(1+ (string-to-number \2))``RET` * `M-C-%` is bound to `query-replace-regexp`. * `\("finished":[[:space:]]*\)\([0-9]+\)` is the regexp to search for, the first group is just for copying into the replacement string, the second group is the number to be transformed. * `\1\,(1+ (string-to-number \2))` is the replacement string (`\1\,(1+ (read \2))` would also work). + `\1` copies group 1 at the head of the search string. + `\,(...)` evaluates the form `(...)` and inserts the result at the position of the escape sequence. + The Elisp transforms the string from group 2 (i.e., the string with the number) into a number and adds 1. The result is automatically translated back to a string that is inserted into the replacement string. > 9 votes # Answer I'm going to use the function found here. ``` (defun increment-number-at-point () (interactive) (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (1+ (string-to-number (match-string 0)))))) ``` For a quick solution, I would use a macro. This is appropriate if you only need to do it a small number of times, and the number of replacements is small. First, go to the beginning of the file: `M-S-<`. Now, we can record the macro. I'm going to search forward for the next instance of `"finished"`, go to the end of the line, go back two characters, then run the command `increment-number-at-point`. `C-x ( C-s finished C-e C-b C-b M-x increment-number-at-point RET C-x e`. You can then keep pressing `e` to repeat this macro until you get to the end of the file. > 2 votes # Answer Not everything needs to be done in pure elisp or using just Emacs facilities. In this case, I would use `shell-command-on-region` (usually bound to `M-|`): first mark the region of interest and then type `M-|` and pass the following shell command to it (followed by `RET`): ``` awk -F ":" '/finished/ {n = $2+1; printf "%s: %s,\n", $1, n; next;} {print $0;}' ``` In words: use a colon as a field separator, for each line, if the line matches `finished`, increment the second field and print out the modified line, then go immediately to the next line; otherwise, just print the line. There are probably shorter ways to do it, and perhaps some error checking needs to be added (e.g. if the second field on `finished` lines is missing or not a number), but in the case you showed, this should be enough. Running `shell-command-on-region` with that command will produce output in a separate buffer, where you can check and make sure that it did the right thing. Once you are sure it is doing the right thing, you can *replace* the original region with the modified text using a `C-u` prefix on `shell-command-on-region`: ``` C-u M-| awk -F ":" '/finished/ {n = $2+1; printf "%s: %s,\n", $1, n; next;} {print $0;}' RET ``` `shell-command-on-region` allows you to use all sorts of tools outside Emacs to do text processing, so IMO it is an indispensable tool in one's tool box. > 1 votes --- Tags: text ---
thread-53727
https://emacs.stackexchange.com/questions/53727
Why dired+ not save sort mode?
2019-11-14T11:03:10.800
# Question Title: Why dired+ not save sort mode? windows 10, Emacs 26.1, Dired+ Suppose I has 3 files and sort it by name in dired mode. Smt like this: OK. Now I sort it by date, press `s` Here result: OK. Now I edit file `3.txt` and after save data in this file I return to dired by press `dired-jump` (C-x C-j). And here result. As you can see it again sort by **name** but I need to sort by **date**. Why dired+ not save my sort mode? # Answer > 1 votes `dired-jump` (`C-x C-j`) just invokes command `dired`, which gives you a **new** Dired buffer, with the default switches from **`dired-listing-switches`**. You can customize `dired-listing-switches` to whatever you want. If you expect to return to an existing Dired buffer, which already uses the switches you want, then use `C-x b` to switch to that buffer. If you want to automatically change the default switches to use each time you use `s` in Dired (that is, automatically modify `dired-listing-switches`), so that another, arbitrary use of `dired` uses the latest ones, then you'll need to program that. You can, for example, advise `dired-sort-toggle-or-edit` (which is bound to `s` in Dired mode). --- Tags: dired, sorting ---
thread-53736
https://emacs.stackexchange.com/questions/53736
How increment specific value in text
2019-11-14T15:56:15.297
# Question Title: How increment specific value in text windows 10, Emacs 26.1 Suppose I has the next text ``` [ { "id": 1, "finished": 1573550444.4444, "orgn": 17 }, { "id": 1, "finished": 1573550444.4444, "orgn": 17 }, { "id": 1, "finished": 1573550444.4444, "orgn": 17 }, { "id": 1, "finished": 1573550444.4444, "orgn": 17 } ] ``` I need to increment only field "**id**" The result must be like this: ``` [ { "id": 2, "finished": 1573550444.4444, "orgn": 17 }, { "id": 3, "finished": 1573550444.4444, "orgn": 17 }, { "id": 4, "finished": 1573550444.4444, "orgn": 17 }, { "id": 5, "finished": 1573550444.4444, "orgn": 17 } ] ``` Is it possible? Without create my custom function. # Answer Use a regular expression replacement with a bit of Lisp code. In the replacement text, you can use `\,(…)` to execute some Lisp code, and you can use `\#` as the number of replacements made so far. So `\,(+ 2 \#)` will be become successively `2`, `3`, `4`, … in successive replacements. Thus, use `C-M-%` or `M-x replace-regexp` to replace `\("id": \)[0-9]+` with `\1\,(+ 2 \#)` > 3 votes # Answer That should do it: ``` (defun cummulative-raise-regexp (&optional regexp) (interactive) (let* ((regexp (or regexp "\"id\": \\([0-9]+\\),")) (counter 1)) (while (re-search-forward regexp nil t) (replace-match (concat "\"id\": "(number-to-string (+ counter (string-to-number (match-string-no-properties 1))))",")) (setq counter (1+ counter))))) ``` > 0 votes --- Tags: text ---
thread-53751
https://emacs.stackexchange.com/questions/53751
Help with basic diary/calendar features
2019-11-15T04:52:49.533
# Question Title: Help with basic diary/calendar features I have created two diary entries, I can't see them in the week agenda. Why is that? Also I would have expected 11/15 to be highlighted, or something like that, to indicate an event was planned that day. # Answer > 0 votes I didn't know Org Agenda can work with Diary since they are two separate apps. Then I searched the org manual with keyword `diary`, and found this on (info "(org) Weekly/daily agenda"): > In order to include entries from the Emacs diary into Org mode’s agenda, you only need to customize the variable > > ``` > (setq org-agenda-include-diary t) > > ``` That variable defaults to nil. --- Tags: org-agenda, calendar ---
thread-53753
https://emacs.stackexchange.com/questions/53753
DO NOT complete file-name with company
2019-11-15T08:19:49.810
# Question Title: DO NOT complete file-name with company I do not want emacs company mode to complete the file names in my org-mode buffer, as it wrongly replaces many words eg But becomes Butale (file-name, surname of person) and the becomes (themaskar, another surname). kindly help # Answer What company backends do you use? Remove `company-files` from `company-backends`. > `company-files` is an autoloaded interactive compiled Lisp function in `company-files.el`. > > `company-mode` completion backend existing file names. > > Completions works for proper absolute and relative files paths. File paths with spaces are only supported inside strings. > 1 votes --- Tags: org-mode, company-mode, auto-complete-mode ---
thread-53755
https://emacs.stackexchange.com/questions/53755
Increase the font size for Hebrew text in Emacs but leave English font size as is
2019-11-15T10:12:33.993
# Question Title: Increase the font size for Hebrew text in Emacs but leave English font size as is I frequently type both in Hebrew and English. The font I use is Dejavu Sans Mono. This renders Hebrew fonts accurately. However, because Hebrew uses small vowels, I would like to increase the font size of the Hebrew text but keep the English as it is. I have tried various solutions but none have worked for worked for me: I installed the package unicode-fonts, but this does not seem to have the ability to tweak font sizes. I followed the instructions in this link How to assign a certain font for each input method/language in Emacs 24? but found no useful solution there. I use the code below to change input methods: ``` (define-key 'iso-transl-ctl-x-8-map "f" [?‎]) ;; Input method and key binding configuration. (setq alternative-input-methods '(("hebrew-biblical-sil" . [?\C-\\]) ("greek-babel" . [?\C-|]))) (setq default-input-method (caar alternative-input-methods)) (defun toggle-alternative-input-method (method &optional arg interactive) (if arg (toggle-input-method arg interactive) (let ((previous-input-method current-input-method)) (when current-input-method (deactivate-input-method)) (unless (and previous-input-method (string= previous-input-method method)) (activate-input-method method))))) (defun reload-alternative-input-methods () (dolist (config alternative-input-methods) (let ((method (car config))) (global-set-key (cdr config) `(lambda (&optional arg interactive) ,(concat "Behaves similar to `toggle-input-method', but uses \"" method "\" instead of `default-input-method'") (interactive "P\np") (toggle-alternative-input-method ,method arg interactive))))));; Input method and key binding configuration. (reload-alternative-input-methods) ``` # Answer You can do this with `set-fontset-font`, which allows overriding the builtin selection mechanisms for fonts for specific characters, charsets or scripts. So in your case, something like: ``` (set-fontset-font "fontset-default" 'hebrew (font-spec :family "Dejavu Sans Mono" :size 20)) ``` See Modifying-Fontsets for more info. > 2 votes --- Tags: fonts ---
thread-44623
https://emacs.stackexchange.com/questions/44623
Not a Tramp file name
2018-09-08T13:36:08.157
# Question Title: Not a Tramp file name windows 10 (64 bit), emacs 26.1 I try to connect by Tramp mode from Windows to remote Linux machine. I use this command: ``` C-x C-f ``` and then ip of remote machine (ip address): ``` /xxx.xxx.xxx.xxx: ``` but I get error: ``` Error running timer: (user-error "Not a Tramp file name: \"/xxx.xxx.xxx.xxx:\"") ``` # Answer See Emacs NEWS (`C-h n`): > \*** The method part of remote file names is mandatory now. A valid remote file name starts with "/method:host:" or "/method:user@host:". > > \*** The new pseudo method "-" is a marker for the default method. "/-::" is the shortest remote file name then. > > \*** The command 'tramp-change-syntax' allows you to choose an alternative remote file name syntax. > 2 votes --- Tags: tramp ---
thread-53230
https://emacs.stackexchange.com/questions/53230
Convert text under a heading into an org-table
2019-10-18T16:12:51.473
# Question Title: Convert text under a heading into an org-table I am using spacemacs. I've written my shortcuts in an org file to not forget them. It has a structure of Description: key, then I go to the next line and enter the next command. For example \*** Latex Preview at point: SPC m p p Jump to begin or the end of the environment: % Use macro: C-c RET Create environment: C-c C-e or SPC m e It occured to me, that using an org-table for this would fit quite nicely. By now I have quite some headings with corresponding shortcuts. Is there an elegant fast way to convert my records under a certain heading/tree in an org-table format, so that the text before ":" goes into a first column of a table and the text after ":" in a second column with one table row dedicated for each entry pair? Some custom function defined via defun? # Answer Ok, I discovered an alternative efficient way for me. I just used `M-x query-replace` (`M-x %`) to replace all `:` (colons) by `,` (comma). Afterwards I could apply the convertion command `C-c |` to retain the structure I had. The answer of allsOrts answers it partially, but doesn't mention the trick, that comma can be used for separation to get the 2 columns structure in this case (I am not sure what is meant under replacing colon with a tab). > 0 votes # Answer For the `:`, a simple `M-x query-replace` will quickly get you the `|` between the two columns. For the `|` at the beginning and end, `M-x query-replace-regexp` should do: * replace `^` with `|` for the beginning of the line * replace `$` with `|` for the end of the line Once you've got all the `|` inserted, pressing tab anywhere in the table will line up all the columns. > 0 votes # Answer The following approach works for the full subtree describing the key-bindings for all major-modes at once (if the structure of your document is really as you indicated in the question): 1. narrow to the subtree in question: `C-x n s` 2. Type `C-<home>` to go to the beginning of buffer. 3. query replace with `M-C-%` `^\([[:alnum:] ]+\):\( .*\)$` `RET` `|\1|\2|` `RET`. In the 2nd item I assume that your descriptions only contain alphanumeric characters and spaces. > 0 votes # Answer I often use `(C-c |)` to convert tab separated areas, so you could perhaps simply replace the colon character with a tab and use that. Or wrap some elisp around `(org-table-convert-region BEG0 END0 &optional SEPARATOR)` Initially I wondered if what you really want is to use the powerful (and I mean to learn this for myself still) Emacs Org's Column View, `org-columns`(`C-c C-x C-c`). But having read it again I see that is not appropriate at all to this need. > 0 votes --- Tags: org-mode, org-table ---
thread-53766
https://emacs.stackexchange.com/questions/53766
How to change color of Python "None" and Booleans for digital-ofs1 color theme
2019-11-15T17:08:32.367
# Question Title: How to change color of Python "None" and Booleans for digital-ofs1 color theme I'm trying to change the color of Python None and Boolean variables in the `digital-ofs1` color scheme, but can't find which variable to change. I've Googled around to no avail and can't seem to solve the problem backwards by matching the color to a list of Emacs colors and then seeing which variable matches it. Could someone please tell me what to do? I like this color scheme, but there are a few contrasts that are just too slight. The code for the color scheme is as follows: ``` (deftheme digital-ofs1 "digital-ofs1 theme") (custom-theme-set-faces 'digital-ofs1 '(default ((t (:background "#CA94AA469193" :foreground "Black")))) '(mouse ((t (:foregound "black")))) '(cursor ((t (:foregound "black")))) '(border ((t (:foregound "black")))) '(Man-overstrike-face ((t (:bold t)))) '(Man-underline-face ((t (:underline t :bold t)))) '(gnus-mouse-face ((t (:bold t :background "darkseagreen2")))) '(goto-address-mail-face ((t (:italic t :bold t)))) '(goto-address-mail-mouse-face ((t (:bold t :background "paleturquoise")))) '(goto-address-url-face ((t (:bold t)))) '(goto-address-url-mouse-face ((t (:bold t :background "darkseagreen2")))) '(ispell-highlight-face ((t (:bold t :background "darkseagreen2")))) '(list-matching-lines-face ((t (:bold t)))) '(rmail-highlight-face ((t (:italic t :bold t :foreground "Blue")))) '(view-highlight-face ((t (:bold t :background "darkseagreen2")))) '(default ((t (:bold t)))) '(bbdb-company ((t (:italic t)))) '(bbdb-field-name ((t (:bold t)))) '(bbdb-field-value ((t (nil)))) '(bbdb-name ((t (:underline t)))) '(blank-space-face ((t (nil)))) '(blank-tab-face ((t (nil)))) '(blue ((t (:bold t :foreground "blue")))) '(bold ((t (:bold t)))) '(bold-italic ((t (:italic t :bold t)))) '(border-glyph ((t (:bold t)))) '(buffers-tab ((t (:background "black" :foreground "LightSkyBlue")))) '(calendar-today-face ((t (:underline t :bold t :foreground "white")))) '(comint-input-face ((t (nil)))) '(cperl-array-face ((t (:bold t :background "lightyellow2" :foreground "Blue")))) '(cperl-hash-face ((t (:italic t :bold t :background "lightyellow2" :foreground "Red")))) '(cperl-here-face ((t (nil)))) '(cperl-invalid-face ((t (:foreground "white")))) '(cperl-nonoverridable-face ((t (:foreground "chartreuse3")))) '(cperl-pod-face ((t (nil)))) '(cperl-pod-head-face ((t (nil)))) '(custom-button-face ((t (:bold t)))) '(custom-changed-face ((t (:bold t :background "blue" :foreground "white")))) '(custom-comment-face ((t (:foreground "white")))) '(custom-comment-tag-face ((t (:foreground "white")))) '(custom-documentation-face ((t (:bold t)))) '(custom-face-tag-face ((t (:underline t :bold t)))) '(custom-group-tag-face ((t (:underline t :bold t :foreground "DarkBlue")))) '(custom-group-tag-face-1 ((t (:underline t :bold t :foreground "red")))) '(custom-invalid-face ((t (:bold t :background "red" :foreground "yellow")))) '(custom-modified-face ((t (:bold t :background "blue" :foreground "white")))) '(custom-rogue-face ((t (:bold t :background "black" :foreground "pink")))) '(custom-saved-face ((t (:underline t :bold t)))) '(custom-set-face ((t (:bold t :background "white" :foreground "blue")))) '(custom-state-face ((t (:bold t :foreground "dark green")))) '(custom-variable-button-face ((t (:underline t :bold t)))) '(custom-variable-tag-face ((t (:underline t :bold t :foreground "blue")))) '(cvs-filename-face ((t (:foreground "white")))) '(cvs-handled-face ((t (:foreground "pink")))) '(cvs-header-face ((t (:bold t :foreground "green")))) '(cvs-marked-face ((t (:bold t :foreground "green3")))) '(cvs-msg-face ((t (:italic t :foreground "red")))) '(cvs-need-action-face ((t (:foreground "yellow")))) '(cvs-unknown-face ((t (:foreground "grey")))) '(cyan ((t (:foreground "cyan")))) '(diary-face ((t (:bold t :foreground "red")))) '(diff-added-face ((t (nil)))) '(diff-changed-face ((t (nil)))) '(diff-file-header-face ((t (:bold t :background "grey70")))) '(diff-hunk-header-face ((t (:background "grey85")))) '(diff-index-face ((t (:bold t :background "grey70")))) '(diff-removed-face ((t (nil)))) '(dired-face-boring ((t (:foreground "Gray65")))) '(dired-face-directory ((t (:bold t)))) '(dired-face-executable ((t (:foreground "SeaGreen")))) '(dired-face-flagged ((t (:background "LightSlateGray")))) '(dired-face-header ((t (:background "grey75" :foreground "black")))) '(dired-face-marked ((t (:background "PaleVioletRed")))) '(dired-face-permissions ((t (:background "grey75" :foreground "black")))) '(dired-face-setuid ((t (:foreground "Red")))) '(dired-face-socket ((t (:foreground "magenta")))) '(dired-face-symlink ((t (:foreground "cyan")))) '(display-time-mail-balloon-enhance-face ((t (:bold t :background "orange")))) '(display-time-mail-balloon-gnus-group-face ((t (:bold t :foreground "blue")))) '(display-time-time-balloon-face ((t (:bold t :foreground "red")))) '(ediff-current-diff-face-A ((t (:background "pale green" :foreground "firebrick")))) '(ediff-current-diff-face-Ancestor ((t (:background "VioletRed" :foreground "Black")))) '(ediff-current-diff-face-B ((t (:background "Yellow" :foreground "DarkOrchid")))) '(ediff-current-diff-face-C ((t (:background "Pink" :foreground "Navy")))) '(ediff-even-diff-face-A ((t (:background "light grey" :foreground "Black")))) '(ediff-even-diff-face-Ancestor ((t (:background "Grey" :foreground "White")))) '(ediff-even-diff-face-B ((t (:background "Grey" :foreground "White")))) '(ediff-even-diff-face-C ((t (:background "light grey" :foreground "Black")))) '(ediff-fine-diff-face-A ((t (:background "sky blue" :foreground "Navy")))) '(ediff-fine-diff-face-Ancestor ((t (:background "Green" :foreground "Black")))) '(ediff-fine-diff-face-B ((t (:background "cyan" :foreground "Black")))) '(ediff-fine-diff-face-C ((t (:background "Turquoise" :foreground "Black")))) '(ediff-odd-diff-face-A ((t (:background "Grey" :foreground "White")))) '(ediff-odd-diff-face-Ancestor ((t (:background "light grey" :foreground "Black")))) '(ediff-odd-diff-face-B ((t (:background "light grey" :foreground "Black")))) '(ediff-odd-diff-face-C ((t (:background "Grey" :foreground "White")))) '(erc-action-face ((t (:bold t)))) '(erc-bold-face ((t (:bold t)))) '(erc-default-face ((t (nil)))) '(erc-direct-msg-face ((t (nil)))) '(erc-error-face ((t (:bold t)))) '(erc-input-face ((t (nil)))) '(erc-inverse-face ((t (nil)))) '(erc-notice-face ((t (nil)))) '(erc-pal-face ((t (nil)))) '(erc-prompt-face ((t (nil)))) '(erc-underline-face ((t (nil)))) '(eshell-ls-archive-face ((t (:bold t :foreground "Orchid")))) '(eshell-ls-backup-face ((t (:foreground "OrangeRed")))) '(eshell-ls-clutter-face ((t (:bold t :foreground "OrangeRed")))) '(eshell-ls-directory-face ((t (:bold t :foreground "Blue")))) '(eshell-ls-executable-face ((t (:bold t :foreground "ForestGreen")))) '(eshell-ls-missing-face ((t (:bold t :foreground "Red")))) '(eshell-ls-picture-face ((t (:foreground "Violet")))) '(eshell-ls-product-face ((t (:foreground "OrangeRed")))) '(eshell-ls-readonly-face ((t (:foreground "Brown")))) '(eshell-ls-special-face ((t (:bold t :foreground "Magenta")))) '(eshell-ls-symlink-face ((t (:bold t :foreground "DarkCyan")))) '(eshell-ls-text-face ((t (:foreground "medium aquamarine")))) '(eshell-ls-todo-face ((t (:bold t :foreground "aquamarine")))) '(eshell-ls-unreadable-face ((t (:foreground "Grey30")))) '(eshell-prompt-face ((t (:bold t :foreground "Red")))) '(eshell-test-failed-face ((t (:bold t :foreground "OrangeRed")))) '(eshell-test-ok-face ((t (:bold t :foreground "Green")))) '(excerpt ((t (:italic t)))) '(ff-paths-non-existant-file-face ((t (:bold t :foreground "NavyBlue")))) '(fg:black ((t (:foreground "black")))) '(fixed ((t (:bold t)))) '(fl-comment-face ((t (:foreground "medium purple")))) '(fl-doc-string-face ((t (nil)))) '(fl-function-name-face ((t (:foreground "green")))) '(fl-keyword-face ((t (:foreground "LightGreen")))) '(fl-string-face ((t (:foreground "light coral")))) '(fl-type-face ((t (:foreground "cyan")))) '(flyspell-duplicate-face ((t (:underline t :bold t :foreground "Gold3")))) '(flyspell-incorrect-face ((t (:underline t :bold t :foreground "OrangeRed")))) '(font-latex-bold-face ((t (:bold t)))) '(font-latex-italic-face ((t (:italic t)))) '(font-latex-math-face ((t (nil)))) '(font-latex-sedate-face ((t (nil)))) '(font-latex-string-face ((t (nil)))) '(font-latex-warning-face ((t (nil)))) '(font-lock-builtin-face ((t (:italic t :bold t :foreground "Orchid")))) '(font-lock-comment-face ((t (:bold t :foreground "Firebrick")))) '(font-lock-constant-face ((t (:italic t :bold t :foreground "CadetBlue")))) '(font-lock-doc-string-face ((t (:italic t :bold t :foreground "green4")))) '(font-lock-emphasized-face ((t (:bold t)))) '(font-lock-exit-face ((t (:foreground "green")))) '(font-lock-function-name-face ((t (:italic t :bold t :foreground "Blue")))) '(font-lock-keyword-face ((t (:bold t :foreground "dark olive green")))) '(font-lock-other-emphasized-face ((t (:italic t :bold t)))) '(font-lock-other-type-face ((t (:bold t :foreground "DarkBlue")))) '(font-lock-preprocessor-face ((t (:italic t :bold t :foreground "blue3")))) '(font-lock-reference-face ((t (:italic t :bold t :foreground "red3")))) '(font-lock-special-comment-face ((t (nil)))) '(font-lock-special-keyword-face ((t (nil)))) '(font-lock-string-face ((t (:italic t :bold t :foreground "DarkBlue")))) '(font-lock-type-face ((t (:italic t :bold t :foreground "DarkGreen")))) '(font-lock-variable-name-face ((t (:italic t :bold t :foreground "darkgreen")))) '(font-lock-warning-face ((t (:bold t :foreground "Red")))) '(fringe ((t (:background "grey95")))) '(gdb-arrow-face ((t (:bold t)))) '(gnus-cite-attribution-face ((t (:italic t :bold t)))) '(gnus-cite-face-1 ((t (:bold t :foreground "MidnightBlue")))) '(gnus-cite-face-10 ((t (:foreground "medium purple")))) '(gnus-cite-face-11 ((t (:foreground "turquoise")))) '(gnus-cite-face-2 ((t (:bold t :foreground "firebrick")))) '(gnus-cite-face-3 ((t (:bold t :foreground "dark green")))) '(gnus-cite-face-4 ((t (:foreground "OrangeRed")))) '(gnus-cite-face-5 ((t (:foreground "dark khaki")))) '(gnus-cite-face-6 ((t (:bold t :foreground "dark violet")))) '(gnus-cite-face-7 ((t (:foreground "SteelBlue4")))) '(gnus-cite-face-8 ((t (:foreground "magenta")))) '(gnus-cite-face-9 ((t (:foreground "violet")))) '(gnus-cite-face-list ((t (nil)))) '(gnus-emphasis-bold ((t (:bold t)))) '(gnus-emphasis-bold-italic ((t (:italic t :bold t)))) '(gnus-emphasis-highlight-words ((t (:background "black" :foreground "yellow")))) '(gnus-emphasis-italic ((t (:italic t)))) '(gnus-emphasis-underline ((t (:underline t)))) '(gnus-emphasis-underline-bold ((t (:underline t :bold t)))) '(gnus-emphasis-underline-bold-italic ((t (:underline t :italic t :bold t)))) '(gnus-emphasis-underline-italic ((t (:underline t :italic t)))) '(gnus-filterhist-face-1 ((t (nil)))) '(gnus-group-mail-1-empty-face ((t (:foreground "DeepPink3")))) '(gnus-group-mail-1-face ((t (:bold t :foreground "DeepPink3")))) '(gnus-group-mail-2-empty-face ((t (:foreground "HotPink3")))) '(gnus-group-mail-2-face ((t (:bold t :foreground "HotPink3")))) '(gnus-group-mail-3-empty-face ((t (:foreground "magenta4")))) '(gnus-group-mail-3-face ((t (:bold t :foreground "magenta4")))) '(gnus-group-mail-low-empty-face ((t (:foreground "DeepPink4")))) '(gnus-group-mail-low-face ((t (:bold t :foreground "DeepPink4")))) '(gnus-group-news-1-empty-face ((t (:foreground "ForestGreen")))) '(gnus-group-news-1-face ((t (:bold t :foreground "ForestGreen")))) '(gnus-group-news-2-empty-face ((t (:foreground "CadetBlue4")))) '(gnus-group-news-2-face ((t (:bold t :foreground "CadetBlue4")))) '(gnus-group-news-3-empty-face ((t (nil)))) '(gnus-group-news-3-face ((t (:bold t)))) '(gnus-group-news-4-empty-face ((t (nil)))) '(gnus-group-news-4-face ((t (:bold t)))) '(gnus-group-news-5-empty-face ((t (nil)))) '(gnus-group-news-5-face ((t (:bold t)))) '(gnus-group-news-6-empty-face ((t (nil)))) '(gnus-group-news-6-face ((t (:bold t)))) '(gnus-group-news-low-empty-face ((t (:foreground "DarkGreen")))) '(gnus-group-news-low-face ((t (:bold t :foreground "DarkGreen")))) '(gnus-header-content-face ((t (:italic t :foreground "indianred4")))) '(gnus-header-from-face ((t (:bold t :foreground "red3")))) '(gnus-header-name-face ((t (:bold t :foreground "maroon")))) '(gnus-header-newsgroups-face ((t (:italic t :bold t :foreground "MidnightBlue")))) '(gnus-header-subject-face ((t (:bold t :foreground "red4")))) '(gnus-picons-face ((t (:background "white" :foreground "black")))) '(gnus-picons-xbm-face ((t (:background "white" :foreground "black")))) '(gnus-signature-face ((t (:italic t :bold t)))) '(gnus-splash ((t (nil)))) '(gnus-splash-face ((t (:foreground "Brown")))) '(gnus-summary-cancelled-face ((t (:background "black" :foreground "yellow")))) '(gnus-summary-high-ancient-face ((t (:bold t :foreground "RoyalBlue")))) '(gnus-summary-high-read-face ((t (:bold t :foreground "DarkGreen")))) '(gnus-summary-high-ticked-face ((t (:bold t :foreground "firebrick")))) '(gnus-summary-high-unread-face ((t (:italic t :bold t)))) '(gnus-summary-low-ancient-face ((t (:italic t :foreground "RoyalBlue")))) '(gnus-summary-low-read-face ((t (:italic t :foreground "DarkGreen")))) '(gnus-summary-low-ticked-face ((t (:italic t :bold t :foreground "firebrick")))) '(gnus-summary-low-unread-face ((t (:italic t)))) '(gnus-summary-normal-ancient-face ((t (:foreground "RoyalBlue")))) '(gnus-summary-normal-read-face ((t (:foreground "DarkGreen")))) '(gnus-summary-normal-ticked-face ((t (:bold t :foreground "firebrick")))) '(gnus-summary-normal-unread-face ((t (:bold t)))) '(gnus-summary-selected-face ((t (:underline t)))) '(gnus-x-face ((t (:background "white" :foreground "black")))) '(green ((t (:bold t :foreground "green")))) '(gui-button-face ((t (:bold t :background "grey75" :foreground "black")))) '(gui-element ((t (:bold t :background "Gray80")))) '(highlight ((t (:bold t :background "darkseagreen2")))) '(highlight-changes-delete-face ((t (:underline t :foreground "red")))) '(highlight-changes-face ((t (:foreground "red")))) '(highline-face ((t (:background "black" :foreground "white")))) '(holiday-face ((t (:bold t :background "pink" :foreground "white")))) '(hproperty:but-face ((t (:bold t)))) '(hproperty:flash-face ((t (:bold t)))) '(hproperty:highlight-face ((t (:bold t)))) '(hproperty:item-face ((t (:bold t)))) '(html-helper-bold-face ((t (:bold t)))) '(html-helper-bold-italic-face ((t (nil)))) '(html-helper-builtin-face ((t (:underline t :foreground "blue3")))) '(html-helper-italic-face ((t (:italic t :bold t :foreground "yellow")))) '(html-helper-underline-face ((t (:underline t)))) '(html-tag-face ((t (:bold t)))) '(hyper-apropos-documentation ((t (:foreground "white")))) '(hyper-apropos-heading ((t (:bold t)))) '(hyper-apropos-hyperlink ((t (:foreground "sky blue")))) '(hyper-apropos-major-heading ((t (:bold t)))) '(hyper-apropos-section-heading ((t (:bold t)))) '(hyper-apropos-warning ((t (:bold t :foreground "red")))) '(ibuffer-marked-face ((t (:foreground "red")))) '(info-menu-5 ((t (:underline t :bold t)))) '(info-menu-6 ((t (nil)))) '(info-node ((t (:italic t :bold t)))) '(info-xref ((t (:bold t)))) '(isearch ((t (:bold t :background "paleturquoise")))) '(isearch-secondary ((t (:foreground "red3")))) '(ispell-face ((t (:bold t)))) '(italic ((t (:italic t :bold t)))) '(jde-bug-breakpoint-cursor ((t (:background "brown" :foreground "cyan")))) '(jde-bug-breakpoint-marker ((t (:background "yellow" :foreground "red")))) '(jde-java-font-lock-link-face ((t (:underline t :foreground "blue")))) '(jde-java-font-lock-number-face ((t (:foreground "RosyBrown")))) '(lazy-highlight-face ((t (:bold t :foreground "dark magenta")))) '(left-margin ((t (:bold t)))) '(linemenu-face ((t (nil)))) '(list-mode-item-selected ((t (:bold t :background "gray68")))) '(magenta ((t (:foreground "magenta")))) '(makefile-space-face ((t (:background "hotpink")))) '(man-bold ((t (:bold t)))) '(man-heading ((t (:bold t)))) '(man-italic ((t (:foreground "yellow")))) '(man-xref ((t (:underline t)))) '(message-cited-text ((t (:bold t :foreground "orange")))) '(message-cited-text-face ((t (:bold t :foreground "red")))) '(message-header-cc-face ((t (:bold t :foreground "MidnightBlue")))) '(message-header-contents ((t (:italic t :bold t :foreground "white")))) '(message-header-name-face ((t (:bold t :foreground "cornflower blue")))) '(message-header-newsgroups-face ((t (:italic t :bold t :foreground "blue4")))) '(message-header-other-face ((t (:bold t :foreground "steel blue")))) '(message-header-subject-face ((t (:bold t :foreground "navy blue")))) '(message-header-to-face ((t (:bold t :foreground "MidnightBlue")))) '(message-header-xheader-face ((t (:bold t :foreground "blue")))) '(message-headers ((t (:bold t :foreground "orange")))) '(message-highlighted-header-contents ((t (:bold t)))) '(message-mml-face ((t (:bold t :foreground "ForestGreen")))) '(message-separator-face ((t (:foreground "brown")))) '(message-url ((t (:bold t :foreground "pink")))) '(mmm-face ((t (:background "black" :foreground "green")))) '(modeline ((t (:bold t :background "Black" :foreground "#CA94AA469193")))) '(modeline-buffer-id ((t (:bold t :background "Gray80" :foreground "blue4")))) '(modeline-mousable ((t (:bold t :background "Gray80" :foreground "firebrick")))) '(modeline-mousable-minor-mode ((t (:bold t :background "Gray80" :foreground "green4")))) '(my-tab-face ((t (nil)))) '(nil ((t (nil)))) '(p4-diff-del-face ((t (:bold t)))) '(paren-blink-off ((t (:foreground "gray80")))) '(paren-face ((t (nil)))) '(paren-face-match ((t (nil)))) '(paren-face-mismatch ((t (nil)))) '(paren-face-no-match ((t (nil)))) '(paren-match ((t (:background "darkseagreen2")))) '(paren-mismatch ((t (:background "DeepPink" :foreground "black")))) '(paren-mismatch-face ((t (:bold t :background "DeepPink" :foreground "white")))) '(paren-no-match-face ((t (:bold t :background "yellow" :foreground "white")))) '(pointer ((t (:bold t)))) '(primary-selection ((t (:bold t :background "gray65")))) '(red ((t (:bold t :foreground "red")))) '(region ((t (:bold t :background "gray")))) '(right-margin ((t (:bold t)))) '(searchm-buffer ((t (:bold t)))) '(searchm-button ((t (:bold t)))) '(searchm-field ((t (nil)))) '(searchm-field-label ((t (:bold t)))) '(searchm-highlight ((t (:bold t)))) '(secondary-selection ((t (:bold t :background "paleturquoise")))) '(semantic-intangible-face ((t (:foreground "gray25")))) '(semantic-read-only-face ((t (:background "gray25")))) '(senator-momentary-highlight-face ((t (:background "gray70")))) '(setnu-line-number-face ((t (:italic t :bold t)))) '(sgml-comment-face ((t (:foreground "dark green")))) '(sgml-doctype-face ((t (:foreground "maroon")))) '(sgml-end-tag-face ((t (:foreground "blue2")))) '(sgml-entity-face ((t (:foreground "red2")))) '(sgml-ignored-face ((t (:background "gray90" :foreground "maroon")))) '(sgml-ms-end-face ((t (:foreground "maroon")))) '(sgml-ms-start-face ((t (:foreground "maroon")))) '(sgml-pi-face ((t (:foreground "maroon")))) '(sgml-sgml-face ((t (:foreground "maroon")))) '(sgml-short-ref-face ((t (:foreground "goldenrod")))) '(sgml-start-tag-face ((t (:foreground "blue2")))) '(shell-input-face ((t (:bold t)))) '(shell-option-face ((t (:bold t :foreground "blue4")))) '(shell-output-2-face ((t (:bold t :foreground "green4")))) '(shell-output-3-face ((t (:bold t :foreground "green4")))) '(shell-output-face ((t (:bold t)))) '(shell-prompt-face ((t (:bold t :foreground "red4")))) '(show-paren-match-face ((t (:bold t :background "turquoise")))) '(show-paren-mismatch-face ((t (:bold t :background "purple" :foreground "white")))) '(speedbar-button-face ((t (:bold t :foreground "magenta")))) '(speedbar-directory-face ((t (:bold t :foreground "orchid")))) '(speedbar-file-face ((t (:bold t :foreground "pink")))) '(speedbar-highlight-face ((t (:background "black")))) '(speedbar-selected-face ((t (:underline t :foreground "cyan")))) '(speedbar-tag-face ((t (:foreground "yellow")))) '(swbuff-current-buffer-face ((t (:bold t :foreground "red")))) '(template-message-face ((t (:bold t)))) '(term-black ((t (:foreground "black")))) '(term-blackbg ((t (:background "black")))) '(term-blue ((t (:foreground "blue")))) '(term-blue-bold-face ((t (:bold t :background "snow2" :foreground "blue")))) '(term-blue-face ((t (:foreground "blue")))) '(term-blue-inv-face ((t (:background "blue")))) '(term-blue-ul-face ((t (:underline t :background "snow2" :foreground "blue")))) '(term-bluebg ((t (:background "blue")))) '(term-bold ((t (:bold t)))) '(term-cyan ((t (:foreground "cyan")))) '(term-cyan-bold-face ((t (:bold t :background "snow2" :foreground "cyan")))) '(term-cyan-face ((t (:foreground "cyan")))) '(term-cyan-inv-face ((t (:background "cyan")))) '(term-cyan-ul-face ((t (:underline t :background "snow2" :foreground "cyan")))) '(term-cyanbg ((t (:background "cyan")))) '(term-default-bg ((t (nil)))) '(term-default-bg-inv ((t (nil)))) '(term-default-bold-face ((t (:bold t :background "snow2" :foreground "darkslategray")))) '(term-default-face ((t (:background "snow2" :foreground "darkslategray")))) '(term-default-fg ((t (nil)))) '(term-default-fg-inv ((t (nil)))) '(term-default-inv-face ((t (:background "darkslategray" :foreground "snow2")))) '(term-default-ul-face ((t (:underline t :background "snow2" :foreground "darkslategray")))) '(term-green ((t (:foreground "green")))) '(term-green-bold-face ((t (:bold t :background "snow2" :foreground "green")))) '(term-green-face ((t (:foreground "green")))) '(term-green-inv-face ((t (:background "green")))) '(term-green-ul-face ((t (:underline t :background "snow2" :foreground "green")))) '(term-greenbg ((t (:background "green")))) '(term-invisible ((t (nil)))) '(term-invisible-inv ((t (nil)))) '(term-magenta ((t (:foreground "magenta")))) '(term-magenta-bold-face ((t (:bold t :background "snow2" :foreground "magenta")))) '(term-magenta-face ((t (:foreground "magenta")))) '(term-magenta-inv-face ((t (:background "magenta")))) '(term-magenta-ul-face ((t (:underline t :background "snow2" :foreground "magenta")))) '(term-magentabg ((t (:background "magenta")))) '(term-red ((t (:foreground "red")))) '(term-red-bold-face ((t (:bold t :background "snow2" :foreground "red")))) '(term-red-face ((t (:foreground "red")))) '(term-red-inv-face ((t (:background "red")))) '(term-red-ul-face ((t (:underline t :background "snow2" :foreground "red")))) '(term-redbg ((t (:background "red")))) '(term-underline ((t (:underline t)))) '(term-white ((t (:foreground "white")))) '(term-white-bold-face ((t (:bold t :background "snow2" :foreground "white")))) '(term-white-face ((t (:foreground "white")))) '(term-white-inv-face ((t (:background "snow2")))) '(term-white-ul-face ((t (:underline t :background "snow2" :foreground "white")))) '(term-whitebg ((t (:background "white")))) '(term-yellow ((t (:foreground "yellow")))) '(term-yellow-bold-face ((t (:bold t :background "snow2" :foreground "yellow")))) '(term-yellow-face ((t (:foreground "yellow")))) '(term-yellow-inv-face ((t (:background "yellow")))) '(term-yellow-ul-face ((t (:underline t :background "snow2" :foreground "yellow")))) '(term-yellowbg ((t (:background "yellow")))) '(text-cursor ((t (:bold t :background "Red3" :foreground "gray80")))) '(toolbar ((t (:bold t :background "Gray80")))) '(underline ((t (:underline t :bold t)))) '(vc-annotate-face-0046FF ((t (nil)))) '(vcursor ((t (:underline t :background "cyan" :foreground "blue")))) '(vertical-divider ((t (:bold t :background "Gray80")))) '(vhdl-font-lock-attribute-face ((t (:foreground "Orchid")))) '(vhdl-font-lock-directive-face ((t (:foreground "CadetBlue")))) '(vhdl-font-lock-enumvalue-face ((t (:foreground "Gold4")))) '(vhdl-font-lock-function-face ((t (:foreground "Orchid4")))) '(vhdl-font-lock-generic-/constant-face ((t (nil)))) '(vhdl-font-lock-prompt-face ((t (:bold t :foreground "Red")))) '(vhdl-font-lock-reserved-words-face ((t (:bold t :foreground "Orange")))) '(vhdl-font-lock-translate-off-face ((t (:background "LightGray")))) '(vhdl-font-lock-type-face ((t (nil)))) '(vhdl-font-lock-variable-face ((t (nil)))) '(vhdl-speedbar-architecture-face ((t (:foreground "Blue")))) '(vhdl-speedbar-architecture-selected-face ((t (:underline t :foreground "Blue")))) '(vhdl-speedbar-configuration-face ((t (:foreground "DarkGoldenrod")))) '(vhdl-speedbar-configuration-selected-face ((t (:underline t :foreground "DarkGoldenrod")))) '(vhdl-speedbar-entity-face ((t (:foreground "ForestGreen")))) '(vhdl-speedbar-entity-selected-face ((t (:underline t :foreground "ForestGreen")))) '(vhdl-speedbar-instantiation-face ((t (:foreground "Brown")))) '(vhdl-speedbar-instantiation-selected-face ((t (:underline t :foreground "Brown")))) '(vhdl-speedbar-package-face ((t (:foreground "Grey50")))) '(vhdl-speedbar-package-selected-face ((t (:underline t :foreground "Grey50")))) '(vhdl-speedbar-subprogram-face ((t (nil)))) '(viper-minibuffer-emacs-face ((t (:background "darkseagreen2" :foreground "Black")))) '(viper-minibuffer-insert-face ((t (:background "pink" :foreground "Black")))) '(viper-minibuffer-vi-face ((t (:background "grey" :foreground "DarkGreen")))) '(viper-replace-overlay-face ((t (:background "darkseagreen2" :foreground "Black")))) '(viper-search-face ((t (:background "khaki" :foreground "Black")))) '(vm-xface ((t (:background "white" :foreground "black")))) '(vmpc-pre-sig-face ((t (:foreground "forestgreen")))) '(vmpc-sig-face ((t (:foreground "steelblue")))) '(vvb-face ((t (nil)))) '(w3m-anchor-face ((t (:bold t :foreground "DodgerBlue1")))) '(w3m-arrived-anchor-face ((t (:bold t :foreground "DodgerBlue3")))) '(w3m-header-line-location-content-face ((t (:background "dark olive green" :foreground "wheat")))) '(w3m-header-line-location-title-face ((t (:background "dark olive green" :foreground "beige")))) '(white ((t (:foreground "white")))) '(widget ((t (nil)))) '(widget-button-face ((t (:bold t)))) '(widget-button-pressed-face ((t (:bold t :foreground "red")))) '(widget-documentation-face ((t (:bold t :foreground "dark green")))) '(widget-field-face ((t (:bold t :background "gray85")))) '(widget-inactive-face ((t (:bold t :foreground "dim gray")))) '(widget-single-line-field-face ((t (:background "gray85")))) '(woman-bold-face ((t (:bold t)))) '(woman-italic-face ((t (:foreground "beige")))) '(woman-unknown-face ((t (:foreground "LightSalmon")))) '(x-face ((t (:bold t :background "white" :foreground "black")))) '(x-symbol-adobe-fontspecific-face ((t (nil)))) '(x-symbol-face ((t (nil)))) '(x-symbol-heading-face ((t (:bold t)))) '(x-symbol-info-face ((t (nil)))) '(x-symbol-invisible-face ((t (nil)))) '(x-symbol-revealed-face ((t (nil)))) '(xrdb-option-name-face ((t (:foreground "red")))) '(xref-keyword-face ((t (:foreground "blue")))) '(xref-list-default-face ((t (nil)))) '(xref-list-pilot-face ((t (:foreground "navy")))) '(xref-list-symbol-face ((t (:foreground "navy")))) '(yellow ((t (:bold t :foreground "yellow")))) '(zmacs-region ((t (:bold t :background "gray65"))))) ``` # Answer > 0 votes Emacs calls the set of styles that change character colors, highlighting, underlining, etc, a face. If we find out the face that is being used for these variables, we can customize it to have different colors. We can use `what-cursor-position` (bound to `C-x =` to find out face information: > Print info on cursor position (on screen and within buffer). > > In addition, with prefix argument, show details about that character in \*Help\* buffer. So, first move point to a character in the variable you want to change, then press `C-u C-x =`. You'll see a `*Help*` buffer pop up, with, among other things in it, text like this sample: ``` There are text properties here: font-lock-face magit-diff-added-highlight ``` So we see that the face is `magit-diff-added-highlight`, which we can change to be what we want -- perhaps using `M-x customize-face`, or any other preferred method. --- Tags: themes, colors ---
thread-53758
https://emacs.stackexchange.com/questions/53758
Is it possible to have multiple *Find* buffers in emacs?
2019-11-15T14:18:52.410
# Question Title: Is it possible to have multiple *Find* buffers in emacs? If I execute a `M-x find-name-dired` command the output is a `*Find*` buffer containing the results. However if I perform a subsequent `find-name-dired` the contents of the `*Find*` buffer are overwritten with the latest output. Is there a means to execute multiple `find-name-dired` commands and keep the output buffer of each? In other words, have multiple `*Find*` buffers? # Answer Looking at the code, `find-name-dired` delegates to `find-dired`. Looking at the `find-dired` code, it opens a buffer with name `"*Find*"`. From its source: ``` (get-buffer-create "*Find*") ``` So if we rename the first buffer we made, the second call to `find-name-dired` will not touch it. You can rename the buffer with `M-x rename-buffer` (lets you choose a name) or `M-x rename-uniquely` (adds a numerical suffix `<2>`, `<3>`, …). Rather than renaming by hand, here's a wrapper function around `find-name-dired` that changes the buffer name after it's ran. Note that it will reuse any preexisting buffer called `*Find*`, so prior searches ran with `find-name-dired` or other find commands will go away. ``` (defun find-name-dired-with-unique-buffer-name (dir pattern) "Search DIR recursively for files matching the globbing pattern PATTERN, and run Dired on those files. PATTERN is a shell wildcard (not an Emacs regexp) and need not be quoted. The default command run (after changing into DIR) is find . -name \\='PATTERN\\=' -ls See `find-name-arg' to customize the arguments." (interactive "DFind-name (directory): \nsFind-name (filename wildcard): ") (find-name-dired dir pattern) (let ((buffer-name (format "*Find: %s in %s*" pattern dir))) "If we previously searched for the same thing, kill that buffer for reuse" (when (get-buffer buffer-name) (kill-buffer buffer-name)) ;;we are left in a buffer called "*Find*" (rename-buffer buffer-name))) ``` > 4 votes # Answer If you use library **`find-dired+.el`** then the buffer used is *not* `*Find*`. Instead, it has same name (using `directory-file-name`) as argument `DIR` (the directory). So if you change directory then you get a different buffer. If that's not enough then you can always use hook `find-dired-hook` to rename the buffer each time (or whatever). > 2 votes --- Tags: dired ---
thread-53764
https://emacs.stackexchange.com/questions/53764
How to exit read-only mode
2019-11-15T16:35:47.430
# Question Title: How to exit read-only mode I have a buffer in read-only mode. Killing the buffer and reopening it does not do the job while restarting emacs does. How to exit the read-only mode without restarting emacs? # Answer > 15 votes Calling `read-only-mode` toggles between read-only and edit mode for the current buffer. You can call this via `M-x read-only-mode` or with `C-x C-q`. # Answer > 10 votes To add a bit to @Juancho's answer, which is correct: The default value of `read-only-mode` depends on the buffer. In particular, if it is visiting a *file*, and if the file itself is read-only, then the default value of `read-only-mode` will be *on*. You can toggle such a buffer, as @Juancho said, to turn off `read-only-mode`. But if you try to save the buffer after changing it you'll be prompted to confirm, like this: ``` File foo.el is write-protected; try to save anyway? (yes or no) ``` And if you answer `yes` you may be presented with an error such as this: ``` Opening output file: Permission denied, /path/to/foo.el ``` # Answer > 4 votes I like very much to click on the `buffer-read-only` indicator `%` in the mode line for that purpose. It is marked with a red ellipse in the following Figure. It just feels natural to toggle the read only state where it is indicated. Note that you can also toggle the `buffer-modified-p` flag on the right side of the `buffer-read-only` flag. This is sometimes handy when you just want to kill a modified buffer avoiding backup copies. --- Tags: read-only-mode ---
thread-53774
https://emacs.stackexchange.com/questions/53774
Evil key bindings with evil-define-key do opposite of what I want?
2019-11-15T20:47:53.853
# Question Title: Evil key bindings with evil-define-key do opposite of what I want? Below is the entirety of my Evil key bindings in `init.el`: ``` (evil-define-key 'normal 'global (kbd "SPC") (make-sparse-keymap)) (evil-define-key 'normal 'global (kbd "SPC TAB") #'ivy-switch-buffer) (evil-define-key 'normal 'Info-mode-map (kbd "SPC") (make-sparse-keymap)) (evil-define-key 'normal 'Info-mode-map (kbd "SPC SPC") #'Info-scroll-up) ``` The end result of this is as follows: * In `Emacs-Lisp` mode, `SPC TAB` is bound to `ivy-switch-buffer`; this is expected. * In `Emacs-Lisp` mode, `SPC SPC` is bound to `Info-scroll-up`; this is unexpected. * In `Info` mode, `SPC TAB` is undefined; this is unexpected. * In `Info` mode, `SPC SPC` is bound to `Info-scroll-up`; this is expected. It seems to me (in one sentence) that the global config is not global and the local config is global. This is the opposite of what I would expect. The `Info-scroll-up` binding is defined on `Info-mode-map` and has effect even when `Info` mode is not active. Why? The `ivy-switch-buffer` binding is defined globally, but does not work when I am in `Info` mode. Not only does it not work, but it is undefined. It's not that `SPC TAB` has been replaced by another command, `SPC TAB` is undefined (and `SPC` is a prefix key). Why? I can't form any mental model of why Evil / Emacs is behaving this way. Why is it behaving this way? # Answer > 1 votes This works as expected: ``` (evil-define-key 'normal 'global (kbd "SPC") (make-sparse-keymap)) (evil-define-key 'normal 'global (kbd "SPC TAB") #'ivy-switch-buffer) (evil-define-key 'normal Info-mode-map (kbd "SPC") (make-sparse-keymap)) (evil-define-key 'normal Info-mode-map (kbd "SPC SPC") #'Info-scroll-up) ``` Notice that `Info-mode-map` is not quoted like it was in the original question. The `evil-define-key` docs mention you can pass `'global'` or `'local` as the second argument. I'm not sure what it does if you give it some other quoted value like I was doing, but now that I'm calling `evil-define-key` correctly it works the way I would expect. --- Tags: key-bindings, evil ---
thread-53776
https://emacs.stackexchange.com/questions/53776
What does it mean to type the "at" symbol in `C-c @ C-h`?
2019-11-15T23:19:54.797
# Question Title: What does it mean to type the "at" symbol in `C-c @ C-h`? I'm using hideshow and I like it. The package is recommending me that I use the keys `C-c @ C-h` to hide a block instead of typing some really long command. I'm familiar with `C-c` and with `C-h`, but I can't figure out what the `@` means. # Answer `@` doesn't mean anything, by itself, beside representing the `@` key on your keyboard. The key sequence `C-c @ C-h` is bound to command `hs-hide-block` in `hs-minor-mode`, that is, in keymap `hs-minor-mode-map`. * In that key sequence, `C-c` is a *prefix key*, which means it's bound to a *keymap*. * In that keymap, `@` is a *prefix key*, which means it's bound to a *keymap*. * In that keymap, `C-h` is bound to *command* `hs-hide-block` --- In `hs-minor-mode`, type `C-c C-h` to see the key bindings on prefix key `C-c`. Conventionally, typing `C-h` after a prefix key shows you all of the keys on that prefix key. Prefix key `C-c @` disobeys this convention, so `C-c @ C-h` does **not** show you all the keys on prefix key `C-c @`. Instead, it gives you `hs-hide-block`. (IMHO, that's unfortunate, but presumably the author thought otherwise.) > 2 votes # Answer > I'm familiar with C-c and with C-h, but I can't figure out what the @ means. It's the literal character `@` for which your keyboard should have a key (or key sequence). On my keyboard `@` is `Shift+2`. So just type `Ctrl+C` and then type `@` Conceptually it's no different to being told to type `C-c a` (for example). > 2 votes --- Tags: key-bindings, keymap, help, prefix-keys ---
thread-31646
https://emacs.stackexchange.com/questions/31646
how to paste with indent
2017-03-23T13:06:42.590
# Question Title: how to paste with indent the code block I copy outside emacs, which is not auto-indent when yanking in org type `org-return-indent` -\> yank code block -\> indent manually: ``` *** headline | v *** headline { code block } v *** headline { code block } ``` expecting the yank and indent in a one step # Answer Here is a elisp function that should do what you want ``` (defun yank-with-indent () (interactive) (let ((indent (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (message indent) (yank) (narrow-to-region (mark t) (point)) (pop-to-mark-command) (replace-string "\n" (concat "\n" indent)) (widen))) ``` > 1 votes # Answer @native-human congratulations for this very useful snippet! But after using it I found that it removes narrow-to-region and so breaks my org workflow. To fix it I added a few lines to preserve narrowing: ``` (defun yank-with-indent () (interactive) (let ((indent (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (message indent) (yank) (save-excursion (save-restriction (narrow-to-region (mark t) (point)) (pop-to-mark-command) (replace-string "\n" (concat "\n" indent)) (widen))))) ``` (define-key org-mode-map (kbd "C-c y") 'yank-with-indent) > 2 votes # Answer Here is a different approach, maybe someone will find this useful. This is a minor mode that patches `get-text-property` to fake the property `'yank-handler`, which indicates which function to use for inserting. Then I use `insert-rectangle` for that. That way, this also works with `helm-ring`. ``` (defvar my/is-rectangle-yanking nil) (defun my/insert-rectangle-split (string) (let ((rows (split-string string "\n")) (my/is-rectangle-yanking t)) (save-excursion (insert (make-string (length rows) ?\n))) (insert-rectangle rows) (delete-char 1))) (defun my/get-text-property-rectangle-yank (fun pos prop &optional object) (let ((propv (funcall fun pos prop object))) (if propv propv (when (and (eq prop 'yank-handler) (stringp object) (not my/is-rectangle-yanking)) '(my/insert-rectangle-split))))) (define-global-minor-mode my/yank-as-rectangle "Minor mode to yank as rectangle. This patches `get-text-property' to put `insert-rectangle' as the insert function (`yank-handler')." :init-value nil :lighter " Rec" (if (not my/yank-as-rectangle) (advice-remove 'get-text-property #'my/get-text-property-rectangle-yank) (advice-add 'get-text-property :around #'my/get-text-property-rectangle-yank))) ``` > 1 votes --- Tags: org-mode, indentation, copy-paste ---
thread-53780
https://emacs.stackexchange.com/questions/53780
(un)-Indenting text over a region
2019-11-16T09:53:10.143
# Question Title: (un)-Indenting text over a region This in org mode. How do I get from * 1 to 2 * 2 to 3 in as few keystrokes as possible? And, if possible, in reverse. I was hoping selecting Food's subtree and `M-^` would do the job but what it does instead is delete subsequent lines. # 1 ``` * Food This is the body, which says something about the topic of food. ** Delicious Food This is the body of the second-level header. ** Distasteful Food This could have a body too, with several lines. *** Dormitory Food * Shelter Another first-level topic with its header line. ``` # 2 ``` * Food This is the body, which says something about the topic of food. ** Delicious Food This is the body of the second-level header. ** Distasteful Food This could have a body too, with several lines. *** Dormitory Food * Shelter Another first-level topic with its header line. ``` # 3 ``` * Food This is the body, which says something about the topic of food. ** Delicious Food This is the body of the second-level header. ** Distasteful Food This could have a body too, with several lines. *** Dormitory Food * Shelter Another first-level topic with its header line. ``` # Answer > 4 votes ## From 1, 3 to 2 * Select all text: `C-x h` * Remove indentation: `M-x` `close-rectangle` `RET` (Although kind of a hacky use of `close-rectangle`.) ## From 1, 2 to 3 * Select all text: `C-x h` * `indent-region`: `C-M-\` ## From 3 to 1 With point at start of buffer: `M-x` `replace-regexp` `RET` `^ +` `RET` `<4 spaces>` `RET` # Answer > 0 votes `C-x h C-M-\` goes directly from 1 to 3 The first part (`C-x h`) runs the command `mark-whole-buffer`, the second (`C-M-\`) runs `indent-region`. You can go from 1 or 3 to 2 with `C-M-% ^ + RET RET`, that runs the command `query-replace-regexp` to replace any sequence of whitespaces at the beginning of line with nothing. I don't know how to easily revert the change. --- Tags: org-mode, indentation ---
thread-53516
https://emacs.stackexchange.com/questions/53516
How to disable syntactic indentation interactively in php-mode?
2019-11-02T17:39:38.650
# Question Title: How to disable syntactic indentation interactively in php-mode? I discovered that in php-mode, syntactic indentation makes rigid indentation very slow when the marked region is big. When I disable syntactic indentation, rigid indentation is not slow anymore. So I made functions that disable syntactic indentation before indenting rigidly. ``` (defun my/indent-region-left-tab () (interactive) (c-toggle-syntactic-indentation -1) (indent-rigidly (region-beginning) (region-end) -4) (c-toggle-syntactic-indentation 1) (setq deactivate-mark nil) ) (defun my/indent-region-right-tab () (interactive) (c-toggle-syntactic-indentation -1) (indent-rigidly (region-beginning) (region-end) 4) (c-toggle-syntactic-indentation 1) (setq deactivate-mark nil) ) ``` The problem is they don't seem to disable syntactic indentation, because they work just as slow. But if I use the next function before calling my/indent-region-left-tab or my/indent-region-right-tab, then the indentation is done fast: ``` (defun my/disable-syntactic-indentation () (interactive) (c-toggle-syntactic-indentation -1) ) ``` How to do it so it can be all put inside the functions so they are not slow anymore? # Answer > 1 votes Just guessing here because I can't replicate the issue, but do the following slightly different functions work? ``` (defun my/indent-region-left-tab () (interactive) (let ((c-syntactic-indentation nil)) (indent-rigidly (region-beginning) (region-end) -4)) (setq deactivate-mark nil)) (defun my/indent-region-right-tab () (interactive) (let ((c-syntactic-indentation nil)) (indent-rigidly (region-beginning) (region-end) 4)) (setq deactivate-mark nil)) ``` --- Tags: indentation, php-mode ---
thread-53788
https://emacs.stackexchange.com/questions/53788
How set default number (1) in the interactive custom function
2019-11-16T13:30:25.267
# Question Title: How set default number (1) in the interactive custom function here custom function: ``` (defun increment-number-at-point(number) (interactive "nInput increment number:") (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (+ number (string-to-number (match-string 0)))))) ``` Nice it's work fine. But I want to set default value (1) when user not input any number. # Answer > 1 votes Use `read-number` directly: ``` (interactive (list (read-number "Input increment number: " 1))) ``` --- Tags: read ---
thread-53790
https://emacs.stackexchange.com/questions/53790
Is it possible to bind CTRL-SHIFT-xxx and CTRL-num combination?
2019-11-16T16:01:35.130
# Question Title: Is it possible to bind CTRL-SHIFT-xxx and CTRL-num combination? I'm very new to emacs and essentially came from `vim` where it is not possible to bind `CTRL-num` combination like (CTRL-1, CTRL-2, etc) which as well as `CTRL-SHIFT-xxx` like `CTRL-#` which essentially works as simply `#`. Is something like this possible in emacs? # Answer > 2 votes It is perfectly possible to bind C-digit, at least in a "graphical terminal". In a text terminal, things may be different because the terminal may itself generate characters from a key combo, which then can't be seen by emacs. See this answer for discussion and links. Actually, `C-0`, `C-1` etc are already bound in the global map, as can be seen with the command `describe-key`: ``` M-x describe-key CTRL 1 ``` > C-1 runs the command digit-argument (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’. > > It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, C-M-0. > > (digit-argument ARG) > > Part of the numeric argument for the next command. C-u following digits or minus sign ends the argument. You can rebind it, eg: ``` (global-set-key [(control ?1)] 'save-buffer) ``` You can do the same for #: ``` (global-set-key [(control ?#)] 'save-buffer) ``` For information on how to rebind keys, see the elisp manual chapter on keymaps. --- Tags: key-bindings ---
thread-24406
https://emacs.stackexchange.com/questions/24406
Calc: copy only a value, not stack number
2016-07-06T15:42:51.500
# Question Title: Calc: copy only a value, not stack number This seems so obvious that I feel sure that I've just missed something in the manual. I frequently do a calculation and then want to use that calculation elsewhere. But let's say my stack is currently: ``` --- Emacs Calculator Mode --- 1: 42 . ``` Any way I've tried to copy the value `42` with incantations of `M-w`, what I get when I yank is ``` 1: 42 ``` including the newline. The manual says > Although a whole line is always deleted, C-k with no argument copies only the number itself into the kill ring, whereas C-k with a prefix argument of 1 copies the number with its trailing newline. but that only works with `C-k`, weirdly, not with `M-w` (though otherwise the commands respond to arguments similarly), and still, that doesn't solve my problem, as I still get the stack number. Amazingly, even moving the cursor, setting mark on `4` and point after `2` to set a region (which is highlighted, making me think this should work) doesn't get my the value: it still gives me the entire line. I know about `M-x quick-calc`, which lets me enter an algebraic expression into the minibuffer whose result is placed into the kill ring, but that's not helpful if I'm doing a complex calculation or simply want to use the normal Calc RPN interface. (While there are methods described about how to move a `quick-calc` result into the calculator stack, I don't see a way to gain access to the stack from `quick-calc`. `$1`, etc., refer to prior results of `quick-calc` instead.) `calc-copy-to-buffer` is bound conveniently to `y`, but I often want to use the result in the minibuffer or even in another program via kill-ring/clipboard integration, so this isn't a solution, either. Of course I can yank or copy to a buffer and then edit the result and re-kill the edited result, but I do this so frequently and again, it seems like such an obvious use case that I really think I'm just missing something. (I know there are Orgmode and database solutions for bulk transfer of Calc data, but I just want a single value to yank; it shouldn't be that hard.) # Answer Just after posting this, I found a solution I'm surprised I didn't think of sooner: 1. Hit backtick (`calc-edit`) to edit the stack value. 2. Kill the line in the edit buffer with `C-w` (editing it first if it suits your needs). 3. `C-c C-c` to close the buffer (if you killed everything, the value gets restored on the stack, so it's equivalent to hitting `C-c C-k`). 4. Yank or paste wherever you please. Not quite the single-key solution I was expecting, but it'll do. > 5 votes # Answer You can set mark and point, and save the region to the kill ring with `kill-ring-save`, which by default is bound to `C-M-w` in calc mode (instead of `M-w` as it is in most other modes). > 5 votes # Answer Using `C-x * y` allows you to yank the result into the buffer of your choice, including the minibuffer. I'm not sure this will help you with yanking into another program, though. See here for more. > 3 votes # Answer Here's some code to define a function to put the most recent thing in the calc stack into the kill ring. ``` (defun copy-calc-top () "Copy the thing at the top of the calc stack." (interactive) (let ((val (calc-top))) (kill-new (if (Math-scalarp val) (math-format-number val) (math-format-flat-expr-fancy val 0))))) ``` And we can bind it to a key. ``` (define-key calc-mode-map (kbd "M-w") #'copy-calc-top) ``` I think this should now work for most data types. It works for integers, floating point numbers, and dates. > 2 votes # Answer I thought exactly the same thing, found nothing and wrote this piece of code: ``` (with-eval-after-load 'calc (defun calc-copy-as-kill () "Copy the top of stack as kill." (interactive) (let ((buffer (generate-new-buffer "*copy-here*"))) (unwind-protect (progn (cl-letf (((symbol-function 'calc-find-writable-buffer) (lambda (buf mode) buffer))) (call-interactively 'calc-copy-to-buffer)) (with-current-buffer buffer (kill-new (buffer-substring-no-properties (point-min) (point-max)))) (message "Copied the result: %s" (car kill-ring))) (and (buffer-name buffer) (kill-buffer buffer))))) (defun calc-copy-as-kill-and-quit () "Copy the top of stack as kill and quit." (interactive) (calc-copy-as-kill) (calc-quit)) (define-key calc-mode-map (kbd "W") 'calc-copy-as-kill) (define-key calc-mode-map (kbd "C-c C-c") 'calc-copy-as-kill-and-quit)) ``` This is kind of a dirty hack to steal what `calc-copy-to-buffer` would paste into the last buffer and copy it as kill, but it works for me so far. > 0 votes --- Tags: kill-ring, calc ---
thread-53795
https://emacs.stackexchange.com/questions/53795
wrong-type-argument from insert yank
2019-11-17T05:06:24.333
# Question Title: wrong-type-argument from insert yank I'm looking for ways to get the last copy from the kill ring in Emacs. I run ``` (insert (yank))[cursor] ``` with `C-x C-e` and I get this `*Backtrace*`: ``` Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil) insert(nil) eval((insert (yank)) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) ``` What I'm trying to do is get the last copied text from the kill-ring (I think it would make it feel more polished if when I call this it removes the last copy from the kill-ring when ran, but I haven't found how to do that yet.), so I can have the defun that calls this get the last think I copied. The command works correctly, but also calls up this Backtrace. I don't know what the backtrace message wants me to do? I would suspect that I'm not supposed to call yank in this manner. # Answer Let's look at the documentation for `yank`. From `C-h f yank RET`: > Reinsert ("paste") the last stretch of killed text. Oh, so `yank` doesn't just *return* the last killed text; it *inserts* it too. So you can simply run `(yank)` to put that text into your buffer. ### Errors? So why are we seeing the wrong-type-argument error? Let's run `(yank)` in IELM, so we can see its return value ``` ELISP> (yank) nil ELISP> I killed this text previously. ``` Oh! So `(yank)` returns nil. Amusingly, the inserted text is inserted into IELM's next prompt! To complete the circle, let's try running `(insert nil)`. When I do that, I also get a wrong-type-argument error. > 2 votes --- Tags: yank, customization, backtrace ---
thread-53803
https://emacs.stackexchange.com/questions/53803
How create custom function access only from ONE el file?
2019-11-17T15:02:53.593
# Question Title: How create custom function access only from ONE el file? Emacs 26.1 In my file `custom_functions.el` ``` (defun increment-number-by-one-at-point() (interactive) (increment-number-at-point-private 1)) ;; Increment number at point (defun increment-number-at-point(number) (interactive (list (read-number "Input increment number: " 1))) (increment-number-at-point-private number)) (defun increment-number-at-point-private(number) (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (+ number (string-to-number (match-string 0)))))) ``` The problem is that `increment-number-at-point-private` is has access in the any place in Emacs List files. But I need that function `increment-number-at-point-private` must have access only in file `custom_functions.el` # Answer If you call `defun`, it creates the function with a global scope. Emacs has no namespaces. There's some previous discussion here, but I won't go into it here. So what can we do to make a function that does not get bound to a name? We could use `lambda` to create an anonymous function, bind it locally with `let`, and use it the function inside that body. We can use this function inside a named ("public") function: ``` (let ((my-private-function (lambda () (interactive) "Returned privately!"))) (defun my-public-function () (interactive) (replace-regexp-in-string "private" "public" (funcall my-private-function)))) (my-public-function) => "Returned publicly!" ``` This works fine, but we can use some functionality built into Emacs to make `my-private-function` callable by name *inside* the body, but not callable by name outside it. ``` (require 'cl-macs) (cl-labels ((my-private-function () (interactive) "Returned privately!")) (defun my-public-function () (interactive) (replace-regexp-in-string "private" "public" (my-private-function)))) (my-public-function) => "Returned publicly!" ``` > 2 votes --- Tags: scope ---
thread-53802
https://emacs.stackexchange.com/questions/53802
"Symbol's value as variable is void: *" using load-file
2019-11-17T14:54:55.270
# Question Title: "Symbol's value as variable is void: *" using load-file I have this function in my config file and for some reason, I'm getting this error: Symbol's value as variable is void: \*. ``` (defun reload-config() "Reload config.org" (interactive) (load-file (concat EMACS_DIR CONFIG_FILE))) ``` I have a similar function that works right. ``` (defun find-config () "Edit config.org" (interactive) (find-file (concat EMACS_DIR CONFIG_FILE))) ``` Ps: I'm defining EMACS\_DIR and CONFIG\_FILE as ``` (setq EMACS_DIR "~/.emacs.d/") (setq CONFIG_FILE "config.org") ``` # Answer > 2 votes From `C-h f load-file RET`: ``` Load the Lisp file named FILE. ``` I'm assuming `~/.emacs.d/config.org` is an org file, not a Lisp file. That is, it starts something like: ``` * all my amazing settings #+BEGIN_SRC emacs-lisp (setq whos-awesome 'i-am) #+END_SRC ``` We can see that the first thing in that file is `*`; that is, just an asterisk. So when Emacs tries to *load* that file, it will look for the variable meaning of `*`, fail to find it, and throw an error. If your file is set up as the example above shows, where all the Emacs Lisp is in `#+BEGIN_SRC emacs-lisp` blocks, you can use `org-babel-load-file`. From its documentation: > Load Emacs Lisp source code blocks in the Org FILE. You can use it as follows: ``` (org-babel-load-file (concat EMACS_DIR CONFIG_FILE)) ``` --- Tags: init-file, syntax ---
thread-53798
https://emacs.stackexchange.com/questions/53798
emacsclientw does not use font specified in init.el (Windows)
2019-11-17T09:36:52.670
# Question Title: emacsclientw does not use font specified in init.el (Windows) **Emacs version:** GNU Emacs 25.3.1 (x86\_64-w64-mingw32) I have set up a shell-script which runs Emacs server at Windows startup as mentioned in Emacs Wiki. I have set up a shortcut on my desktop which I can double-click to run `emacsclientw.exe` with this command ``` H:\emacs-25.3-x86_64\bin\emacsclientw.exe -n -c -a "" ``` But `emacsclientw.exe` does **not** use the font I have specified in my `init.el`. This is strange, since everything else in my `init.el` works **perfectly** (macros, packages, etc). How do I get `emacsclientw.exe` to use the font I have set up in my `init.el`? I have this Elisp code in my `init.el` to set font and frame size on startup ``` ;; Select a desirable font-size, frame position and frame size when Emacs starts up (defun originalPosition () (interactive) (set-frame-font "Courier New-14" t t) (set-frame-position (selected-frame) 100 50) (when window-system (set-frame-size (selected-frame) 82 28)) ) (originalPosition) ``` # Answer I used `default-frame-alist` and it solves the issue. ``` (add-to-list 'default-frame-alist '(font . "Courier New-14")) ;; Font type & size ``` It is guaranteed to work, whether Emacs is launched normally or as a daemon. > 1 votes --- Tags: init-file, microsoft-windows, emacsclient, fonts, server ---
thread-53800
https://emacs.stackexchange.com/questions/53800
Is [:space:] same as \s-?
2019-11-17T13:20:24.690
# Question Title: Is [:space:] same as \s-? Emacs 26.1 In regexp help https://www.emacswiki.org/emacs/RegularExpression has the next regexp: `[:space:]` a whitespace character Is this a same as: ``` [ \t\r\n\v\f] ``` and same as ``` \s- ``` ? # Answer I recommend reading the Emacs Lisp manual instead of Emacswiki. Here's some of it on backslash sequences in regular expressions: ``` ‘\sCODE’ matches any character whose syntax is CODE. Here CODE is a character that represents a syntax code: thus, ‘w’ for word constituent, ‘-’ for whitespace, ‘(’ for open parenthesis, etc. To represent whitespace syntax, use either ‘-’ or a space character. *Note Syntax Class Table::, for a list of syntax codes and the characters that stand for them. ``` The corresponding part on character classes: ``` ‘[:space:]’ This matches any character that has whitespace syntax (*note Syntax Class Table::). ``` So, yes, they are the same, both are about characters with whitespace syntax. The exact meaning of whitespace syntax depends on the currently active syntax table, it can be customized by major modes and less commonly, by users. For example if someone defined the comma character to have whitespace syntax in Clojure buffers, then both `\s-` and `[[:space:]]` would be matched by a comma. To summarize, if you want to write a regex matching specific whitespace characters, then there's no other way to get there than actually spelling them out. In case you find it tedious to do so with strings, I highly recommend the built-in `rx` library as alternative notation that's easier to generate and compose. > 5 votes --- Tags: regular-expressions, whitespace ---
thread-28749
https://emacs.stackexchange.com/questions/28749
Quickly inserting a single Greek letter
2016-11-18T20:56:27.530
# Question Title: Quickly inserting a single Greek letter How can I make it so that `H-g` followed by `a` gives an alpha etc.? # Answer > 5 votes There are several ways. A key difference is how close `H-g a` is to typing an actual character α would be if you had that key on your keyboard. For example, you can make `H-g a` a macro that inserts the string `α`: ``` (define-key global-map (kbd "H-g a") "α") ``` But then `H-g a` differs from inserting a character in several ways which may or may not be desirable. For example it won't trigger behaviors specific to `self-insert-command` (which is the case in some abbrev expansion/autocompletion packages), it is not grouped with other insertions for undo purposes, etc. This also allows `H-g` to be overridden by mode-specific bindings. To make the translation really look like a character insertion and work before any ordinary key bindings, but after terminal-specific ones (so if you use a non-window Emacs on a terminal that sends an escape sequence for `H-g`, your binding will still work), put it in `key-translation-map`, which is pretty much designed for what you're doing. ``` (define-key key-translation-map (kbd "H-g a") "α") … ``` Emacs has input methods for inserting characters that aren't on the keyboard, but I don't know how to use an input method for the next character only. # Answer > 2 votes To do this for **all** Greek letters, download library **`ucs-cmds.el`**, then put this in your init file: ``` (require 'ucs-cmds) (ucsc-make-commands "^greek [a-z]+ letter"))) (global-set-key (kbd "H-g a") 'greek-small-letter-alpha) ``` That defines a command for *each* Greek letter, which inserts it. The command name is the same as the character (letter) it inserts, except that it is lowercase and spaces have been replaced by hyphens. The return value of `ucsc-make-commands` is a list of the commands created (their symbols), so you can in fact iterate over it (or a subset) to create a set of key bindings for them all at once, if you like. # Answer > 1 votes You can access one input method from another. Switch to your Greek input method and evaluate ``` (setq greek-map (quail-map)) ``` Switch to your standard Latin input method and evaluate ``` (quail-defrule ",." greek-map) ``` Now, if you type `,.a`, that will produce an alpha, &c. --- Tags: input-method, insert ---
thread-53797
https://emacs.stackexchange.com/questions/53797
Export Org-mode Headers Level 4 or Above as Headers in Texinfo
2019-11-17T09:28:36.047
# Question Title: Export Org-mode Headers Level 4 or Above as Headers in Texinfo I am writing software documentation using Org-mode, but I also want to export the result as a Texinfo file. The process works well, however, Texinfo transforms level 4 headings into numbered lists instead of subsubsections, etc. The documentation indicates to use `#+OPTIONS: num:6` exporting as subsubheadings, etc. instead of numbered lists for any header of level 6 or lower. Has anybody run into this issue and know how to deal with it? It is not a huge problem, but my INFO files would be easier to navigator with the proper layout. # Answer Looking at the org manual section "Export settings", we can see that `num` sets the headlines that will be numbered: headline levels above this number will be unumbered. > ‘num:’ > > Toggle section-numbers (‘org-export-with-section-numbers’). When set to number ‘n’, Org numbers only those headlines at level ‘n’ or above. Setting ‘UNNUMBERED’ property to non-‘nil’ disables numbering of a heading. Since subheadings inherit from this property, it affects their numbering, too. What you want to change is the number of headline levels to use for export, and that is option `H`: > ‘H:’ > > Set the number of headline levels for export (‘org-export-headline-levels’). Below that level, headlines are treated differently. In most back-ends, they become list items. So you should use the following setting: ``` #+OPTIONS: H:6 ``` Note that the effect of this line is to set the value of variable `org-export-headline-levels` for this one buffer. There are other ways to set this parameter: > Export options can be set: globally with variables; for an individual file by making variables buffer-local with in-buffer settings, by setting individual keywords, or by specifying them in a compact form with the ‘#+OPTIONS’ keyword; > 4 votes --- Tags: org-mode, org-export, texinfo ---
thread-53772
https://emacs.stackexchange.com/questions/53772
AUCTeX fontification for any command: overkill?
2019-11-15T18:47:56.217
# Question Title: AUCTeX fontification for any command: overkill? Reading the AUCTeX manual I see that it is possible to add expressions to those one wants to highlight in a `.tex` file. There are also many specific suggestions around for how to add specific commands to the list `font-latex-keywords`. Now, coming from another editor (ST3) where it seems that the default is to highlight *anything* starting with `\`, I wonder whether there's any reason not to do this in Emacs and, if not, exactly how to do it. (From what I understand, you can't use a regex to specify a list of keywords, is that right?) # Answer > 1 votes AUCTeX fontifies all control words: For known ones (added in `font-latex.el` or via AUCTeX style files), it uses different classes (e.g., `warning`, `function`, `textual` etc.) and for unknown ones, it simply uses the `font-latex-sedate-face` which defaults to `Foreground: DimGray`. You can customize this face if you want a different appearance. There is no fontification for control symbols. You can load this file in your Emacs to see some basic ideas behind fontification of general macros in AUCTeX. --- Tags: latex, auctex, font-lock, syntax-highlighting ---
thread-53814
https://emacs.stackexchange.com/questions/53814
Custom sorting of agenda (by tag)
2019-11-17T22:35:06.487
# Question Title: Custom sorting of agenda (by tag) Is there a way to customize how tags get sorted in org-agenda weekly view? I don't like the default which is sorting alphabetically (within tasks of the same date/priority). It would be more useful if the sorting could be in the order tags are defined in the org file. # Answer While this doesn't exactly answer the question, when you're in the agenda tag view you can filter the tags by using `\ TAB` and specifying another, this is probably the easiest approach. The default method in org-mode is to sort the tag-match agenda view by the sequence they are seen in the files (10.4.3 of the manual doesn't say it's alphabetical but it could be wrong). You can adjust how they are sorted by changing `org-agenda-sorting-strategy`, so you might want to use `M-x customize-variable org-agenda-sorting-strategy` from there you will be able to toggle all sorts of things. > 0 votes --- Tags: org-mode, org-agenda ---
thread-53811
https://emacs.stackexchange.com/questions/53811
How to turn off Latex/MathJax buffer symbol conversion in org-mode
2019-11-17T20:19:39.733
# Question Title: How to turn off Latex/MathJax buffer symbol conversion in org-mode Whenever I write, say, `\Rightarrow` inside of $$, I immediately see the actual right-pointing arrow substituted in. Unfortunately, this does not travel well between GUI-based Emacs and Emacs started `-nw` in a terminal. Research tells me this is a `latex-math-preview-*` (or is it something with `org-preview-latex-default-process`?) feature, and this substitution is happening as Emacs (through imagemagick?) creates actual images to insert in-line when it sees Latex/MathJax blocks. My question is, How do I turn this feature completely off in the buffer? I'm on Emacs 26.3 and (elpa) org-mode latest. # Answer I don't think you're seeing the image preview via `imagemagick`/`dvisvgm`, I think you might be seeing a unicode overlay maybe? If it is, according to the manual you should be able to toggle it with `C-c C-x \` looking at the variable `org-pretty-entities` in `M-x customize-variables` may help you. > 1 votes --- Tags: org-mode, latex, mathjax ---
thread-53785
https://emacs.stackexchange.com/questions/53785
How to solve GPG problem on Windows 10?
2019-11-16T12:21:28.000
# Question Title: How to solve GPG problem on Windows 10? I'm having problem with GPG on emacs. It keeps saying ``` Failed to verify signature archive-contents.sig: No public key for [some_weird_code_here] created at [date_here] using RSA Command output: gpg: WARNING: unsafe permissions on homedir `c:/Users/[user]/AppData/Roaming/.emacs.d/elpa/gnupg' gpg: Signature made [date_here] using RSA key ID [some_code] gpg: Can't check signature: public key not found ``` How can I solve this gpg problem in GNU Emacs on my Windows 10 PC (64-bit)? I googled the issue but still don't know how to solve it. Read some websites, installed Gpg4win software, etc. Thanks beforehand. I don't know what the gpg is, but that's another issue. I just want to solve this problem and go on with my own issues. # Answer > 1 votes GPG is just an implementation of the PGP encryption standard, you can read more about it here; `gpg` keys can be a real pain, particularly on Windows, maybe try downloading the key and then using `M-x package-import-keyring` from within emacs to load the key manually? --- Tags: microsoft-windows, gpg ---
thread-41329
https://emacs.stackexchange.com/questions/41329
when to use defer in use-package?
2018-05-04T04:04:21.933
# Question Title: when to use defer in use-package? Quoting from use-package > If you aren't using :commands, :bind, :bind\*, :bind-keymap, :bind-keymap\*, :mode, or :interpreter (all of which imply :defer; see the docstring for use-package for a brief description of each), you can still defer loading with the :defer keyword: But why I found many people including jwiegley himself still use `:defer` even it's already have `:bind` # Answer > 4 votes The answer is present on `use-packages`'s GitHub page under section "Notes about lazy loading". To quote, > In almost all cases you don't need to manually specify `:defer t`. This is implied whenever `:bind` or `:mode` or `:interpreter` is used. **Typically, you only need to specify `:defer` if you know for a fact that some other package will do something to cause your package to load at the appropriate time, and thus you would like to defer loading** even though use-package isn't creating any autoloads for you. --- Tags: use-package ---
thread-53794
https://emacs.stackexchange.com/questions/53794
Why isn't the Evil global motion map used in Info mode?
2019-11-17T04:07:13.477
# Question Title: Why isn't the Evil global motion map used in Info mode? I'm having a problem where it appears Emacs is not looking at keybindings set in my `evil-motion-state-map`. Below is my entire `init.el`. I start with an empty `.emacs.d` directory and only install `evil`. ``` ;; The following line is a workaround for Emacs 26.2. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") (package-initialize) (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/"))) (setq package-selected-packages '(evil)) ;;; theme config (set-face-attribute 'default nil :height 160) (defun lookup-spc-tab () "For debugging." (interactive) (message "SPC TAB binding for motion and normal states: %s %s" (lookup-key evil-motion-state-map (kbd "SPC TAB")) (lookup-key evil-normal-state-map (kbd "SPC TAB")))) ;;; evil config (evil-mode 1) (lookup-spc-tab) (evil-define-key 'motion 'global (kbd "SPC") (make-sparse-keymap) (kbd "SPC TAB") #'switch-to-buffer) (evil-define-key 'motion Info-mode-map (kbd "SPC") (make-sparse-keymap) (kbd "SPC SPC") #'Info-scroll-up) (lookup-spc-tab) ``` When I start Emacs the following is printed in the `*Messages*`, which leads me to believe that `SPC TAB` was set in `evil-motion-state-map`. The following messages come from my debugging function `lookup-spc-tab` and appear in the `*Messages*`. ``` SPC TAB binding for motion and normal states: 1 1 SPC TAB binding for motion and normal states: switch-to-buffer 1 ``` Now for my question: In every mode I've tried (Fundamental, Emacs-Lisp, Message), in both motion and normal state, `SPC SPC` is undefined and `SPC TAB` is `switch-to-buffer`; this is all to be expected. The exception is Info mode. When I use Info mode, in both motion and normal state, `SPC SPC` is `Info-scroll-up` (expected), but `SPC TAB` is undefined. What is is about Info mode that overrides `SPC TAB`? `SPC TAB` works in every other mode! However, if I do: ``` ... (evil-define-key 'normal 'global (kbd "SPC") (make-sparse-keymap) (kbd "SPC TAB") #'switch-to-buffer) (evil-define-key 'normal Info-mode-map (kbd "SPC") (make-sparse-keymap) (kbd "SPC SPC") #'Info-scroll-up) ... ``` That is, if I change my config to modify normal states instead of motion states, then everything works (in normal state) in every mode, even Info mode. Specifically, `SPC TAB` is defined in every mode, including Info mode, and `SPC SPC` is defined only in Info mode. All as expected. So, again, my question is, what is it about `evil-motion-state-map` that gets overridden in Info mode only? And why does only motion state get overridden but not normal state? # Answer On the emacs wiki for evil there is a section about this: Managing keymaps \> Overriding and intercept keymaps: > **Overriding and intercept keymaps** > > There are Emacs modes that provide their own single letter key bindings, independent of Evil. BufferMenu, Ediff, and Edebug are a few examples. By default, Evil allows these modes’ keymaps to override Evil’s. To change this behavior, customize the evil-overriding-maps and evil-intercept-maps variables. (...) The default value of `evil-overriding-maps` includes `(Info-mode-map . motion)`. This means that by default that mode keymaps overrides the evil one in motion state. > 3 votes --- Tags: evil ---
thread-53799
https://emacs.stackexchange.com/questions/53799
Why multiple-cursor ask me on every line? How avoid this?
2019-11-17T12:20:06.737
# Question Title: Why multiple-cursor ask me on every line? How avoid this? emacs 26.1, multiple-cursor https://github.com/magnars/multiple-cursors.el Here my custom Elisp function that add some number(by default 1) to number. ``` (defun increment-number-at-point(number) (interactive (list (read-number "Input increment number: " 1))) (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (+ number (string-to-number (match-string 0)))))) (global-set-key (kbd "C-c +") 'increment-number-at-point) ``` Nice it's work fine. But suppose I has this json and want to add to every **id** the number 400. Example json: ``` [ { "id": 0, "finished": 2, "orgn": 17 }, { "id": 1, "finished": 3, "orgn": 17 }, { "id": 2, "finished": 4, "orgn": 17 }, { "id": 3, "finished": 5, "orgn": 17 } ] ``` The result must be: ``` [ { "id": 400, "finished": 2, "orgn": 17 }, { "id": 401, "orgn": 17 }, { "id": 402, "orgn": 17 }, { "id": 403, "orgn": 17 } ] ``` here my steps (use my custom function and multiple-cursor) 1. 2. 3. 4. Use `C-c +` (increment-number-at-point) 5. 6. Input **400** `RET` 7. It's **AGAIN** ask me about number 8. So it ask my about number **ON EVERY LINE**. It's not good. Is it possible to set **ONLY ONCE** number (400) and replace on every line automatic? # Answer Answering the last question: ``` (defun add-to-number-atpt () (interactive "*") (let* ((regexp "\"id\": \\([0-9]+\\),")) (while (re-search-forward regexp nil t) (replace-match (concat "\"id\": "(number-to-string (+ 400 (string-to-number (match-string-no-properties 1))))","))))) ``` > 0 votes # Answer The function gets called for each cursor (if it is added to `mc/always-run-for-all`) and therefore the number is also read for each cursor. To get around this you could write a wrapper that reads the number once and then runs your command for all cursors. ``` (defun my-mc/increment-number-at-cursors (number) "Increment numbers for all cursors by NUMBER." (interactive (list (read-number "Input increment number: " 1))) (mc/execute-command-for-all-cursors (lambda () (interactive) (increment-number-at-point number)))) ``` > 0 votes # Answer You could split your function into two. * One, which is doing the work on one single cursor (`internal`). * A second one, which is called once by the user (`cmd`). This function ensures, that the work is done by for every single cursor. source code: ``` (defun foo--internal () (interactive) (skip-chars-backward "0-9") (or (looking-at "[0-9]+") (error "No number at point")) (replace-match (number-to-string (+ number (string-to-number (match-string 0)))))) (defun foo-cmd (number) (interactive (list (read-number "Input increment number: " 1))) (if (fboundp 'mc/execute-command-for-all-cursors) (mc/execute-command-for-all-cursors #'foo--internal) (foo--internal))) (global-set-key (kbd "C-c +") 'foo-cmd) ``` > 0 votes --- Tags: text-editing, multiple-cursors ---
thread-53793
https://emacs.stackexchange.com/questions/53793
Activate personal configuration to the config with load-file and require
2019-11-17T03:54:39.330
# Question Title: Activate personal configuration to the config with load-file and require I created personal my-config in .doom.d and have 'my-org-agenda\` etc within it. ``` #+BEGIN_SRC shell :results output tree ~/.doom.d | head #+END_SRC #+RESULTS: #+begin_example /home/me/.doom.d ├── config.el ├── init.el ├── my-config │ ├── my-org-agenda.el │ ├── my-org-babel.el │ ├── my-org.el │ └── my-org-note.el ├── packages.el ├── snippets #+end_example ``` I do the following configuration: Add `(add-to-list 'load-path "~/.doom.d/my-config/")` as the first line of `config.el` and require the appropriate personal configs ``` ;;-------------------------------------------------------------------------- ;;Org ;;Note taking ;;GTD agenda ;;literature programming ;;-------------------------------------------------------------------------- (require 'my-org-note) (require 'my-org-babel) (require 'my-org-agenda) ``` Restart emacs but got the errors: ``` /home/me/Documents/primary.doom.d/my-config/my-org-note.el failed to provide feature ‘my-org-note’ ``` What the problem with my usage of load and require? # Answer You should insert `(provide 'my-org-note)` at the end of your `my-org-note.el` file. (and similar for the other files). Through this call Emacs can update the feature list with the `required` package symbol. This mechanism prevents re-evaluation of lisp code multiple times. Have a read at Xah's Website or the official Emacs documentation for more details. > 1 votes --- Tags: config, configuration-files ---
thread-53827
https://emacs.stackexchange.com/questions/53827
Updating magit today gives me invalid face attribute
2019-11-18T10:38:51.173
# Question Title: Updating magit today gives me invalid face attribute Updating magit this morning I now can't start things up, getting: ``` face-attribute: Invalid face attribute name: :extend ``` Anyone know what could cause and (hopefully!) fix this? # Answer `:extend` is a new face property in the development version of Emacs 27. I still hope it won't make it into Emacs 27.1 in its current form. Never-the-less I have updated Magit to set this attribute when necessary (i.e. only for certain faces and only when using Emacs 27). If you are using Emacs 27 but have not pulled and recompiled in a month or so, then you get this warning. Pull and recompile Emacs to fix this. > 1 votes --- Tags: magit ---
thread-53828
https://emacs.stackexchange.com/questions/53828
Magit log: move cursor to the HEAD
2019-11-18T11:15:11.083
# Question Title: Magit log: move cursor to the HEAD While in the log buffer, is there a way to move the cursor directly to the HEAD commit? # Answer > 1 votes No. If you wish to implement such a command, then I would recommend searching for the respective (abbreviated) hash in the buffer and moving there. --- Tags: magit ---
thread-53835
https://emacs.stackexchange.com/questions/53835
Building Emacs 24.4 without admin rights, ncurses dependency
2019-11-18T16:18:50.823
# Question Title: Building Emacs 24.4 without admin rights, ncurses dependency I'd like to build Emacs 24.4 from source on a system where I don't have admin rights. When I run `./configure`, I get the error: ``` The required function \'tputs' was not found in any library. The following libraries were tried (in order): libtinfo, libncurses, libterminfo, libtermcap, libcurses Please try installing whichever of these libraries is most appropriate for your system, together with its header files. For example, a libncurses-dev(el) or similar package. ``` I naively downloaded ncurses6.0 and built it, and then just pasted the headers, sources and .a files into the emacs24.4 directory. This didn't work. (I tried pasting those files into all of the subdirectories of emacs24.4, too.) Any idea how, or if, I can do this? As you can tell, I'm not particularly experienced with building things on Linux. Edit: I just double checked, and I found that ncurses is in fact installed on my system. Is there a way I can get the build script to recognize it, given the location of the ncurses install? # Answer When building ncurses, tell it to install in a directory under your home directory: ``` ./configure --prefix=$HOME/ncurses make make install ``` Then, when building Emacs, tell Emacs to look for include files and libraries under that directory: ``` ./configure LDFLAGS=-L$HOME/ncurses/lib CPPFLAGS=-I$HOME/ncurses/include ``` > 2 votes --- Tags: install, emacs24 ---
thread-53841
https://emacs.stackexchange.com/questions/53841
How are major modes and local keymaps associated?
2019-11-18T20:45:43.377
# Question Title: How are major modes and local keymaps associated? The Emacs manual says: > Major modes customize Emacs by providing their own key bindings in local keymaps.... Minor modes can also have local keymaps... Roughly, it seems to say: > Major modes provide local keymaps. Minor modes have local keymaps. I understand the idea of major and minor modes: A buffer has one major mode and possibly (usually) several minor modes which apply small modifications. I am confused about the terminology "local keymap". For a time I thought "major" and "local" were somewhat synonymous. This was confusing because "major" implies big and important and "local" implies small and less important. I then looked at the rules for looking up keybindings which are roughly: ``` (or (if overriding-terminal-local-map (find-in overriding-terminal-local-map)) (if overriding-local-map (find-in overriding-local-map) (or (find-in (get-char-property (point) 'keymap)) (find-in-any emulation-mode-map-alists) (find-in-any minor-mode-overriding-map-alist) (find-in-any minor-mode-map-alist) (if (get-text-property (point) 'local-map) (find-in (get-char-property (point) 'local-map)) (find-in (current-local-map))))) (find-in (current-global-map))) ``` It looks like minor mode keymaps are found in `minor-mode-map-alist` and `minor-mode-overriding-map-alist`, and that major mode keymaps are found in `current-local-map`. All three of those are "local" variables, right? Which means any modifications to them are visible only to the current buffer. Do I understand that correctly? If that is the case, then the keymaps do no belong to a major mode (or minor mode), they simply belong to buffer local variables. Which brings me to my (somewhat vague) question: How are modes and keymaps associated? To pick a specific example. How are `emacs-lisp-mode`, `emacs-lisp-mode-map`, and `current-local-map` related? Is `emacs-lisp-mode-map` merely a template that initializes `current-local-map`? Is `current-local-map` an independent copy? Or do all buffers using `emacs-lisp-mode` share the same `current-local-map`? # Answer You do have to be a bit careful with the terminology. Each buffer has a single "local keymap", and therefore it's sensible to avoid using that terminology to refer to other keymaps. ``` current-local-map is a built-in function in `C source code'. (current-local-map) Return current buffer's local keymap, or nil if it has none. Normally the local keymap is set by the major mode with `use-local-map'. ``` Other keymaps may indeed be active in the buffer on account of buffer-local values (such as buffer-local minor modes), but to reduce the potential for confusion you should avoid using the terms "local map" or "local keymap" to refer to anything other than `(current-local-map)`, as that is *the* local map. > To pick a specific example. How are `emacs-lisp-mode`, `emacs-lisp-mode-map`, and `current-local-map` related? > > Is `emacs-lisp-mode-map` merely a template that initializes `current-local-map`? The `define-derived-mode` macro (which handles the boiler plate for most major modes) calls `use-local-map` with the major mode's keymap as an argument (and major modes defined without the macro will mostly do the same thing). So in your example, calling `emacs-lisp-mode` means that `(use-local-map emacs-lisp-mode-map)` happens when the mode function is evaluated. > Is `current-local-map` an independent copy? Or do all buffers using `emacs-lisp-mode` share the same `current-local-map`? Yes and no. The *value* of the local map is not the major mode map's symbol, but the keymap value itself -- so `emacs-lisp-mode-map` is a global variable pointing at that structure, and then every buffer in `emacs-lisp-mode` has its own buffer-local "local map" value, which by default will *also* be pointing at that exact same structure. So `(eq (current-local-map) emacs-lisp-mode-map)` would be true in those buffers. If you were to call `use-local-map` in a buffer then you could point the local map to some other keymap, and it would no longer be the same as `emacs-lisp-mode-map`. --- Tangentially, there's some other related behaviour in `define-derived-mode`. If the mode's keymap doesn't have a parent, then the macro will automatically assign one with `(set-keymap-parent ,map (current-local-map))` -- which means that modes which derive from other modes will acquire the local bindings of their parent mode (as the parent mode's body has been evaluated already, and had itself set the current local map). > 6 votes --- Tags: major-mode, keymap ---
thread-53830
https://emacs.stackexchange.com/questions/53830
Error in custom eshell function (exit and close window)
2019-11-18T12:37:47.290
# Question Title: Error in custom eshell function (exit and close window) I got the below function from an article on howardism.org. Its purpose is to exit eshell and close the corresponding window. ``` ;; GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.10) of 2019-08-29 (defun eshell/x () (insert "exit") (eshell-send-input) (delete-window)) (setq debug-on-error t) ``` Looked pretty straightforward to me. But when I start `emacs -Q` (See above code block for version info), then evaluate the above code and type `x<RET>` in an eshell window. I get the following: ``` Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil) eshell-lisp-command(eshell/x nil) eshell-plain-command("x" nil) eshell-named-command("x") (prog1 (eshell-named-command "x") (run-hooks (quote eshell-this-command-hook))) (condition-case err (prog1 (eshell-named-command "x") (run-hooks (quote eshell-this-command-hook))) ((debug error) (run-hooks (quote eshell-this-command-hook)) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))) (condition-case-unless-debug err (prog1 (eshell-named-command "x") (run-hooks (quote eshell-this-command-hook))) (error (run-hooks (quote eshell-this-command-hook)) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))) (eshell-condition-case err (prog1 (eshell-named-command "x") (run-hooks (quote eshell-this-command-hook))) (error (run-hooks (quote eshell-this-command-hook)) (eshell-errorn (error-message-string err)) (eshell-close-handles 1))) (let ((eshell-this-command-hook (quote (ignore)))) (eshell-condition-case err (prog1 (eshell-named-command "x") (run-hooks (quote eshell-this-command-hook))) (error (run-hooks (quote eshell-this-command-hook)) (eshell-errorn (error-message-string err)) (eshell-close-handles 1)))) (eshell-trap-errors (eshell-named-command "x")) (progn (eshell-trap-errors (eshell-named-command "x"))) (catch (quote top-level) (progn (eshell-trap-errors (eshell-named-command "x")))) (progn (run-hooks (quote eshell-pre-command-hook)) (catch (quote top-level) (progn (eshell-trap-errors (eshell-named-command "x")))) (run-hooks (quote eshell-post-command-hook))) (let ((eshell-current-handles (eshell-create-handles t (quote append))) eshell-current-subjob-p) (progn (run-hooks (quote eshell-pre-command-hook)) (catch (quote top-level) (progn (eshell-trap-errors (eshell-named-command "x")))) (run-hooks (quote eshell-post-command-hook)))) (eshell-commands (progn (run-hooks (quote eshell-pre-command-hook)) (catch (quote top-level) (progn (eshell-trap-errors (eshell-named-command "x")))) (run-hooks (quote eshell-post-command-hook)))) eval((eshell-commands (progn (run-hooks (quote eshell-pre-command-hook)) (catch (quote top-level) (progn (eshell-trap-errors (eshell-named-command "x")))) (run-hooks (quote eshell-post-command-hook))))) eshell-send-input(nil) funcall-interactively(eshell-send-input nil) call-interactively(eshell-send-input nil nil) command-execute(eshell-send-input) ``` Without debug-on-error the "Wrong type argument"-message ends up in the buffer I was working in when invoking eshell. To add to my confusion, this only happens the first time I call `eshell/x`. Stepping through the function with edebug suggests that the error occurs in neither of the functions called inside `eshell/x` as the debugger only starts after I stepped over the last function call. Also when changing the function to this ``` (defun eshell/x () (insert "exit") (eshell-send-input) (delete-window) (message "done deleting window")) ``` The debugger only gets entered after "done deleting window" appeared in the echo area. Now I don't know how to continue searching for the error. Can someone please help me identify the error? # Answer With the default settings of `eshell`, typing the word "exit" in the `*eshell*` buffer, followed by the enter key, causes Emacs to execute the function `eshell/exit`. As such, the proposed approach set forth in the question above, i.e., by inserting the word "exit" and calling `eshell-send-input`, is probably not the best way to handle this. So, let us start by examining the built-in function `eshell/exit`, which is essentially a one-liner. To do that, we evaluate `(require 'eshell)` with something like `M-:` (aka `M-x eval-expression`) ; or, we could copy/paste the `(require 'eshell)` statement to a `*scratch*` buffer and place our cursor just after the closing parenthesis and type `C-x C-e`. Then, we locate the function with `M-x find-function RET eshell/exit RET` -- it looks like this: ``` (defun eshell/exit () "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." (throw 'eshell-terminal t)) ``` Since it is just a one-liner, why not create our own function by simply changing the function name, like so?: ``` (defun eshell/x () "Leave or kill the Eshell buffer, depending on `eshell-kill-on-exit'." (throw 'eshell-terminal t)) ``` We decide to pay attention to the doc-string about the variable `eshell-kill-on-exit` and if we are curious, we type `C-h v` (aka `M-x describe-variable`) and look it up: ``` eshell-kill-on-exit is a variable defined in ‘esh-mode.el’. Its value is t Documentation: If non-nil, kill the Eshell buffer on the ‘exit’ command. Otherwise, the buffer will simply be buried. You can customize this variable. ``` As luck would have it, we have the benefit of a similar thread which has an accepted answer: https://stackoverflow.com/questions/51867693/emacs-eshell-kill-window-on-exit So, we take the answer in that similar thread -- suggesting that we advise `eshell-life-is-too-much`, and we combine it with our new function `eshell/x`: ``` (require 'eshell) (defun eshell/x () (throw 'eshell-terminal t)) (defun my-custom-func () (when (not (one-window-p)) (delete-window))) (advice-add 'eshell-life-is-too-much :after 'my-custom-func) ``` > 0 votes --- Tags: debugging, eshell ---
thread-53838
https://emacs.stackexchange.com/questions/53838
Commenting out/disabling file local variable for input method in AUCTeX
2019-11-18T18:11:55.857
# Question Title: Commenting out/disabling file local variable for input method in AUCTeX I have the following local variables defined in a XeTeX file. As you can see, the input method is currently set to Devanagari. This is inconvenient when I want to type Roman letters. I'd like a way to disable that particular setting so I can then type Roman letters, and then re-enable it. I realise I can change the setting in Emacs, but it would be convenient if I could do so by commenting and uncommenting the file. ``` %%% Local Variables: %%% coding: utf-8 %%% mode: latex %%% eval: (set-input-method 'devanagari-itrans) %%% TeX-engine: xetex %%% TeX-master: t %%% End: ``` The question How comment out a variable line in a local variable list is related, but doesn't have an answer. EDIT: I see that the question has been closed as a dupe of this question. I think the the two options provided in the question as at best workarounds. The first one doesn't even attempt to answer the question. The answer even says: > I'm reasonably sure that you can't. I was hoping there were some other options, at least for my use case - which isn't exactly the same as the other question. # Answer I don't understand why you want to comment out that line (especially since it won't have any effect until you re-open the file or do something like `M-x normal-mode`): to toggle the devanagari-itrans input method you can simply use `C-\`. > 2 votes --- Tags: input-method, file-local-variables ---
thread-53842
https://emacs.stackexchange.com/questions/53842
Preventing convertion of ASCII rules on org--html export
2019-11-18T21:32:33.593
# Question Title: Preventing convertion of ASCII rules on org--html export When you export to html, `--` is converted to en-rule and `---` to em-rule. Is it possible to prevent this? # Answer These conversions are defined by a set of regular expressions in file `ox-export.el`: ``` (defconst org-html-special-string-regexps '(("\\\\-" . "&#x00ad;") ; shy ("---\\([^-]\\)" . "&#x2014;\\1") ; mdash ("--\\([^-]\\)" . "&#x2013;\\1") ; ndash ("\\.\\.\\." . "&#x2026;")) ; hellip "Regular expressions for special string conversion.") ``` So you could change them by redefining this value, **after** `ox-export` has been loaded (as `defconst` unconditionnaly sets the value). A possible way would be to add the following to your init file: ``` (eval-after-load 'ox-html '(setq org-html-special-string-regexps '(("\\\\-" . "&#x00ad;") ; shy ("---\\([^-]\\)" . "---\\1") ; mdash ("--\\([^-]\\)" . "--\\1") ; ndash ("\\.\\.\\." . "&#x2026;")) ; hellip )) ``` That is, after `ox-export` has been loaded (and the variable set), we change its value. > 3 votes --- Tags: org-export ---
thread-53846
https://emacs.stackexchange.com/questions/53846
`use-package` and `define-key`
2019-11-19T02:37:19.657
# Question Title: `use-package` and `define-key` I'm using `multiple-cursors`, setting it up with `use-package`. By default, when `multiple-cursors` mode is enabled, `<return>` is bound to `multiple-cursors-mode`. I'm trying to override that adding this after `:config` in the `use-package` declaration: ``` (define-key mc/keymap (kbd "<return>") nil) ``` So, this is part of my `init.el`: ``` (use-package multiple-cursors :ensure t :bind (("s-d" . mc/mark-next-like-this) ("s-D" . mc/mark-all-dwim) ("s-L" . mc/edit-beginnings-of-lines) ("s-<mouse-1>" . mc/add-cursor-on-click)) :config (define-key mc/keymap (kbd "<return>") nil) ) ``` Unfortunately, when `multiple-cursors` mode is enabled, `C-h k` tells me ``` <return> runs the command multiple-cursors-mode (found in mc/keymap) ``` I tried putting the `:config` bit before `:bind` just in the off chance it had something to do with the way `:bind` works, but that didn't make a difference. # Answer Reading the source code (of multiple-cursors) helped me with this one. :) This key is defined in file `multiple-cursors-core.el` and the end of this file `provides` the feature `multiple-cursors-core`, so you have to `use-package` this feature. ``` (use-package multiple-cursors-core :bind (:map mc/keymap ("<return>" . nil))) ``` > 2 votes --- Tags: key-bindings, use-package, multiple-cursors ---
thread-53851
https://emacs.stackexchange.com/questions/53851
Define key binding for a single mode (Fundamental)
2019-11-19T10:13:49.953
# Question Title: Define key binding for a single mode (Fundamental) In light that this may be a duplicate, but I did not find the answer to my question scouring this site. The default behavior of GNU Emacs appears to have `electric-indent-mode` enabled, which is fine almost everywhere. However, I would like to change the behavior for trimming whitespace at the end of the line and auto-indenting after pressing `Return` for only one mode: Fundamental. In essence, I would like `Enter` to simply add a newline (`electric-indent-just-newline`) while pressing `Alt`+`Enter` to insert the default `newline`. How would I go about it? I found this, but I do not seem to get it converted to work with Fundamental. # Answer This is a partial answer to your question, as I could not yet figure out, how to run a hook on `fundamental-mode` only, but please read on. With the following command, you can activate the `Enter` behaviour you like. Just run this command with `M-x` from the current buffer. (It enables this keybinding in all buffers with the same major-mode) ``` (defun my-fundamental-newline () (interactive) (local-set-key (kbd "<RET>") #'electric-indent-just-newline) (local-set-key (kbd "M-<RET>") #'newline)) ``` I got the idea from this question/answer --- Then please read this question/answer to get info, why it is difficult to `hook` this function to `fundamental-mode`. > 1 votes # Answer `electric-indent-mode` is turnedd on by default since Emacs 24.4, according to `C-u C-h n 24.4`. --- Fundamental mode is not an ordinary major mode, it's the default major mode for temporary buffers and Emacs creates lots of temporary buffers all the time, such as when you use minibuffer/echo area and make network requests. For example, right now I have 20 buffers in Fundamental mode (note that they are created automatically, such as, `*Echo Area 1*`): ``` (seq-count (lambda (b) (with-current-buffer b (eq 'fundamental-mode major-mode))) (buffer-list)) ;; => 20 ``` It might be a good reason that Fundamental mode doesn't have a mode keymap and hook. And users should use more specialized major modes such as Text mode instead of Fundamental mode. If you are not satisfied with Fundamental mode, you should use another major mode instead of trying to extend it. --- Regarding your question, if I want only a newline, I use the default `C-j` (`electric-newline-and-maybe-indent`). And since you like different key bindings, you should customize them using a minor mode or major mode keymap. > 1 votes --- Tags: indentation, newlines, electric-indent ---
thread-27601
https://emacs.stackexchange.com/questions/27601
how to markup a quotation?
2016-10-05T22:44:06.253
# Question Title: how to markup a quotation? How do I specify a quote in org-mode so that it is rendered nicely in github? In markdown it is rendered like so: > Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. * *albert enstein* thanks in advance. # Answer > 62 votes When quoting a passage from another document, it is customary to format this as a paragraph that is indented on both the left and the right margin. You can include quotations in Org mode documents like this: ``` #+BEGIN_QUOTE Everything should be made as simple as possible, but not any simpler -- Albert Einstein #+END_QUOTE ``` This information in available in the org manual When you convert your file to html then your text will be as shown below # Answer > 14 votes If you want to get nice formatting, you can customize the CSS of `blockquote` element. Why `blockquote` element? If you use browser's inspect function to inspect the quote block, you can find its style is controlled by `blockquote` element. Below is an example of StackExchange like quote block, you can find the configuration by using inspect function. ``` #+BEGIN_EXPORT html <style> blockquote { margin-bottom: 10px; padding: 10px; background-color: #FFF8DC; border-left: 2px solid #ffeb8e; border-left-color: rgb(255, 228, 102); display: block; margin-block-start: 1em; margin-block-end: 1em; margin-inline-start: 40px; margin-inline-end: 40px; } </style> #+END_EXPORT #+BEGIN_QUOTE Everything should be made as simple as possible, but not any simpler -- Albert Einstein #+END_QUOTE ``` It renders like In addition to writing css yourself, you can use alhassy/org-special-block-extras which offers a number of new custom blocks and link types. --- Tags: org-mode ---
thread-53864
https://emacs.stackexchange.com/questions/53864
Is function `list` equivalent to using `cons` with a final cdr of `nil`?
2019-11-19T18:03:53.643
# Question Title: Is function `list` equivalent to using `cons` with a final cdr of `nil`? I'm trying to explain Elisp to 5th and 6th graders and I tell them that `(+ 1 2)` evaluates to `3` and not `(3)`. So if I do want something that evaluates to `(3)` would I just evaluate `((+ 1 2))`? No! This gives the error message `Lisp error: (invalid-function (+ 1 2))`, which I explain by saying any list must have a function in the first element position, and having `(+ 1 2)` in the first position is not a function. Good. But again, how to get a result `(3)`? If I try `(list (+ 1 2))` I do in fact get `(3)`. Why does `list` evaluate `(+ 1 2)` then create the list containing `3`? `quote` doesn't -- and, no, it shouldn't. `(function (+ 1 2))` gives `(+ 1 2)`. As I understand,`list` is just syntactic sugar for `(cons (+ 1 2) '())`. Is this true? Can anyone explain some of the details of what I'm experiencing here -- or point me to a good explanation? # Answer +1 for teaching Lisp to 5th graders. And have fun! Lisp, like Logo, is good for kids. --- Your question is a bit rambling. (Emacs.SE is not a place for tutorials or discussions - it's really for specific Q & A.) I recommend that you take a look at the manual *An Introduction to Programming in Emacs Lisp*, by using `C-h i` and choosing **Emacs Lisp Intro**. Work your way through it. (Then maybe do likewise with your 5th graders.) You won't regret it. --- This is false: "any list must have a function in the first element position". If you *evaluate* a list that doesn't have a function as its car then an error is raised. But lists that do not have a function as their car certainly exist. `(3)` is one such example. --- Anyway, the answer to your question is that function `list` conses up its arguments, with `nil` as the last cdr. So yes, `(list (+ 1 2))` is equivalent to `(cons (+ 1 2) ())`. It's generally more convenient to write `(list a b c)` than to write `(cons a (cons b (cons c nil)))`. It's not about being syntactic sugar. Both `list` and `cons` are full-fledged Lisp functions. It's not important how they might be implemented (e.g. in C code). > 4 votes --- Tags: list ---
thread-38347
https://emacs.stackexchange.com/questions/38347
Emacs 27 MELPA connection failure on macOS
2018-01-25T18:06:48.563
# Question Title: Emacs 27 MELPA connection failure on macOS I have been trying to install packages `ivy`, `counsel`, and `swiper` on Emacs 27 prelude. Starting Emacs results in the following error: ``` Warning (initialization): An error occurred while loading ‘/Users/username/.emacs.d/init.el’: error: Could not create connection to melpa.org:443 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. ``` Any ideas on why startup fails? I was using the following init file as a reference point: https://github.com/sitesonix/emacs-prelude-personal/blob/26dab880d0d096a1f04e81b9ee6ba470563aef8f/rtg-init.el. # Answer > 2 votes When installing newer Emacsen via Homebrew, use the `gnutls` switch: ``` brew reinstall emacs --HEAD --with-gnutls ``` Source: https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-12/msg00439.html # Answer > 3 votes You may have to just use `http` instead of `https` Here is what I have (essentially removed the `s` from `https`) Not the perfect solution but something to get me going. ``` (setq package-enable-at-startup nil) (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) ;; (add-to-list 'package-archives ;; '("melpa3" . "http://www.mirrorservice.org/sites/stable.melpa.org/packages/")) ;; Package.el stuff ``` --- Tags: package-repositories ---
thread-53868
https://emacs.stackexchange.com/questions/53868
Difference between apply and funcall
2019-11-19T20:30:08.007
# Question Title: Difference between apply and funcall `(describe-function apply)` says: ``` apply is a built-in function in ‘src/eval.c’. (apply FUNCTION &rest ARGUMENTS) Call FUNCTION with our remaining args, using our last arg as list of args. Then return the value FUNCTION returns. Thus, (apply '+ 1 2 '(3 4)) returns 10. ``` `(describe-function funcall)` says: ``` funcall is a built-in function in ‘src/eval.c’. (funcall FUNCTION &rest ARGUMENTS) Call first argument as a function, passing remaining arguments to it. Return the value that function returns. Thus, (funcall 'cons 'x 'y) returns (x . y). ``` What is the difference between these two function? # Answer Use `apply` when you don't know what the individual arguments are, or how many there are. You can use `funcall` (or `apply`) when you do know that. For example, suppose your *list of args* to apply the function to is the value of variable `foo`. Then you would use `(apply 'some-fun foo)`. If you know that you're going to apply the function to args `3`, `toto`, and `4`, in that order, then you can use `(apply 'some-fun (list 3 'toto 4))` or `(funcall 'some-fun 3 'toto 4)`. > 8 votes --- Tags: apply, funcall ---
thread-53823
https://emacs.stackexchange.com/questions/53823
Selecting punctuation, namely, periods, commas, question marks, exclamations, etc. in Emacs
2019-11-18T09:02:08.610
# Question Title: Selecting punctuation, namely, periods, commas, question marks, exclamations, etc. in Emacs I use Emacs mostly for writing text not code. This involves a great deal of selecting, deleting and editing, as one would expect. By default if I move forward by a word in Emacs, Emacs ignores basic punctuation such as . , ; ? ! ' ". This is especially problematic for me when I want to copy or delete text because it involves using both M-f and then C-f. What I would like is for Emacs to move forward to the empty space AFTER a punctuation mark, so that the punctuation mark after a word becomes part of the selection. If one moves forward by sentences, Emacs does this naturally, but not when one moves by words, and by implication by phrases. For example, in the sentence, ``` Bob went to the store, in a joyful, happy mood. ``` If I wanted to delete the words "to the store," (including the comma) I would like to simply use the mark and press M-f 3 times without also having to then press C-f. I have tried some solutions but none of them really worked for me, including, * evil-mode (I like Vim's behaviour when it comes to moving by words, but do not wish to change my whole workflow to evil) * forward-same-syntax (movements are too refined) * the package syntax-subword (changes the Emacs default too radically) Please note that my default file mode is org-mode, not text-mode. # Answer Two rules to take into account when solving your problem: 1. Do not persistently mess up the syntax table if you do not see through all the consequences. It is used for many tasks. 2. Do not advice `forward-word` to solve your problem. It is also used for many tasks you do not aprehend at the first look. But, what you can do is rebinding the keys for `forward-char` and `backward-char`. The following code defines a new minor mode `forward-w.-mode` and switches it automatically on in new `org-mode` buffers. In `forward-w.-mode` the keys for `forward-word` and `backward-word` are rebound to `forward-w.` and `backward-w.`. These functions skip punctuation chars after running `forward-word`/`backward-char`. The mode uses as much as possible from `forward-char` and `backward-char` to keep stuff like `subword-mode` and text field motion working. ``` (defun forward-w. (&optional arg) "Move point forward ARG words (backward if ARG is negative). In constrast to `forward-word' also skip attached to words punctuation." (interactive "P") (cl-flet ((move-f (_forward-word _skip-syntax-forward _char-after) (let (c) (funcall _forward-word) (while (and (setq c (funcall _char-after)) (eq (char-syntax c) ?.) (progn (funcall _skip-syntax-forward ".") (when (and (setq c (funcall _char-after)) (memq (char-syntax c) '(?_ ?w))) (funcall _forward-word)) (and (setq c (funcall _char-after)) (memq (char-syntax c) '(?_ ?w ?.))))))))) (cl-macrolet ((move (forward after) `(move-f ,@(mapcar (lambda (stuff) (symbol-function (intern-soft (apply #'concat stuff)))) `((,forward "-word") ("skip-syntax-" ,forward) ("char-" ,after)))))) (when (null arg) (setq arg 1)) (cond ((eq arg 1) (move "forward" "after")) ((eq arg -1) (move "backward" "before")) ((> arg 1) (dotimes (i arg) (forward-w. 1))) ((< arg -1) (dotimes (i (- arg)) (forward-w. -1))))))) (defun backward-w. (&optional arg) "Do the same as `forward-w.' with negated ARG." (interactive "P") (unless arg (setq arg 1)) (forward-w. (- arg))) (define-minor-mode forward-w.-mode "Skip punctuation with `forward-word' and `backward-word'." nil " w." (let ((map (make-sparse-keymap))) (define-key map [remap forward-word] #'forward-w.) (define-key map [remap backward-word] #'backward-w.) map)) (add-hook 'org-mode-hook #'forward-w.-mode) ``` > 4 votes # Answer For the specific example you cite, I would execute `M-z ,`, where `M-z` is bound to `zap-to-char`. I don't know how well this would generalize to your daily usage though. > 2 votes --- Tags: org-mode, navigation, selection ---
thread-53880
https://emacs.stackexchange.com/questions/53880
What is #'eq and how does it differ from 'eq
2019-11-20T09:10:35.573
# Question Title: What is #'eq and how does it differ from 'eq I've seen a few snippets of code where symbols were prepended by #' instead '. like the following snippet ``` (seq-count #'not (seq-mapn #'eq seq1 seq2)) ``` What is the difference and why couldn't I just use ' instead of #'? # Answer > 1 votes Functionally, there is no difference in using `#'` instead of `'` in elisp. The main difference is that #' invokes the function `function` and `'` calls `quote`, meaning that your lisp code can be written as: ``` (seq-count (function not) (seq-mapn (function eq) seq1 seq2)) ``` There are many flavors of lisp beside emacs-lisp some of them have decided to differentiate between function symbols and variable symbols, placing them in different namespaces and thus allowing variables and functions to share names. In those cases, `function` is used to get the function symbol, whereas `quote` would give you the variable symbol. This is not done in elisp however, which give you the same symbol in both cases. Thus, `#'` is primarily used to reinforce that the symbol refers to a function and not a variable, even if it's functionally the same. I believe there are some cases where the optimizer can use the knowledge of `#'` to inline some functions, but I'm less certain on that topic. # Answer > 0 votes In addition to what @Xalvew said, here's some information from elisp manual, detailing what differs between `quote` and `function`: > -- Special Form: function function-object > > This special form returns FUNCTION-OBJECT without evaluating it. In this, it is similar to `quote`. But unlike `quote`, it also serves as a note to the Emacs evaluator and byte-compiler that FUNCTION-OBJECT is intended to be used as a function. Assuming FUNCTION-OBJECT is a valid lambda expression, this has two effects: > > • When the code is byte-compiled, FUNCTION-OBJECT is compiled into a byte-code function object. > > • When lexical binding is enabled, FUNCTION-OBJECT is converted into a closure. > > The read syntax `#'` is a short-hand for using `function`. --- Tags: elisp, quote ---
thread-53883
https://emacs.stackexchange.com/questions/53883
Referring to a different table's cell value in org-mode
2019-11-20T10:48:18.230
# Question Title: Referring to a different table's cell value in org-mode I'm doing some code estimating and have split my project up like so ``` * Overview | Proposal | Best case | Likely case | Worst case | Average | |-----------------+----------------------------------------------+------------------------------------------------+------------+---------| | First proposal | (Best case total from first proposal table) | (Likely case total from first proposal table) | etc | | | Second proposal | (best case total from second proposal table) | (Likely case total from second proposal table) | etc | | #+TBLFM: $5=vmean($2..$4);%0.2f ** First proposal | Section | Best case | Likely case | Worst case | Average | |---------+-----------+-------------+------------+---------| | Foo | 1 | 2 | 3 | 2.00 | | Bar | 2 | 3 | 2 | 2.33 | | Baz | 1 | 1 | 1 | 1.00 | |---------+-----------+-------------+------------+---------| | Total | 4 | 6 | 6 | 5.33 | #+TBLFM: $5=vmean($2..$4);%0.2f::@5$2=vsum(@2..@-1)::@5$3=vsum(@2..@-1)::@5$4=vsum(@2..@-1) ** Second proposal | Section | Best case | Likely case | Worst case | Average | |---------+-----------+-------------+------------+---------| | Foo | 1 | 2 | 3 | 2.00 | | Bar | 2 | 3 | 2 | 2.33 | | Baz | 4 | 5 | 8 | 5.67 | |---------+-----------+-------------+------------+---------| | Totals | 7 | 10 | 13 | 10.00 | #+TBLFM: $5=vmean($2..$4);%0.2f::@5$2=vsum(@2..@-1)::@5$3=vsum(@2..@-1)::@5$4=vsum(@2..@-1) ``` Is it possible to get org-mode to automatically copy the total values from the other tables so I don't have to do it manually as I add/edit rows? # Answer You can use remote references for this task. Essentially, they note that the reference (e.g. `@5$2`) shouldn't looked up in the current table, but in a foreign one. You only need a `#+NAME` to refer to other tables: ``` ** First proposal #+NAME: First proposal | Section | Best case | Likely case | Worst case | Average | |---------+-----------+-------------+------------+---------| | Foo | 1 | 2 | 3 | 2.00 | | Bar | 2 | 3 | 2 | 2.33 | | Baz | 1 | 1 | 1 | 1.00 | |---------+-----------+-------------+------------+---------| | Total | 4 | 6 | 6 | 5.00 | #+TBLFM: $>=vmean($2..$>>);%0.2f :: @>$2..@>$>>=vsum(@I..II) ``` The calculation of the sums on the last row has also been simplified to avoid duplication, by using a `range`: the cells on the last row (`@>`) from column 2 (`$2`) to the penultimate column (`$>>`); in each column, the sum ranges over the values from the first horizontal separator to the second horizontal separator (`@I..II`). ``` ** Second proposal #+NAME: Second proposal | Section | Best case | Likely case | Worst case | Average | |---------+-----------+-------------+------------+---------| | Foo | 1 | 2 | 3 | 2.00 | | Bar | 2 | 3 | 2 | 2.33 | | Baz | 4 | 5 | 8 | 5.67 | |---------+-----------+-------------+------------+---------| | Totals | 7 | 10 | 13 | 10.00 | #+TBLFM: $>=vmean($2..$>>);%0.2f :: @>$2..@>$>>=vsum(@I..II) ``` Now it's possible to use `remote(First proposal, @>$2)` to refer to the first proposal's best case total. However, since the name of the remote table is already in the first column of your target table, we can instead use `remote($1, ...)` to get rid of duplicate code: ``` * Overview | Proposal | Best case | Likely case | Worst case | Average | |-----------------+-----------+-------------+------------+---------| | First proposal | | | | | | Second proposal | | | | | #+TBLFM: $2=remote($1, @>$2)::$3=remote($1,@>$3)::$4=remote($1,@>$4)::$5=vmean($2..$4);%0.2f ``` We can simplify this even further and just fill our current column with the last value in the column of the other table: ``` | Proposal | Best case | Likely case | Worst case | Average | |-----------------+-----------+-------------+------------+---------| | First proposal | | | | | | Second proposal | | | | | #+TBLFM: @2$2..@>$>>=remote($1, @>$$#) :: $> = vmean($2..$>>);%0.2f ``` `@2$2..@>$>>` are all fields in the rectangular region from the second row, second column cell to the cell in the last row and the penultimate column; `remote($1, @>$$#)` then looks up a value in the last row (`@>`) but the same column (`$$#`) in the given table. The last column is recalculated from the other columns in the same way as in the other tables, in order to apply the "two digits after the decimal point" format. > 2 votes --- Tags: org-mode ---
thread-51155
https://emacs.stackexchange.com/questions/51155
How to always show buffer in the new created frame?
2019-06-20T17:29:15.343
# Question Title: How to always show buffer in the new created frame? My workflow is: * I initialize emacs with a shortcut (in my `~/.i3/config` I have a line like this `bindcode $mod+49 exec emacsclient -c -n -q -a=''`. I use i3wm.org) * By default it goes to `temp.org`, in .emacs is `(setq initial-buffer-choice "~/org/temp.org")`, which is useful to do temp notes * But sometimes I want to edit an existing file, I use `C-x C-f` (`(ido-mode 1)` is enabled in `.emacs`), most of them, org files. I have very *large* (at least for me) org files that are part of my personal documentation. I can open the same file different times, when this happen I would like to have (and initialize) the same buffer in different frames (I see this as a good default behavior), but I never cannot do that, what happens is that switches (reuses) to the frame where the buffer is. + Example of my problem. - Given: Frame1-temp.org Frame2-thing.org - Action: in Frame1 I do `C-x C-f thing.org` - Consequence: focus switches from Frame1 to Frame2 (because there is thing.org) - Result: Frame1-temp.org Frame2-thing.org + Example of what I would like. - Given: Frame1-temp.org Frame2-thing.org - Action: in Frame1 I do `C-x C-f thing.org` - Consequence: Frame1 displays thing.org - Result: Frame1-thing.org Frame2-thing.org Applying over and over this workflow I end up with lots of `temp.org` emacs frames opened, that I close using a bash alias: `alias killtemp='i3-msg [title="^temp.org.*"] kill'` emacs version: GNU Emacs 26.2 (build 1, x86\_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2019-05-27 # Answer > 0 votes working ``` (setq ido-default-file-method 'selected-window) ``` not working ``` (setq ido-default-buffer-method 'selected-window) ``` thanks to this link, but they point to the wrong solution works in selfcompiled \[1\] GNU Emacs 26.3 (build 1, x86\_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-10-20 \[1\] ``` sudo apt build-dep emacs git clone git://git.sv.gnu.org/emacs.git cd emacs git checkout emacs-26.3 ./autogen.sh all ./configure make clean make sudo make install ``` --- Tags: org-mode, buffers, frames, emacsclient, ido ---
thread-53892
https://emacs.stackexchange.com/questions/53892
Buffer-local input history for read-from-minibuffer
2019-11-20T18:01:26.903
# Question Title: Buffer-local input history for read-from-minibuffer I've been trying to create a command that, when run, calls another function (`my-function`) which reads from the minibuffer and does some processing on the input. I want the command history for this command (`my-command`) to be buffer-local, so that each buffer will have a separate input history. The input history is supposed to be stored in variable `my-hist`. Here's a summarized version of my code: ``` ;; -*- lexical-binding: t; -*- (defun my-function (hist) (read-from-minibuffer "> " nil nil nil 'hist)) (defvar my-hist nil) (make-variable-buffer-local 'my-hist) (defun my-command () (interactive) (add-to-history 'my-hist (my-function 'my-hist))) ``` I've found that after executing `my-command` from two different buffers, their input history is shared, for some reason. Using `M-p` and `M-n` I can go back and forwards through all the inputs I've entered from any of the two buffers. However, if I inspect `my-hist` using `M-:`, the input history appears to be correct for each buffer. Could this be related to how `read-from-minibuffer` looks up the value pointed at by symbol `'hist`? # Answer > 1 votes > What I'm actually trying to do is ... calling `read-number` from a separate function (my-command) with a buffer-local variable as HIST. As `read-number` doesn't have its own history list, you could let-bind `minibuffer-history` to your buffer-local history list around your call to `read-number`. ``` (defvar-local local-history nil "Buffer-local history.") (defun my-command () "Read a number." (interactive) (message "Number was %f" (let ((minibuffer-history local-history)) (prog1 (read-number "Num: ") (setq-local local-history minibuffer-history))))) ``` That `setq-local` is needed because, following the `read-number` call, `local-history` might only be the cdr of the `minibuffer-history` list (i.e. if a new value was pushed to the history), so it needs to be updated to the current value. # Answer > 2 votes Do this: ``` (defvar my-hist nil) (make-variable-buffer-local 'my-hist) (defun my-function (hist) (read-from-minibuffer "> " nil nil nil hist)) (defun my-command () (interactive) (add-to-history 'my-hist (my-function 'my-hist))) ``` Don't quote `hist` when you pass it to `read-from-minibuffer`. You want to pass its *value*, e.g. the symbol `my-hist`, and not the result of evaluating `'hist`, which is the symbol `hist`. But I agree with you about using `M-p` etc. Function `read-from-minibuffer` apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it). That would also explain why, to add to the buffer-local value you need to explicitly use `add-to-history`, passing the value of the input that was read. Normally (i.e., if the history var is not buffer-local), you would just invoke `(my-function 'my-hist)` in `my-command` \- `read-from-minibuffer` automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it. Seems like a bug. But this is longstanding behavior (I see it back to Emacs 22, and I see the fact that it doesn't work without `add-to-history` even back to Emacs 20, which doesn't have `add-to-history`). So I'm probably missing something. Hopefully someone else will enlighten us. (`completing-read` behaves the same way.) Good question. # Answer > 2 votes Here's how to do it buffer-locally: ``` (defvar-local my-hist-symbol nil) (defun my-function () (unless my-hist-symbol ;; Create the buffer's history symbol. (setq-local my-hist-symbol (make-symbol "my-hist"))) (read-from-minibuffer "> " nil nil nil my-hist-symbol)) (defun my-command () (interactive) (my-function)) (defun my-show-buffer-history () (interactive) (if (null my-hist-symbol) (message "No history yet") (message "%s" (symbol-value my-hist-symbol)))) ``` --- Tags: minibuffer, buffer-local, history-variables ---
thread-53897
https://emacs.stackexchange.com/questions/53897
use .dir-locals.el to setup blacklist (based on projectile root) for ccls (c++mode server)
2019-11-20T23:23:17.230
# Question Title: use .dir-locals.el to setup blacklist (based on projectile root) for ccls (c++mode server) I use this setup to setup blacklists for ccls in my project: ``` ( (prog-mode (ccls-initialization-options . (:index (:blacklist [ "^/Users/xxx/proj/dir1/" "^/Users/xxx/proj/dir2/(dir3|dir4)/"]))) ) ``` How do I make it dependent on (projectile-project-root) instead? This didn't work: ``` ( (nil . ((eval . (progn (require 'projectile) (setq ccls-initialization-options (:index (:blacklist (vector (concat "^" (projectile-project-root) "dir1/") (concat "^" (projectile-project-root) "dir2/(dir3|dir4)/")))))))))) ) ``` # Answer > 1 votes You were pretty close. I imagine you want something like this? ``` ((nil . ((eval . (progn (require 'projectile) (setq-local ccls-initialization-options `(:index (:blacklist ,(vector (concat "^" (projectile-project-root) "dir1/") (concat "^" (projectile-project-root) "dir2/(dir3|dir4)/")))))))))) ``` --- Tags: directory-local-variables, ccls, lsp ---
thread-53820
https://emacs.stackexchange.com/questions/53820
Org-mode add a property (e.g. effort) on the same row as my task (similar to priority and tags)
2019-11-18T06:40:10.510
# Question Title: Org-mode add a property (e.g. effort) on the same row as my task (similar to priority and tags) I'd like to show an additional property (e.g. EFFORT) on the same line as my tasks, so that it is always visible in both org-mode and agenda view. An example is below. Current display: TODO \[#A\] Description of my task \<2019-11-18\> :tag1: :PROPERTIES: :Effort: 15 :END: I'd like something like this: TODO \[#A\] **\[15\]** Description of my task \<2019-11-18\> :tag1: Is this possible, preferably not using column view? Thanks. # Answer > 3 votes I don't know how to get it in to both normal view and the agenda view. But, in case it's helpful, one simple way to get effort into headlines in to the agenda view at least, is to edit `org-agenda-prefix-format`. (Also with this, you are restricted as to where exactly you can place the effort indicator. The prefix is everything before the headline itself, so you can't put the effort after TODO for example). --- That said, here is how I do it: ``` M-x customize-variable Customize variable: org-agenda-prefix-format ``` Look specifically for the `agenda` value. The default value of this is: ``` %i %-12:c%?-12t% s ``` I have changed it to: ``` %i %-12:c%?-12t [%-4e] % s ``` It's the \[%-4e\] that adds in the effort indicator. So, ``` GTD: Sched. 7x: TODO [#A] Do the thing ``` becomes ``` GTD: [0:15] Sched. 7x: TODO [#A] Do the thing ``` See `describe-variable` (`C-h``v`) for `org-agenda-prefix-format` for more details on formatting options. # Answer > 1 votes In normal/org mode you could use `overlays`, although I was told Org does similar things which might get in the way (see here). For now @ngm's answer is probably your best option, but in case it helps, here's one way to solve the first part of your question: ``` (add-hook 'org-mode-hook (lambda () (org-map-entries (lambda () (let (match-end) (when (looking-at org-complex-heading-regexp) (setq match-end (or (match-end 3) (match-end 2) (match-end 1))) (let ((ov (make-overlay match-end (1+ match-end)))) (overlay-put ov 'display (when-let (ef (org-entry-get nil "Effort")) (org-add-props (concat " [" ef "] ") nil 'face 'bold)))))))))) ``` --- Tags: org-mode, org-agenda, text-properties ---
thread-52800
https://emacs.stackexchange.com/questions/52800
How to log all state changes of recurring tasks to a drawer just like clock segments?
2019-09-23T15:53:13.813
# Question Title: How to log all state changes of recurring tasks to a drawer just like clock segments? I have a recurring task with multiple state changes: ``` * TODO Some task SCHEDULED: <2019-09-23 Mon 08:00 ++1d> :PROPERTIES: :LAST_REPEAT: [2019-09-22 Sun 16:40] :END: :LOGBOOK: CLOCK: [2019-09-23 Mon 16:42]--[2019-09-23 Mon 16:43] => 0:01 :END: - State "DONE" from "TODO" [2019-09-22 Sun 16:40] - State "DONE" from "TODO" [2019-09-17 Tue 19:22] ``` How can I move the state changes at the bottom, `State "DONE" from "TODO"`, to their own drawer, similar to the clock segments that are in their own drawer? # Answer You'll want to set `org-log-into-drawer` to `t`. By default it is `nil`. You can do this programmatically in your startup with something like ``` (customize-set-variable 'org-log-into-drawer t) ``` or: ``` (setq org-log-into-drawer t) ``` Or, probably better, you can customize the variable (`M-x customize-variable RET org-log-into-drawer`). > 5 votes # Answer Maybe you should just mention the drawer, this worked for me. `(setq org-log-into-drawer LOGBOOK)` > 1 votes # Answer In addition to @jeffkowalski answer, I add my Python code below to also move previous state changes into the `LOGBOOK` drawer. For clock lines, after running `(setq org-clock-into-drawer t)` and clocking in on a headline, any lines under that headline that are a clock segment are moved into that drawer along with the new clock time. But the same does not happen for state changes. I looked at the source code in lines 1508 onwards of `org-clock.el`: ``` ;; When a clock drawer needs to be created because of the ;; number of clock items or simply if it is missing, collect ;; all clocks in the section and wrap them within the drawer. ((if (wholenump org-clock-into-drawer) ... ``` I am too unfamiliar with Emacs LISP to adapt that code, so I used Python 3. The code below runs the doc-tests first and only if they all pass does it process the file. It keeps the order of appearance of lines that are clock segments or state changes. It creates a backup of the file before running it. I inspected the result manually and could not find any errors. Save as `<name-of-script>`, then call with `python3 <name-of-script> -f <path-to-org-file>`. ``` import argparse import doctest import os import re import shutil DEFAULT_FILE = os.path.expanduser("~/org/gtd.org") LOGBOOK_START = ":LOGBOOK:" LOGBOOK_END = ":END:" META_DATA_RE = "^( |\\t)*:?(CLOSED|DEADLINE|SCHEDULED|END|#+END):" HEADLINE_RE = "[*]+ " def find_end_of_metadata(lines): """Finds the last index of metadata in the array >>> lines = ['** TODO task', \ 'SCHEDULED: <2019-09-24 Tue 08:04 ++1d>', \ ':PROPERTIES:', \ ':LAST_REPEAT: [2019-09-23 Mon 11:42]', \ ':END:', \ ':LOGBOOK:', \ '...', \ ':END:', \ 'some comment'] >>> find_end_of_metadata(lines) == len(lines) - 2 True """ if list != type(lines): raise ValueError("This function requires a list as input") num_lines = len(lines) for i in range(num_lines - 1, -1, -1): line = lines[i] if re.match(META_DATA_RE, line) or re.match(HEADLINE_RE, line): return i assert False, "Unable to find end of metadata!" + "\n".join(lines) def process_headline(headline, logbook_start = LOGBOOK_START, logbook_end = LOGBOOK_END): """Processes the headline, creating a logbook drawer if needed, and moving state changes and clocks into the logbook drawer. >>> no_drawer_headline = '\\n'.join(['** TODO task', \ 'SCHEDULED: <2019-09-19 Thu 21:00 ++1d>', \ ':PROPERTIES:', \ ':LAST_REPEAT: [2019-09-18 Wed 21:24]', \ ':END:', \ '- State "DONE" from "TODO" [2019-09-18 Wed 21:24]', \ '- State "DONE" from "TODO" [2019-09-17 Tue 12:52]', \ 'CLOCK: [2019-09-24 Tue 09:01]--[2019-09-24 Tue 09:41] => 0:40', \ 'CLOCK: [2019-04-22 Mon 14:31]--[2019-04-22 Mon 15:23] => 0:52']) >>> no_drawer_actual = process_headline(no_drawer_headline) >>> no_drawer_expected = '\\n'.join(['** TODO task', \ 'SCHEDULED: <2019-09-19 Thu 21:00 ++1d>', \ ':PROPERTIES:', \ ':LAST_REPEAT: [2019-09-18 Wed 21:24]', \ ':END:', \ ':LOGBOOK:', \ '- State "DONE" from "TODO" [2019-09-18 Wed 21:24]', \ '- State "DONE" from "TODO" [2019-09-17 Tue 12:52]', \ 'CLOCK: [2019-09-24 Tue 09:01]--[2019-09-24 Tue 09:41] => 0:40', \ 'CLOCK: [2019-04-22 Mon 14:31]--[2019-04-22 Mon 15:23] => 0:52', \ ':END:']) >>> drawer_headline = '\\n'.join(['** TODO task', \ 'SCHEDULED: <2019-09-19 Thu 21:00 ++1d>', \ ':PROPERTIES:', \ ':LAST_REPEAT: [2019-09-18 Wed 21:24]', \ ':END:', \ ':LOGBOOK:', \ '- State "DONE" from "TODO" [2019-09-18 Wed 21:24]', \ 'CLOCK: [2019-09-24 Tue 09:01]--[2019-09-24 Tue 09:41] => 0:40', \ ':END:', \ '- State "DONE" from "TODO" [2019-09-17 Tue 12:52]', \ 'CLOCK: [2019-04-22 Mon 14:31]--[2019-04-22 Mon 15:23] => 0:52']) >>> drawer_actual = process_headline(drawer_headline) >>> drawer_expected = '\\n'.join(['** TODO task', \ 'SCHEDULED: <2019-09-19 Thu 21:00 ++1d>', \ ':PROPERTIES:', \ ':LAST_REPEAT: [2019-09-18 Wed 21:24]', \ ':END:', \ ':LOGBOOK:', \ '- State "DONE" from "TODO" [2019-09-18 Wed 21:24]', \ 'CLOCK: [2019-09-24 Tue 09:01]--[2019-09-24 Tue 09:41] => 0:40', \ '- State "DONE" from "TODO" [2019-09-17 Tue 12:52]', \ 'CLOCK: [2019-04-22 Mon 14:31]--[2019-04-22 Mon 15:23] => 0:52', \ ':END:']) >>> no_drawer_actual == no_drawer_expected True >>> drawer_actual == drawer_expected True """ # Split by lines lines = re.split("\n|\r", headline) # Find the indices of all the lines that are a state change # and copy them over indices = [] logbook_lines = [] for iLine, line in enumerate(lines): if line.startswith('- State') or line.startswith('CLOCK: '): indices.append(iLine) logbook_lines.append(line) if 0 == len(logbook_lines): return headline # Delete lines from original for iLine in reversed(indices): lines.pop(iLine) # Initialize new array to hold result processed_lines = [] # Find index of logbook drawer, if any if logbook_start in lines: logbook_start_index = lines.index(logbook_start) logbook_end_index = lines.index(logbook_end, logbook_start_index) else: logbook_start_index = find_end_of_metadata(lines) + 1 lines = lines[:logbook_start_index] + [logbook_start, logbook_end] + lines[logbook_start_index:] logbook_end_index = logbook_start_index + 1 # Add clock lines in the logbook drawer return "\n".join(lines[:(logbook_start_index + 1)] + logbook_lines + lines[logbook_end_index:]) def split_headlines(s): """Splits the contents of an Org file by headline and keeps the delimiter that marks it. >>> contents = "\\n".join(['* Level 1', \ '** TODO Level 2', \ 'comments', \ '** Level 2']) >>> actual = split_headlines(contents) >>> expected = ['* Level 1', \ '\\n'.join(['** TODO Level 2', 'comments']), '** Level 2'] >>> actual == expected True """ regex = re.compile("(\\n|\\r)" + HEADLINE_RE) matches = [] prev_end = 0 for match in regex.finditer(s): match_start = match.start() matches.append(s[prev_end:match.start()]) prev_end = match_start if s[prev_end] in ['\n', '\r']: prev_end += 1 if prev_end < len(s): matches.append(s[prev_end:]) return matches def process_file(filepath): """For the org file in the argument, moves the state changes and clock segments into drawers. """ # Make a backup, just in case backup = filepath + "_backup" assert not os.path.exists(backup), "Backup file already exists!" shutil.copy(filepath, backup) assert os.path.exists(backup) with open(filepath, "r") as f: contents = f.read(-1) with open(backup, "r") as f: backup_contents = f.read(-1) assert contents == backup_contents # Split by headlines headlines = split_headlines(contents) # Process each new_headlines = [] count = 0 for h in headlines: new_h = process_headline(h) new_headlines.append(new_h) # Write to file with open(filepath, "w") as f: f.write("\n".join(new_headlines)) def get_args(): parser = argparse.ArgumentParser(description = "Process text in an Org file") parser.add_argument("-f", "--file", default=DEFAULT_FILE) return parser.parse_args() def main(): args = get_args() filepath = args.file process_file(filepath) if "__main__" == __name__: doctests = doctest.testmod() assert 0 == doctests.failed, "Some doc-tests failed, will not run the script" main() ``` Cross-posted to this other thread that dealt with the same problem with lines with clock segments (such as `CLOCK: [2019-07-17 Wed 14:54]--[2019-07-17 Wed 15:00] => 0:06`). > 0 votes --- Tags: org-mode ---
thread-53912
https://emacs.stackexchange.com/questions/53912
How to open an org presentation?
2019-11-21T17:05:13.943
# Question Title: How to open an org presentation? I have a presentation I wrote using presentation mode a few years ago. Now I'm trying to open it and I forget how to do it. I'm trying to run emacs command `presentation-mode` but nothing is found. I tried installing `presentation-mode` but there was no package with that name on Melpa. I also tried installing `org-present` but the command still doesn't work. Is presentation mode built in to emacs or do I need to install it? Also how do I open it? # Answer > 0 votes I was able to find the mode I was using for presentations at that time. I believe it was `outline-presentation-mode` which is a minor-mode for `org-mode`. It doesn't seem to be very popular, as I didn't see it in Melpa. However after loading the elip file manually I seem to be loading my presentation in emacs as I remember it: Links: https://p4bl0.net/shebang/emacs-outline-presentation-mode.html https://web.archive.org/web/20160623023613/http://pablo.rauzy.name/files/sen-meeting\_2013-01-17.outline Elisp file: https://web.archive.org/web/20160810000826/http://clandest.in/emacs.d/plain/outline-presentation.el --- Tags: org-mode ---
thread-53918
https://emacs.stackexchange.com/questions/53918
Capital A Meaning in Emacs Syntax?
2019-11-21T18:59:07.013
# Question Title: Capital A Meaning in Emacs Syntax? I'm familiar with `M` being the modifier key in Emacs syntax but I'm reading the instructions for a package and it is telling me to prepend the modifier with `A`. ``` A-M-n ``` I've tried a few different things but I can't see to find what `A` is refering to here? # Answer > 3 votes Emacs recognizes 5 modifier keys (arguably 6 depending on how you feel about `Shift`): `<Control>` (`C-`), `<Meta>` (`M-`), `<Super>` (`s-`), `<Hyper>` (`H-`), and `<Alt>` (`A-`). This capital A means that this key-sequence uses the uncommon `<Alt>` modifier. Since your `Alt` key, if you even have one, is most likely used for the `<Meta>` modifier, you probably do not have a key currently mapped to work as this modifier. However, you can simulate its use with the key sequence `C-x @ a`. In this case, `C-x @ a M-n` is equivalent to `A-M-n`. (The similar key sequences `C-x @ h` and `C-x @ s` are equivalent to using the `<Hyper>` and `<Super>` modifiers, respectively.) It's worth noting that it is possible to rebind modifier keys to work as different modifiers. For example, on Windows, the `Alt` key can be rebound to work as the `<Alt>` modifier by setting the variable `w32-alt-is-meta` to a `nil` value. --- Tags: keyboard-layout, modifier-key ---
thread-53915
https://emacs.stackexchange.com/questions/53915
I want to simplify repeated calls in my init.el file
2019-11-21T18:38:14.460
# Question Title: I want to simplify repeated calls in my init.el file I've got a lot of: ``` (desktop-save-mode 1) (show-paren-mode 1) ``` which I'd like to collapse into: ``` (mapcar (lambda (fn) (fn 1)) '(desktop-save-mode show-paren-mode)) ``` but I get an error: ``` Symbol’s function definition is void: fn ``` How can I call a list of functions with the same argument? # Answer `(mapcar (lambda (fn) (funcall fn 1)) '(desktop-save-mode show-paren-mode))` > 2 votes # Answer ``` desktop-save-mode ``` is defined thusly: ``` (define-minor-mode desktop-save-mode ``` so its not a function... > -3 votes --- Tags: functions, funcall ---
thread-53899
https://emacs.stackexchange.com/questions/53899
org schedule entry when another transitions to DONE
2019-11-21T02:36:27.797
# Question Title: org schedule entry when another transitions to DONE Is there a mechanism to specify that a todo entry should be scheduled after some other Todo entry transitions to DONE? something like `schedule 2d after completion of some other TODO entry or event`. this is much like how repeated tasks can be automatically rescheduled after transitioning to Done state. I believe this can be implemented by keeping (id and schedule metadata) pair for each task of interest in the master task. the master task would be the task whose transition to the DONE state is going to be used as a hook to schedule tasks. Then on the hook of when the master task transitions to the Done state, schedule appropriately. It would be nice if this info can also be kept track of in the target tasks that are to be scheduled. # Answer > 2 votes I haven't tried it yet but I think org-edna may be a solution. You can specify conditions that must exist before a task is set to DONE, and actions to take once it is. https://www.nongnu.org/org-edna-el/ There is an earlier package called org-depend, described here: https://karl-voit.at/2016/12/18/org-depend/ --- Tags: org-mode ---
thread-53845
https://emacs.stackexchange.com/questions/53845
font-lock-keywords weirdness
2019-11-18T23:36:24.313
# Question Title: font-lock-keywords weirdness I am trying to modify `pandoc-template-mode.el` to deal with `$$` which is an escape sequence for literal `$` inside the Pandoc template. I have added the `"\\$\\$"` at the top but I still get bad font highlighting as if it were hitting last case of the function. The modified `pandoc-template-mode.el`: ``` (defvar pandoc-template-font-lock-keywords '(("\\$\\$" (0 font-lock-keyword-face)) ("\\$--.*" (0 font-lock-comment-face)) ("\\(\\$\\)\\(if\\|for\\)(\\([^)]+\\))\\(\\$\\)" (1 font-lock-preprocessor-face) (2 font-lock-keyword-face) (3 font-lock-variable-name-face) (4 font-lock-preprocessor-face)) ("\\(\\$\\)\\(endif\\|endfor\\|else\\)\\(\\$\\)" (1 font-lock-preprocessor-face) (2 font-lock-keyword-face) (3 font-lock-preprocessor-face)) ("\\(\\$\\)\\(sep\\)\\(\\$\\)" (1 font-lock-preprocessor-face) (2 font-lock-builtin-face) (3 font-lock-preprocessor-face)) ("\\(\\$\\)\\([^$]+\\)\\(\\$\\)" (1 font-lock-preprocessor-face) (2 font-lock-variable-name-face) (3 font-lock-preprocessor-face)) ) "Keyword highlighting specification for `pandoc-template-mode'.") ;;;###autoload (define-derived-mode pandoc-template-mode fundamental-mode "Pandoc-Template" "A major mode for editing Pandoc-Template files." :syntax-table text-mode-syntax-table (setq-local font-lock-defaults '(pandoc-template-font-lock-keywords)) (setq-local comment-start "$--") (setq-local comment-start-skip "\\$--[ \t]*") (setq-local comment-end "") (setq-local comment-end-skip "[ \t]*$")) (provide 'pandoc-template-mode) ``` The test file with bad highlighting: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?aid style="50" type="snippet" readerVersion="6.0" featureSet="513" product="8.0(370)" ?> <?aid SnippetType="InCopyInterchange"?> <Document DOMVersion="8.0" Self="pandoc_doc"> <RootCharacterStyleGroup Self="pandoc_character_styles"> <CharacterStyle Self="$$ID/NormalCharacterStyle" Name="Default" /> $charStyles$ </RootCharacterStyleGroup> <RootParagraphStyleGroup Self="pandoc_paragraph_styles"> <ParagraphStyle Self="$$ID/NormalParagraphStyle" Name="$$ID/NormalParagraphStyle" SpaceBefore="6" SpaceAfter="6"> <!-- paragraph spacing --> <Properties> <TabList type="list"> <ListItem type="record"> <Alignment type="enumeration">LeftAlign</Alignment> <AlignmentCharacter type="string">.</AlignmentCharacter> <Leader type="string"></Leader> <Position type="unit">10</Position> <!-- first tab stop --> </ListItem> </TabList> </Properties> </ParagraphStyle> $parStyles$ </RootParagraphStyleGroup> <RootTableStyleGroup Self="pandoc_table_styles"> <TableStyle Self="TableStyle/Table" Name="Table" /> </RootTableStyleGroup> <RootCellStyleGroup Self="pandoc_cell_styles"> <CellStyle Self="CellStyle/Cell" AppliedParagraphStyle="ParagraphStyle/$$ID/[No paragraph style]" Name="Cell" /> </RootCellStyleGroup> <Story Self="pandoc_story" TrackChanges="false" StoryTitle="$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$" AppliedTOCStyle="n" AppliedNamedGrid="n" > <StoryPreference OpticalMarginAlignment="true" OpticalMarginSize="12" /> <!-- body needs to be non-indented, otherwise code blocks are indented too far --> $body$ </Story> $hyperlinks$ </Document> ``` The issue is that on the 6th line of the template above (`<CharacterStyle Self="$$ID/NormalCharacterStyle" Name="Default" />`) the $$ is matched and colored but then the rest of the text should be uncolored. What actually happens is that the rest of the text after `$$` is colored as if the last rule of the function matched as well. # Answer Indeed, the last font-lock rule still matches, and of its 3 highlighting instructions, the first (that which highlights the opening `$`) won't be applied because this chars has already been highlighted by the first rule, but the other 2 highlighting instructions are still applied because that part of the text hasn't been highlighted yet. There are also "tricky" cases such as: ``` $sep$$sep$ ``` or ``` $$sep$sep$sep$$ ``` where the `$$` isn't "an escaped `$`". Maybe the best way to deal with it is to consider `$...$` as a kind of "string": ``` (defvar pandoc-template-mode-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?$ "\"$") st)) ``` and then in your rules you'll want to use things like: ``` ("\\(\\$\\)\\(sep\\)\\(\\$\\)" (2 (if (save-excursion (nth 3 (syntax-ppss (match-beginngin 2)))) font-lock-builtin-face) prepend)) ``` > 1 votes --- Tags: font-lock ---
thread-53910
https://emacs.stackexchange.com/questions/53910
Temporarily restrict editing to whitespace only
2019-11-21T15:21:03.567
# Question Title: Temporarily restrict editing to whitespace only Sometimes I make whitespace cleanups to source code. I'd like to be certain that I do not accidentally introduce real code changes (let us assume that the programming language is one where removing or adding white space never changes the meaning of code). Is there a minor mode that sets Emacs to only allow whitespace changes in a particular buffer? So I'd be able to delete white space characters (space, tab, newline etc) and add ones, but not make any other alterations to the buffer content. (A more advanced mode would allow changes in the length of white space sequences, and allow introducing and deleting it around punctuation characters, but disallow breaking a word token (defined as, say, a sequence of characters in \[A-Za-z0-9\_\]) by adding new spaces in the middle, nor fusing two separate word tokens by deleting the white space that separated them. But this is not essential. Most programming languages will make it pretty obvious if you accidentally change 'int x;' to 'intx;'.) # Answer While I personally use -- and feel like the general trend is towards -- external tooling (à la `clang-format`/`clang-tidy`, `autopep8`, `perltidy`, `rustfmt`, etc.) Emacs has some useful tools. While it doesn't restrict editing, have you looked at the excellent `whitespace-cleanup` (and its cousin `whitespace-cleanup-region`) that comes with Emacs? Based on your settings for `whitepsace-style`, `indent-tabs-mode`, and `tab-width` it can delete whitespace at the beginning or end of the buffer or lines, compress and expand whitespace and swap around tabs and spaces. It is part of `whitespace.el` and you can find its documentation by doing `C-h f whitespace-cleanup RET`. You could add it to `before-save-hook` to run at every save, or install a wrapper to possibly save yourself some grief. My personal favorite is `delete-trailing-whitespace` which does exactly that; it deletes the trailing whitespace on lines (and optionally and by default) the buffer. Also, check the documentation for the major mode of the language you're using. Often they have baked in functions for editing/refactoring whitespace. Additionally the Emacs wiki has a solid article on deleting whitespace, while the Emacs manual has an entry on useless whitespace. The elisp manual has a page on some whitespace deleting functions > 1 votes # Answer I've run into the same issue. Besides using auto-formatters (which have mixed results - some aren't entirely lossless). * Compare the resulting object code (bytecode, generated AST or assembly), this isn't fool proof if the language uses a preprocessor, nevertheless, it can help. (example for Python, and Rust) * Write a simple function that removes or normalizes all white-space, then compares output. (By normalize I mean converts all kinds of space to a single space or newline for example). While this may be worse in some cases, it will pick up changes missed by a pre-processor. > 0 votes --- Tags: text-editing, whitespace ---
thread-27821
https://emacs.stackexchange.com/questions/27821
Highlight current line without changing colours
2016-10-14T21:56:19.113
# Question Title: Highlight current line without changing colours I use (global-hl-line-mode 1) in order to highlight the current line. This changes the text colours of the highlighted line. Is it possible to highlight while keeping the current syntax highlighting colours (so changing only the background)? # Answer Just for reference, try ``` (set-face-attribute 'hl-line nil :inherit nil :background "gray6") ``` > 8 votes # Answer This is the case by default for me: `hl-line-mode` by default uses a face which only specifies a background color. That face is `hl-line` which by default just inherits from `highlight`. So maybe the problem is simply your that `highlight` face specifies both a background and a foreground color. I recommend you `M-x customize-face` and either change your `highlight` face or your `hl-line` face so as to keep its foreground color unspecified. > 5 votes # Answer This works for me, with this in my .emacs. See how the syntax colours are nicely preserved? (thx Yadoo86) ``` ;; highlight line with the cursor, preserving the colours. (set-face-attribute 'hl-line nil :inherit nil :background "gray80") (global-hl-line-mode 1) ``` > 5 votes --- Tags: syntax-highlighting, highlighting, hl-line-mode ---
thread-2777
https://emacs.stackexchange.com/questions/2777
How to get the function help without typing?
2014-10-28T22:52:07.173
# Question Title: How to get the function help without typing? I'm already used to press `C-h f` and type a function name to ask for help on that function. But if the function name is already under the cursor (e.g. while visiting the .emacs configuration file), is there a way to avoid typing the whole thing again? # Answer > 2 votes My current favorite reference defun (requires popup.el): ``` (require 'popup) (defun describe-thing-in-popup () (interactive) (let* ((thing (symbol-at-point)) (help-xref-following t) (description (save-window-excursion (with-temp-buffer (help-mode) (help-xref-interned thing) (buffer-string))))) (popup-tip description :point (point) :around t :height 20 :scroll-bar t :margin t))) ``` Use that with your key binding of choice for unobtrusive help reference for `symbol-at-point`. # Answer > 12 votes From gnu.org: > If you type `C-h f <RET>`, it describes the function called by the innermost Lisp expression in the buffer around point, provided that function name is a valid, defined Lisp function. (That name appears as the default while you enter the argument. # Answer > 6 votes Just hitting RET should be enough. Alternatively, try the following snippet to define a function that describes the function at point: ``` (defun my-describe-function-at-point () (interactive) (describe-function (function-called-at-point))) ``` # Answer > 3 votes As Sean Alfred commented above, the default for `C-h f` is to already preselect the function at point as the default. But you could also use `helm-apropos` which is part of the standard helm package (available from package repositories, e.g. from MELPA). Helm apropos will preselect the function under the cursor, and I find it one of the nicest tool to locate documentation. # Answer > 3 votes In addition to what others have said, if you use library **`help-fns+.el`** then the defaulting is a bit better - the cursor needs only to be near the symbol (e.g. function name) that you want to use. (The vanilla Emacs behavior picks up only the symbol used for the function call surrounding the cursor, even if the cursor is on top of another function name that you want to investigate. Not too good for a language that passes functions around as arguments etc.) There are also other enhancements to the Emacs help functions in `help-fns+.el`. # Answer > 1 votes I get Elisp documentation with lispy. There, `C-1` toggles the inline doc for current function. Here's how it looks: If the docstring is very large, `*Help*` window is used instead. # Answer > 0 votes You might want to have the documentation display immediately when you type C-h f on a command (that is, without having to press `<RET>`), while keeping the original behaviour of being able to type the function name when you're anywhere else. That is not so trivial to do, because function-at-point is very greedy. Telling it to display its first suggestion will result in you being unable to use C-h f's prompt almost anywhere, because it will always find a neighbour suggestion. So here's my solution, adapted from wasamasa's answer and EmacsWiki's brilliant Describe thing at point ``` (defun my-describe-function-at-point () "Behaves like function-at-point, but removes the need to type <RET> when point is over a function." (interactive) (let (sym) ;; sigh, function-at-point is too clever. we want only the first half. (cond ((setq sym (ignore-errors (with-syntax-table emacs-lisp-mode-syntax-table (save-excursion (or (not (zerop (skip-syntax-backward "_w"))) (eq (char-syntax (char-after (point))) ?w) (eq (char-syntax (char-after (point))) ?_) (forward-sexp -1)) (skip-chars-forward "`'") (let ((obj (read (current-buffer)))) (and (symbolp obj) (fboundp obj) obj)))))) (describe-function sym)) (t (call-interactively 'describe-function))))) (define-key emacs-lisp-mode-map (kbd "C-h f") 'my-describe-function-at-point) ``` --- Tags: help, functions ---
thread-34396
https://emacs.stackexchange.com/questions/34396
Org-Mode correct indentation
2017-07-25T15:05:24.090
# Question Title: Org-Mode correct indentation I am using spacemacs and try to use full text indentation. When I execute "visual-line-mode" and "adaptive-wrap-prefix-mode" by hand via M-x the text will indent, when I edit it. Of course I tried to automate this behaviour with the following configuration: ``` (with-eval-after-load 'org (setq org-startup-indented t) ; Enable `org-indent-mode' by default (add-hook 'org-mode-hook #'visual-line-mode) (add-hook 'org-mode-hook #'adaptive-wrap-prefix-mode)) ``` But this won't work.. and I have no idea why. I also have tried several other solutions (like this one: Correct indentation for wrapped lines), but nothing worked for me. Here a screenshot of my emacs setup after launch: And here is my emacs after I manually entered the above commands: Can someone help me with my problem or is there another solution for that problem? # Answer Adding the following configurations to the org layer did the trick for me ``` (org :variables org-startup-indented t org-indent-mode t) ``` > 2 votes --- Tags: spacemacs, indentation ---
thread-53926
https://emacs.stackexchange.com/questions/53926
Insert space but don't move point
2019-11-22T09:14:57.513
# Question Title: Insert space but don't move point Search didn't yield any success. Perhaps I'm using the wrong search terms... I'd like to insert a single space (just like when you hit `SPC`) but without changing point. I come up with an example (let `|` be the cursor). Say you have `foobar` in a buffer and you placed the cursor in-between. ``` foo|bar ``` Then I'd like to hit a key sequence that inserts a space character at point, but leaves point where it is, instead of moving it past the inserted char. Like so: ``` foo| bar ``` Perhaps something like `insert-space-right`. I could easily write some Elisp code that does this for me, but I'd like to find out whether such a thing is indeed already built-in and I'm just unable to find it. # Answer > 2 votes There's no built-in command to insert a character before the point, presumably because any key binding for it would have to include at least one key stroke in addition to the character, and if you're going to type two keystrokes then the feature already exists: `SPC` `Left` or `SPC` `Ctrl`+`B`. There is a built-in command `open-line` to insert a newline before the point. It exists because it does a few more things than simply inserting a newline, including adding a fill prefix or a margin if inserting a newline would normally add one. The simplest way to write a command that inserts a character before the point is to insert a character, then move the point back. ``` (defun insert-space-before-point () (interactive) (insert " ") (backward-char)) ``` This works, but there's a clearer way to express that the point isn't moving, which is to call `save-excursion` around the part that moves the point. Among other advantages, this makes it straightforward to support a numeric repeat count like you can use when inserting a character. ``` (defun insert-space-before-point (&optional n) (interactive "p") (save-excursion (insert-char ?\ n))) ``` Depending on what you're doing, you may be better off using Emacs's support for right-to-left text, or in a very different vein Picture mode. --- Tags: commands, whitespace, insert ---
thread-50667
https://emacs.stackexchange.com/questions/50667
Org-mode Auto-Fill-Mode
2019-05-23T13:22:27.087
# Question Title: Org-mode Auto-Fill-Mode Whenever I open an org file, I have to activate auto-fill-mode and go through every signle line that I need to read and press `RET` to get a filled paragraph. Is there any way to globally set auto-fill-mode and applied to all the paragraphs in an org file while opening the file? Best. # Answer > 7 votes If you want to *globally set auto-fill-mode*, as you say, the solution would be to put this in your `.emacs.s/init.el` (or equivalent): ``` (add-hook 'org-mode-hook 'turn-on-auto-fill) ``` This means that all files that are viewed in org-mode (usually, files ending in .org) will have auto-fill-mode switched on. If you do that, you will only use @Tyler's answer once: To format the old paragraphs. After that, auto-fill-mode will keep adding `RET` as you type. You can use the occasional `Meta-Q` (`fill-paragraph`) to refill. # Answer > 6 votes If you want a single org file that you share with others to get auto-filled put this as the first line: `# -*- eval: (auto-fill-mode 1) -*-` This will cause auto-fill minor mode to be used when the file is opened. This is part of a feature called 'local file variables'. It is often used to set tab width for code files. Emacs manual page on file variables # Answer > 3 votes If you want to fill all the lines in a region, use the command `M-x fill-region`. To mark the entire buffer (so the region includes the entire file), use the command `M-x mark-whole-buffer`, which is also bound to the keybinding `C-x h`. If you only want to temporarily wrap the lines for easier reading, you can use `visual-line-mode`, combined with visual-fill-column (available as a package on MELPA) to visually wrap the lines without actually adding linebreaks to your file. --- Tags: org-mode, auto-fill-mode ---
thread-21205
https://emacs.stackexchange.com/questions/21205
Flycheck with file relative eslint executable
2016-03-24T22:16:24.193
# Question Title: Flycheck with file relative eslint executable A lot of projects I work on install eslint as a dev dependency, with a custom set of eslint plugins. Right now, flycheck uses the globally installed version of eslint rather than the version of eslint installed with each project. I would like to make flycheck point to node\_modules/eslint/bin/eslint.js instead. The full path should depend on the path of the current buffer's file so I can be working on multiple projects at the same time with each buffer using a potentially different eslint executable. Is this possible? Any suggestions for how I would go about doing this? # Answer You can programmatically change `flycheck-javascript-eslint-executable`, e.g. ``` (defun my/use-eslint-from-node-modules () (let* ((root (locate-dominating-file (or (buffer-file-name) default-directory) "node_modules")) (eslint (and root (expand-file-name "node_modules/.bin/eslint" root)))) (when (and eslint (file-executable-p eslint)) (setq-local flycheck-javascript-eslint-executable eslint)))) (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules) ``` This code looks for a `node_modules` directory in any parent of the buffer's directory and configures Flycheck to use an eslint executable from that directory if any exists. > 35 votes # Answer I don't have enough reputation to comment on the accepted solution. But I made a variation of it, that works well with nested packages (for example using lerna). This is the exact same code, however it looks up the parent `node_modules` folder recursively until it finds an `eslint` binary, and uses it. This way, you can have a lerna project have only one eslint configuration, shared between all sub-packages. ``` (defun my/use-eslint-from-node-modules () (let ((root (locate-dominating-file (or (buffer-file-name) default-directory) (lambda (dir) (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" dir))) (and eslint (file-executable-p eslint))))))) (when root (let ((eslint (expand-file-name "node_modules/eslint/bin/eslint.js" root))) (setq-local flycheck-javascript-eslint-executable eslint))))) (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules) ``` > 4 votes # Answer I'm on windows and this wasn't working for me, I think the file-executable-p or perhaps the flycheck internals were failing to locate the correct file. As when its working it is pointing to the `.cmd` file and not the `.js` file. I found a comment in flycheck-eslint does not use version of eslint installed in JavaScript project and their blog post to use directory variables instead. In the root directory of the project create a file `.dir-locals.el` ``` ((nil . ((eval . (progn (add-to-list 'exec-path (concat (locate-dominating-file default-directory ".dir-locals.el") "node_modules/.bin/"))))))) ``` Now when I visit the javascript file `flycheck-verify-setup` correctly finds the file `<dir>/node_modules/.bin/eslint.cmd` > 0 votes # Answer My previous solution was a pain to get working across different projects. I've modified the accepted answer to hard code windows stupidities. ``` (defun my/use-eslint-from-node-modules () (let* ((root (locate-dominating-file (or (buffer-file-name) default-directory) "node_modules")) (eslint (and root (expand-file-name "node_modules/.bin/eslint.cmd" root)))) (when (and eslint (file-exists-p eslint)) (setq-local flycheck-javascript-eslint-executable eslint)))) ``` > 0 votes # Answer Here's a solution that combines Bae's and lunaryorn's answers using a `dir-locals.el` file in the root directory of the project (or, more specifically, in the directory that contains the `node_modules/` folder where the `eslint` binary lives). Create said `dir-locals.el` file with the following content. ``` ((js2-mode (flycheck-checker . javascript-eslint) (eval . (setq-local flycheck-javascript-eslint-executable (concat (locate-dominating-file default-directory ".dir-locals.el") "node_modules/.bin/eslint"))))) ``` Here I'm assuming you are using the `js2-mode` emacs major mode to edit javascript files. If that's not the case, change that line accordingly. The second line of the file makes the `javascript-eslint` syntax checker the only one to be used within this project. The third line sets the variable `flycheck-javascript-eslint-executable` to `<root-dir>/node_modules/.bin/eslint`. In this way we don't modify emacs' `exec-path`. > 0 votes # Answer I've tried a few different variations of this and never found exactly what I wanted. I've finally leveled up enough in Emacs lisp to modify it to my liking. What my version does is look for a local eslint and if one is not found it falls back to a globally installed one: ``` (defun configure-web-mode-flycheck-checkers () ;; See if there is a node_modules directory (let* ((root (locate-dominating-file (or (buffer-file-name) default-directory) "node_modules")) (eslint (or (and root ;; Try the locally installed eslint (expand-file-name "node_modules/eslint/bin/eslint.js" root)) ;; Try the global installed eslint (concat (string-trim (shell-command-to-string "npm config get prefix")) "/bin/eslint")))) (when (and eslint (file-executable-p eslint)) (setq-local flycheck-javascript-eslint-executable eslint))) (if eslint (flycheck-select-checker 'javascript-eslint))) ``` > 0 votes --- Tags: flycheck ---
thread-53884
https://emacs.stackexchange.com/questions/53884
Can I Jump to bookmark using a pattern?
2019-11-20T12:16:15.750
# Question Title: Can I Jump to bookmark using a pattern? Using Spacemacs, if I `SPC f r` to search for recent files I am prompted for a pattern. I can enter e.g. a value of `our` which will match a file named `Journal.org`. However if I do `C-x r b` to jump to a bookmark, and then enter some text to match, the match appears to only work at the beginning of the bookmark name. In other words, entering git will not match in the bookmark jump list a bookmark of `KB/Git`. However, if I have jumped to `KB/Git` previously, searching for git will offer `KB/Git` in the jump history. Is there a way of suggesting bookmark names where the entered pattern matches any part of the bookmark name, like it does when searching for recent files? I am aware I can co `C-x r l` and then search with / but am wondering if I can get the same result using `C-x r b`. # Answer `C-x r b` is bound by default to `bookmark-jump`, which uses standard function `completing-read` to read a bookmark name. So this is not something special about bookmark names or their completion. It's a question about `completing-read` in general. You can customize option `completion-styles` to control what kind of matching `completing-read` uses. You can use various "fancy" matching styles, such as "flex"/"scatter" and "partial-completion". Some completion "engines" or alternatives provide even more matching possibilities, but they don't necessarily do that for `completing-read` \- they may do it for their own function instead. If you use Icicles then that's not a problem. You have additional possibilities for how `completing-read` does its matching. And you can also use `icicle-bookmark` for `C-x r b` -- it improves upon the vanilla `bookmark-jump`. > 0 votes # Answer ivy/counsel can do this. Just install counsel and put `(counsel-mode t)` somewhere into your configuration. `C-x r b` should get remapped to `counsel-bookmark` which uses ivy for completing bookmark names. > 0 votes # Answer I used `helm-bookmarks` instead of `bookmark-jump` and this allowed searching via a partial bookmark match. > 0 votes --- Tags: completion, bookmarks ---
thread-53908
https://emacs.stackexchange.com/questions/53908
Enable speedbar in ".el.gz" files?
2019-11-21T14:53:23.670
# Question Title: Enable speedbar in ".el.gz" files? When I navigate through \`describe-function' to the source of a function, very often the buffer is visiting a file with a ".el.gz" extension. Often these files are multi-thousand lines, so a list of functions and variables would be quite useful. And speedbar-mode provides exactly the sort of listing that I'm thinking about. However, speedbar-mode doesn't work in these buffers. Is there an easy way to get speedbar-mode to work in these buffers? # Answer > 0 votes It turns out that speedbar has variable containing a whitelist of file extensions which it will index. This is `speedbar-supported-extension-expressions`. The correct way to update this variable is: ``` (speedbar-add-supported-extension ".el.gz") ``` (Note that when I was working on this, I had to restart emacs before the .el.gz files were indexable by speedbar.) --- Tags: speedbar, imenu ---
thread-53773
https://emacs.stackexchange.com/questions/53773
Best way to make org-babel blocks aware of my $PATH and other environment variables?
2019-11-15T19:12:58.093
# Question Title: Best way to make org-babel blocks aware of my $PATH and other environment variables? By default my source code block can't find most executables: ``` #+BEGIN_SRC bash which aws #+END_SRC #+RESULTS: ``` This fixes the problem: ``` #+BEGIN_SRC bash source $HOME/.bash_profile which aws #+END_SRC #+RESULTS: | ]; | PHP | 7.1.25 | | | /Users/bwood/Library/Python/3.7/bin/aws | | | | ``` **My question:** Is there a way to make code blocks of language type bash (or shell) always source my .bash\_profile, without having to add that line at the beginning of every source block? Base on https://orgmode.org/manual/prologue.html I tried adding the following to my init file, but this didn't fix the problem so maybe I'm not understanding what prologue does: ``` (add-to-list 'org-babel-default-header-args:shell '((:prologue . "source /Users/bwood/.bash_profile"))) ``` EDIT: I should have mentioned that I'm running graphical UI Emacs under MacOS. # Answer Try this package exec-path-from-shell which should solve your problem. > 4 votes --- Tags: org-mode, org-babel ---
thread-53944
https://emacs.stackexchange.com/questions/53944
Use Elisp macro instead of two function arguments?
2019-11-23T01:45:42.970
# Question Title: Use Elisp macro instead of two function arguments? Is the following sort of shortcut macro possible to implement? ``` (defmacro region-end-beg () "Replacement for '(region-end) (region-begin)' in source code" (...)) ``` So that ``` (buffer-substring (region-end-beg)) (setq region-length (- (region-end-beg)) ``` Can be used as a shortcut for ``` (buffer-substring (region-end) (region-beginning)) (setq region-length (- (region-end) (region-beginning)) ``` This example is semi-contrived. What I'm interested in is there is a general technique to make this kind of macro in lisp (particularly elisp). # Answer > 2 votes Not exactly. Function `buffer-substring` requires two arguments. Function `-` will accept a single argument, but in that case it just returns the negative of that numeric argument. What you want to do is, in effect, apply such functions to a *list* of arguments. You can use higher-order function `apply` to do that. What you can do, if you want, is have a macro or an ordinary function return a *list* whose elements are the values of `(region-end)` and `(region-beginning)`, using, say, `(list (region-end) (region-beginning))`. But there's no reason to use a *macro* to do that. As a general rule, use an ordinary function instead of macro, whenever that does what you need. With the list constructed by your function, you would then use `apply` to apply `buffer-substring` and `-` to the list returned by your function. That applies those functions to the list elements as arguments. ``` (defun region-end-beg () `...` (list (region-end) (region-beginning))) (apply #'buffer-substring (region-end-beg)) (apply #'- (region-end-beg)) ``` --- Tags: functions, elisp-macros, arguments, apply ---
thread-53911
https://emacs.stackexchange.com/questions/53911
How to stop backspace from doing kill-region?
2019-11-21T13:22:22.913
# Question Title: How to stop backspace from doing kill-region? (I'm using Emacs for more than 25 years, starting in version 18.58 I think) Recently Emacs received changes that make an old-time user quite desperate, and I wonder how to revert some of those dubious "enhancements": When I set a mark, copy and paste the region, and then want to edit the region (frequently I press C-x C-x to place the mark at the start of the pasted region, then move the cursor and try to replace some text, maybe using backspace or delete), it happened more than once (without me noticing it all the time) that as soon as I edit the pasted region that the whole region is replaced by the character input. This is especially dangerous if you duplicate a longer block of text: Recently I modified the only copy of it instead of modifying the duplicate. So which customization setting is responsible for this? I'm using Emacs 25.3. (The other "enhancement" I was able to fix myself was that `next-line` moved down to the next screen line instead of the next buffer line) Here's an attempt for a reproducable example: ``` C-u [universal-argument] 7 [digit-argument] 2 [digit-argument] a [self-insert-command] <return> [newline] C-u [universal-argument] 7 [digit-argument] 2 [digit-argument] b [self-insert-command] <return> [newline] <up> [previous-line] <up> [previous-line] C-SPC [set-mark-command] <down> [next-line] <down> [next-line] M-w [kill-ring-save] C-y [yank] C-y [yank] <up> [previous-line] <up> [previous-line] <up> [previous-line] <up> [previous-line] C-SPC [set-mark-command] <down> [next-line] <down> [next-line] M-w [kill-ring-save] <up> [previous-line] <up> [previous-line] C-y [yank] C-x C-x [exchange-point-and-mark] <right> [right-char] <right> [right-char] <right> [right-char] <right> [right-char] <right> [right-char] <backspace> [backward-delete-char-untabify] ``` The first backspace kills the whole region. # Answer > 4 votes > The first backspace kills the whole region. You'll want to set `delete-active-region` to `nil` (it was introduced in 24.1). ``` delete-backward-char is an interactive compiled Lisp function in ‘simple.el’. [...] If Transient Mark mode is enabled, the mark is active, and N is 1, delete the text in the region and deactivate the mark instead. To disable this, set option ‘delete-active-region’ to nil. ``` ``` delete-active-region is a variable defined in ‘simple.el’. Its value is t Documentation: Whether single-char deletion commands delete an active region. This has an effect only if Transient Mark mode is enabled, and affects ‘delete-forward-char’ and ‘delete-backward-char’, though not ‘delete-char’. If the value is the symbol ‘kill’, the active region is killed instead of deleted. You can customize this variable. This variable was introduced, or its default value was changed, in version 24.1 of Emacs. ``` --- > (The other "enhancement" I was able to fix myself was that next-line moved down to the next screen line instead of the next buffer line) By the way, the intended customization for this is `line-move-visual`. ``` line-move-visual is a variable defined in ‘simple.el’. Its value is t Documentation: When non-nil, ‘line-move’ moves point by visual lines. This movement is based on where the cursor is displayed on the screen, instead of relying on buffer contents alone. It takes into account variable-width characters and line continuation. If nil, ‘line-move’ moves point by logical lines. A non-nil setting of ‘goal-column’ overrides the value of this variable and forces movement by logical lines. A window that is horizontally scrolled also forces movement by logical lines. You can customize this variable. This variable was introduced, or its default value was changed, in version 23.1 of Emacs. ``` --- Tags: region ---
thread-53950
https://emacs.stackexchange.com/questions/53950
How can I format the orgmode clocktable in the agenda view?
2019-11-23T11:03:26.980
# Question Title: How can I format the orgmode clocktable in the agenda view? In the org-mode Agenda view, I can add a clocktable by pressing `R`. However, in this table I would like to hide non-contributing files. In any other dynamic clocktable block, I would specify `:fileskip0`. How can I achieve this for the clocktable in the Agenda view? I would like this formatting by default, i.e. it should show up after just pressing `R`. # Answer Hm, I should have dug a little deeper... The solution is in the variable `org-clocktable-defaults`. I set it using `(setq org-clocktable-defaults '(:maxlevel 2 :lang "en" :scope file :block nil :wstart 1 :mstart 1 :tstart nil :tend nil :step nil :stepskip0 nil :fileskip0 t :tags nil :match nil :emphasize nil :link nil :narrow 40! :indent t :formula nil :timestamp nil :level nil :tcolumns nil :formatter nil))` which is all default values, except for `:fileskip0`, which I changed from `nil` to `t`. > 2 votes --- Tags: org-mode, org-agenda, org-clock-table ---
thread-53840
https://emacs.stackexchange.com/questions/53840
In spacemacs, how do I copy code from the history in python REPL to my window which has a python source code file open?
2019-11-18T20:40:14.337
# Question Title: In spacemacs, how do I copy code from the history in python REPL to my window which has a python source code file open? I'm new to spacemacs -- I'm using it as a Python IDE. I'd like to know if there is an easy way to copy lines from the history on a REPL back to the source-code window. The idea is, I prototype in the REPL and I'd like to copy and clean the code out in the source code window. Thanks. # Answer In normal Emacs you can do that if you use Python REPL (command `C-c C-l`, see in menu) but there are somewhat mixed two commands on one line and not in order. However, if you use iPython, there is possible to have it right. Use the command `%magic` in iPython and you will find out the `%history` magic keyword can do as in the picture below: Note also that typing first in REPL and then moving to a file will be more time consuming and difficult than typing first in source code and then sending to REPL with `C-c C-c`. > 1 votes --- Tags: python, repl ---
thread-53861
https://emacs.stackexchange.com/questions/53861
set-frame-size does not work on emacsclient
2019-11-19T16:41:22.133
# Question Title: set-frame-size does not work on emacsclient I have set up Emacs daemon on Windows 10. My Emacs version is GNU Emacs 25.3.1 I have some code in my `init.el` which resizes the frame size automatically when Emacs starts up. The code is ``` ;; Select a desirable font-size, frame position and frame size when Emacs starts up (defun originalPosition () (interactive) (set-frame-font "Courier New-14" t t) (set-frame-position (selected-frame) 100 50) (when window-system (set-frame-size (selected-frame) 82 28)) ) (originalPosition) ``` This code used to work perfectly when I launched Emacs **normally** (not as daemon). However, emacsclient does **not** accept these settings. Searching around for a solution, I realised that I need to use `after-make-frame-functions` . So I added an *extra* line to my `init.el` ``` (add-hook 'after-make-frame-functions (lambda (frame)(when (display-graphic-p frame)(originalPosition)))) ``` After adding this line, every instance of emacsclient has **different** frame sizes (but uses the correct font size). How can I get emacsclient to use the correct frame size for **every** instance? # Answer > 0 votes I used `default-frame-alist` and it sets the correct frame size ``` (add-to-list 'default-frame-alist '(height . 28)) ;; Vertical frame size (add-to-list 'default-frame-alist '(width . 82)) ;; Horizontal frame size ``` It works when Emacs is launched normally and also when Emacs is run as daemon. --- Tags: microsoft-windows, frames, emacsclient, emacs-daemon, daemon ---
thread-53958
https://emacs.stackexchange.com/questions/53958
How to make sure that long lines are displayed full (without truncation) in Org Mode?
2019-11-23T22:48:45.333
# Question Title: How to make sure that long lines are displayed full (without truncation) in Org Mode? Imagine I have a line that is longer than the available space. I want this one physical line to be displayed as multiple ones (so that I can see it in full without scrolling). In the screenshot below you see one logical line displayed as two (red rectangle): When I open the same file in Emacs, Org mode, type `:vsp`, then that same line is truncated: **How can I make sure that this line is displayed in Emacs like it is in Vim** (see screenshot above)? I tried the following: 1. Adding `(setq-default truncate-lines nil)` to `.emacs` file as suggested here (then restarting Emacs). 2. `M-x auto-fill-mode` or `M-x fill-region` as suggested here. None of this helped. # Answer Click on `Options / Line wrapping in this buffer / Wrap at window edge` to change it for the current buffer. To change it on a permanent basis, you will need to search your initialization file(s) for `truncate-lines`: somebody must be setting it to `t` for Org mode buffers. You will need to change that setting to `nil`. If it only happens on partial-width windows (as shown in your screenshots), you might want to look at `truncate-partial-width-windows` as Jean Pierre points out in a comment. Setting both of these variables to nil (and making sure that nobody overrides those settings) will ensure that lines are wrapped always. Here's the doc string for `truncate-lines`: > truncate-lines is a variable defined in ‘C source code’. Its value is nil > > Automatically becomes permanently buffer-local when set. Calls these functions when changed: (#) This variable is safe as a file local variable if its value satisfies the predicate ‘booleanp’. You can customize this variable. Probably introduced at or before Emacs version 1.7. > > Documentation: Non-nil means do not display continuation lines. Instead, give each line of text just one screen line. > > Note that this is overridden by the variable ‘truncate-partial-width-windows’ if that variable is non-nil and this buffer is not full-frame width. > > Minibuffers set this variable to nil. > 4 votes --- Tags: org-mode ---
thread-53962
https://emacs.stackexchange.com/questions/53962
org mode babel use contents of block as file in another block
2019-11-24T08:17:32.920
# Question Title: org mode babel use contents of block as file in another block I'm trying to define some data in json file and use the file name in another bloc as command parameter. Something like that: ``` The data: #+BEGIN_SRC json { "Foo": "Bar" } #+END_SRC ... and the script #+BEGIN_SRC json do_something_with_json $the_data #+END_SRC ``` Is it possible? # Answer Read (org) var for the capabilities. As far as I know, you can't reference a src block without run it, but you can reference a literal example, for example, you have put your json data into an EXAMPLE block ``` #+NAME: json_data #+BEGIN_EXAMPLE { "method": "+", "params": [1, 2, 3] } #+END_EXAMPLE ``` then you can reference the json data via its NAME ``` #+BEGIN_SRC sh :var x=json_data echo $x | jq .method #+END_SRC #+RESULTS: : + ``` here is another use ``` #+BEGIN_SRC emacs-lisp :var x=json_data (let-alist (let ((json-array-type 'list)) (json-read-from-string x)) (apply (intern .method) .params)) #+END_SRC #+RESULTS: : 6 ``` > 1 votes --- Tags: org-babel ---
thread-2269
https://emacs.stackexchange.com/questions/2269
How do I get my initial frame to be the desired size?
2014-10-16T22:10:24.273
# Question Title: How do I get my initial frame to be the desired size? I have the following in my `.emacs` file: ``` (when window-system (set-frame-position (selected-frame) 0 0) (set-frame-size (selected-frame) 91 63)) ``` The value of 63 is supposed to make my initial frame take up the full vertical height of my screen. However, the result is not actually a frame of 91x63. Instead, I get a frame of only 51. Likewise, increasing 63 to 70 doesn't get me a taller frame either. Initially, I see the frame popup with the full screen height, but then it shrinks down to a much smaller size. I believe this may be related to the fact that I have a configured font face and font size and the frame size is taking effect *before* the font size is set. So when the frame size is initially set, the frame is too large to fit on the screen so the size is shrunk and then later the font face and size are set, but now there is enough room to grow the frame. Do I need to some how control the order of these settings? If so, how do I do that? Currently, I have the font face and size set in the `custom-set-faces` block. Is there a better way to change the frame size so that it happens after the font face is set? By the way, this code came from the Emacs wiki on Frame Size. This is under Ubuntu Linux, and I'm using the PPA for Emacs 24. I am not using any Xresources. For reference, here's my `custom-set-faces` block: ``` (custom-set-faces '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 95 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))) ``` # Answer Since this is being caused by changing the default font/size during init, one can avoid this problem by setting the font via X resources Add to (creating if necessary) the file `~/.Xresources` in the home directory the following line ``` Emacs.font: DejaVu Sans Mono-12 ``` Emacs will normally pick up the change once X has restarted. However, one can get X to recognize changes to `.Xresources` by running `xrdb ~/.Xresources` in a command-line. Alternately, one can pass the same option at the command line using: ``` emacs --font="DejaVu Sans Mono-12" ``` > 5 votes # Answer This is essentially an addendum to Vamsi's answer which I have discovered after the fact. From the documentation on `initial-frame-alist`, it says the following: > You can specify geometry-related options for just the initial frame by setting this variable in your init file; however, they won't take effect until Emacs reads your init file, which happens after creating the initial frame. If you want the initial frame to have the proper geometry as soon as it appears, you need to use this three-step process: > > * Specify X resources to give the geometry you want. > * Set `default-frame-alist` to override these options so that they don't affect subsequent frames. > * Set `initial-frame-alist` in a way that matches the X resources, to override what you put in `default-frame-alist`. This implies that you **must** modify `~/.Xresources` in order to get consistent behavior for the initial frame. Otherwise, the window bounces around on startup, which is the behavior that I'm seeing. Just to round out my final solution. I'm still using this in my init file: ``` (when window-system (set-frame-position (selected-frame) 0 0) (set-frame-size (selected-frame) 91 63)) ``` As well as this: ``` (custom-set-faces '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 95 :width normal :foundry "unknown" :family "DejaVu Sans Mono"))))) ``` But also setting this in my `~/.Xresources` as pointed out by Vamsi: ``` Emacs.font: DejaVu Sans Mono-9.5 ``` And being sure to run `xrdb` after the fact. > 5 votes # Answer If you really mean the initial frame, then see option `initial-frame-alist`. In particular, see this part of the doc string: ``` You can specify geometry-related options for just the initial frame by setting this variable in your init file; however, they won't take effect until Emacs reads your init file, which happens after creating the initial frame. If you want the initial frame to have the proper geometry as soon as it appears, you need to use this three-step process: * Specify X resources to give the geometry you want. * Set `default-frame-alist' to override these options so that they don't affect subsequent frames. * Set `initial-frame-alist' in a way that matches the X resources, to override what you put in `default-frame-alist'. ``` And this part of `(elisp) Initial Parameters` about the same option: ``` If these settings affect the frame geometry and appearance, you'll see the frame appear with the wrong ones and then change to the specified ones. If that bothers you, you can specify the same geometry and appearance with X resources; those do take effect before the frame is created. *Note X Resources: (emacs)X Resources. X resource settings typically apply to all frames. If you want to specify some X resources solely for the sake of the initial frame, and you don't want them to apply to subsequent frames, here's how to achieve this. Specify parameters in `default-frame-alist' to override the X resources for subsequent frames; then, to prevent these from affecting the initial frame, specify the same parameters in `initial-frame-alist' with values that match the X resources. ``` If you mean only frames after the initial frame then see option `default-frame-alist`. Both of these options let you configure any frame parameters, including `font`, so you can control the font size. (You can also customize face `default`.) You can customize user options (`M-x customize-option`), but for these options you will need to be sure that your customizations take effect before the frame gets displayed. > 3 votes # Answer In addition to the answers given so far, if your immediate goal is to make sure emacs opens up at the full height, you can set the `fullscreen` parameter of either the `default-frame-alist` or the `initial-frame-alist`, depending on whether or not you want all your frames to open at the full height, or just the first one: ``` (add-to-list 'initial-frame-alist '(fullscreen . fullheight)) (add-to-list 'default-frame-alist '(fullscreen . fullheight)) ``` > 1 votes # Answer The font size will affect the size of the window at startup, this problem occurred to me when I start to configure it for different screen resolution(home and work use, I put the configuration in Github) months ago. Actually, you can set the size of the window and font at the same time, here is the solution. --- ``` (defun set-frame-size-according-to-resolution () (interactive) (if window-system (progn ;; use 120 char wide window for largish displays ;; and smaller 80 column windows for smaller displays ;; pick whatever numbers make sense for you (if (> (x-display-pixel-width) 1500) (setq default-frame-alist '((top . 0)(left . 0) (width . 85)(height . 48) (font . "Menlo-13") )) (setq default-frame-alist '((top . 0)(left . 0) (width . 85)(height . 35) (font . "Menlo-13") ))) )) ) (set-frame-size-according-to-resolution) ``` --- Adjust the 1500, top/left width/height, font/font-size as you like. Remove the resolution related if you use only one (same resolution)screen, use only the `setq default-frame-alist` part. > 1 votes # Answer I'm running GNU Emacs 25.1.1 on Windows 10. This works for me: In the `~/.emacs` file, I put: ``` (when window-system (set-frame-position (selected-frame) 0 550) ;; 0 - left edge at left of monitor; 550 - top about halfway down the monitor (set-frame-size (selected-frame) 115 13)) ;; 115 - width full width of monitor; 13 - puts bottom at top of taskbar ``` > 0 votes --- Tags: init-file, frames, faces ---
thread-53963
https://emacs.stackexchange.com/questions/53963
Two windows split horizontally-> can't split vertically
2019-11-24T09:23:47.293
# Question Title: Two windows split horizontally-> can't split vertically emacs 26.1 I split windows-horizontally by `split-window-horizontally` Nice. Now I want to get smt like this: I try `split-window-vertically` , but I get this (not correct result): # Answer > 4 votes Emacs is doing what you are asking it to do, unfortunately. https://www.emacswiki.org/emacs/TransposeFrame is a package which allows you to flip the contents of your frame along the horizontal or vertical axis, or to rotate your frame (which is what you are asking for). I find this reasonably useful, so have bound it to a key: ``` (global-set-key [C-S-f6] 'rotate-frame-clockwise) ``` # Answer > 1 votes For splitting the root window, I am using the following function (from Add window to the right of two horizontally split windows): ``` (defun split-root-window (size direction) "splits the root window (i.e., can be used to create a split below/beside splits.) size, if positive is the size of the current root window after the split, and if negative the size of the new split" (split-window (frame-root-window) (and size (prefix-numeric-value size)) direction)) ``` where `direction` is `'left`, `'right`, `'above` or `'below` and `split-window` is from `windows.el` Auxilliary functions bound to keys: ``` (defun split-root-window-above (&optional size) (interactive "P") (split-root-window size 'above)) (defun split-root-window-below (&optional size) (interactive "P") (split-root-window size 'below)) ``` etc.. Other solutions are found in the answers to the following question: Split Window at outermost border --- Tags: window-splitting ---
thread-53971
https://emacs.stackexchange.com/questions/53971
Can I open emacs in nw mode with the scratch buffer?
2019-11-25T01:42:10.343
# Question Title: Can I open emacs in nw mode with the scratch buffer? When starting emacs from the shell command line, if you pass the "dot", it opened emacs with a 'dired' of the current directory. But can I do this? ``` emacs '*scratch*' ``` so emacs opens with the focus on the scratch buffer. ``` # my .bashrc function emacs() { emacsclient -a "" -s workspace -nw "$@" } ``` # Answer > 3 votes There is no need to provide the "." in your command. However, by default, there is a startup message shown. ``` emacs -nw --eval '(setq inhibit-startup-message t)' ``` or ``` emacs -nw --no-splash ``` should do what you want. --- Tags: start-up, scratch-buffer ---
thread-53973
https://emacs.stackexchange.com/questions/53973
How to edit code in the source window using realgud?
2019-11-25T02:44:10.823
# Question Title: How to edit code in the source window using realgud? I've started using realgud:pdb for python debugging in emacs: https://github.com/realgud/realgud When you begin a realgud session, it opens a command window and a source window. Keys like 'n' and 'b' typed inside the source window execute pdb commands, like 'next' or 'breakpoint.' I would like to make modifications to the source code while I debug, but this is impossible if my keystrokes in the source window are captured by the debugging application. Am I missing something? What's the right, effective workflow for making changes to source using realgud based on information I learn in the debugging process? # Answer See `realgud-srcbuf-lock` variable: > Set source buffers read-only when the debugger is active. A setting of `nil` allows editing, but Short-Key-mode use may inhibit this. You can also use `C-x C-q` in `realgud-short-key-mode` to turn read-only mode off. > 0 votes --- Tags: python, debugging, realgud ---
thread-53961
https://emacs.stackexchange.com/questions/53961
install dependencies for emacs package in a CI environment
2019-11-24T05:50:02.833
# Question Title: install dependencies for emacs package in a CI environment I am testing an Emacs package on Travis CI with `ert`. A PR now requires the s package. This is how I currently make sure it's available in the test environment: ``` script: - $EMACS --version - $EMACS --batch --eval "(progn (package-initialize) (add-to-list 'package-archives (cons \"melpa\" \"https://melpa.org/packages/\") t) (package-refresh-contents) (package-install 's))" - $EMACS --batch -L . --eval "(progn (package-initialize) (setq byte-compile-error-on-warn t))" -f batch-byte-compile julia-repl.el - $EMACS --batch -L . -l ert --eval "(package-initialize)" -l julia-repl-tests.el -f ert-run-tests-batch-and-exit; ``` which is rather inelegant: I have to eval `(package-initialize)` every time, and manually install `s`. I have the ``` ;; Package-Requires: ((emacs "25")(s "1.12")) ``` in the package header, is it possible to somehow grab and install all dependencies? # Answer To answer my own question: 1. Since `--batch` disables init files for Emacs, one has to keep the `(package-initialize)`; best I could do is move it to a file and load it with `-l`. 2. But dependencies do not have to be enumerated manually, `package-install-file` can take care of finding them all. Details in the PR above. > 0 votes --- Tags: package, testing ---
thread-53966
https://emacs.stackexchange.com/questions/53966
Defining Agenda Time Frame
2019-11-24T15:32:27.180
# Question Title: Defining Agenda Time Frame Org-agenda has been working well all week. Now that it is Sunday, `C-c a a` produces an agenda that displays Monday 18 November through Saturday 23 of November. I've changed some of the relevant parameters as below ``` (setq org-agenda-span 10) (setq org-agenda-start-day "-3d") ``` or ``` (setq org-agenda-start-day "-1d") (setq org-agenda-span 5) (setq org-agenda-start-on-weekday nil) ``` But it hasn't gotten the agenda to display days beyond Saturday the 23rd of Nov. # Answer This did not have to do with the time frame I was specifiying. Instead it was a problem while parsing the .org files I includin agenda. A message was raised, \`habit "Weekly Review has no scheduled repeat period or has na incorrect one." Initially I ignored this while trying to debug the agenda problems but when I set `SCHEDULED: <2019-11-17 Sun ++1d>` correctly, the agenda built correctly. > 0 votes --- Tags: org-mode, org-agenda ---
thread-53981
https://emacs.stackexchange.com/questions/53981
How to set up emacsclient as default editor on Debian?
2019-11-25T13:25:28.420
# Question Title: How to set up emacsclient as default editor on Debian? ## What am I trying to achieve I want to use `emacsclient` (not `emacs`) as my default text editor on Debian Buster. ## What have I tried so far * Alternatives: ``` > sudo update-alternatives --config editor` There are 3 choices for the alternative editor (providing /usr/bin/editor). Selection Path Priority Status ------------------------------------------------------------ 0 /bin/nano 40 auto mode 1 /bin/nano 40 manual mode 2 /usr/bin/emacs 0 manual mode * 3 /usr/bin/vim.basic 30 manual mode ``` Emacs is listed here, but when I choose `2`, and test using `git rebase -i HEAD~3` (in a git directory) it launches a new `emacs` instance. * `$EDITOR` & `$VISUAL`: I added these 2 lines in my `.bashrc`: ``` EDITOR="emacsclient -nw" VISUAL=emacsclient ``` I can confirm the values are set but `git rebase -i HEAD~3` still opens a `vim`. (This is despite the fact the documentation saying that `$EDITOR` & `$VISUAL` are taken into account ) --- How can I set my default editor to be `emacsclient`, both for terminal & GUI? (Preferably without changing my system in too many places) # Answer I figured out why `.bashrc` solution didn't work. I had to actually `export` the variables: ``` export EDITOR="emacsclient -nw" export VISUAL=$EDITOR ``` --- I use `-nw` both for `$EDITOR` & `$VISUAL` since I don't want to involve my `emacs` frame as much as possible. > 1 votes --- Tags: emacsclient, bash, debian ---
thread-53931
https://emacs.stackexchange.com/questions/53931
How do I reset minibuffer when it seems to act like a regular buffer?
2019-11-22T14:58:23.037
# Question Title: How do I reset minibuffer when it seems to act like a regular buffer? Occasionally the minibuffer acts somewhat like a "regular" buffer. By that I mean that when I type `C-x o` my cursor jumps to that buffer and then waits for me to type something. But I can't write anything to it. For example, when I type `n` a new frame is opened. The label for this buffer seems to be `*Minibuf-0*` \- it is a minibuffer. (Messages are still printed OK to the echo area, which is in the same location as the minibuffer.) What I would like to do is "reset" the minibuffer so that it acts normally. I tried killing that buffer with `C-x k` but that doesn't change anything. The only thing that seems to fix it is a reboot of Emacs. Is there a way to "reset" the minibuffer? # Answer @NickD had the answer! When my echo area "turns into" a minibuffer, I simply choose that buffer and execute the `top-level` function and the problem is solved. Thanks a ton for the help! > 4 votes --- Tags: debugging, minibuffer ---
thread-53984
https://emacs.stackexchange.com/questions/53984
el-get Basic Setup (https://github.com/dimitri/el-get) : error: Unable to find 'git'
2019-11-25T15:21:38.763
# Question Title: el-get Basic Setup (https://github.com/dimitri/el-get) : error: Unable to find 'git' Start Emacs from gitbash (MINGW64) Snippet below is loaded automatically: ``` ; add el-get to the load path, and install it if it doesn't exist (add-to-list 'load-path "~/.emacs.d/el-get/el-get") (unless (require 'el-get nil 'noerror) (with-current-buffer (url-retrieve-synchronously "https://raw.github.com/dimitri/el-get/master/el-get-install.el") (goto-char (point-max)) (eval-print-last-sexp))) ``` **Error:** ``` Warning (initialization): An error occurred while loading 'c:/Users/user/.emacs': error: Unable to find 'git' 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. ``` ; add el-get to the load path, and install it if it doesn't exist (add-to-list 'load-path "~/.emacs.d/el-get/el-get") (unless (require 'el-get nil 'noerror) (with-current-buffer (url-retrieve-synchronously "https://raw.github.com/dimitri/el-get/master/el-get-install.el") (goto-char (point-max)) (eval-print-last-sexp))) **Environments and settings:** * Windows 10 * Git installed (git version 2.14.1.windows.1) * Git installation path(C:\Program Files\Git\cmb) is added to Environment path variable. * HOMEPATH: c:/Users/user * emacs version: GNU Emacs 26.1 (build 1, x86 64-w64-mingw32) of 2018-05-30 **git can not be found even though it's installed. How can I configure Git set-up properly?** # Answer fixed by also adding the `(setq exec-path (cons "C:/Program Files/Git/bin/" exec-path))` to another file (el-get-settings) where the snippet is actually in. ``` Cloning into 'el-get'... POST git-upload-pack (837 bytes) Congrats, el-get is installed and ready to serve!nil ``` Thanks to these two posts - very helpful. https://github.com/dimitri/el-get/issues/220 enter link description here > 2 votes --- Tags: microsoft-windows, git, el-get ---
thread-12609
https://emacs.stackexchange.com/questions/12609
org mode - prevent future repetitive entries from showing up in agenda view
2015-05-22T07:01:05.097
# Question Title: org mode - prevent future repetitive entries from showing up in agenda view It seems to be obvious but I don't seem to have been able to find an answer yet... I have some repetitive tasks which have a property in the style of `SCHEDULED: <2015-05-22 Fri 23:00 .+4d>`. However this has the effect of making that task also showing up on the agenda view of May 26, May 30... etc. etc., which clutters up the agenda view significantly. I notice that scheduled entries with `habit` style don't behave like this, however I don't want to make all repetitive tasks into `habit`. There must be a way to prevent future occurrences of repetitive tasks(Both `DEADLINE` and `SCHEDULED`) from showing up on calendar prematurely? # Answer The default value for the variable `org-agenda-repeating-timestamp-show-all` is `t` -- i.e., "*Non-nil means show all occurrences of a repeating stamp in the agenda.*" The variable can be set to "*a list of strings*" to "*only show occurrences of repeating stamps for these TODO keywords*." When the variable is set to `nil`, "*only one occurrence is shown, either today or the nearest into the future.*" Therefore, the original poster may wish to add the following line to the `.emacs` or `init.el` file: ``` (setq org-agenda-repeating-timestamp-show-all nil) ``` > 12 votes # Answer **TL;DR:** `(setq org-agenda-show-future-repeats nil)`. --- You have to set `org-agenda-show-future-repeats` to `nil`. The previous option `org-agenda-repeating-timestamp-show-all` has been removed from Org mode in version 9.1, as the new pair of options—the previously named `org-agenda-show-future-repeats` and `org-agenda-prefer-last-repeat`—provide a more fine grained control over the shown tasks in the agenda. Note that `org-agenda-show-future-repeats` also supports `next` if you want to show a single future repeat. For more information, see `M-x customize-option org-agenda-show-future-repeats`. > 12 votes --- Tags: org-mode, org-agenda ---
thread-53993
https://emacs.stackexchange.com/questions/53993
Debugger entered--Lisp error: (invalid-read-syntax ")") read(#<buffer *load*>)
2019-11-25T20:53:30.750
# Question Title: Debugger entered--Lisp error: (invalid-read-syntax ")") read(#<buffer *load*>) Launch Emacs using `runemacs --debug-init` and the following error occurred. any idea on how to locate the file/script of the error or how to fix it? Thanks in advance. ``` Debugger entered--Lisp error: (invalid-read-syntax ")") read(#<buffer *load*>) eval-buffer(#<buffer *load*> nil "c:/Users/user/.emacs" nil t) ; Reading at buffer position 1709 load-with-code-conversion("c:/Users/user/.emacs" "c:/Users/user/.emacs" t t) load("~/.emacs" t t) #f(compiled-function () #<bytecode 0x1000be22d>)() command-line() normal-top-level() ``` # Answer > 5 votes You have an extra right paren, `)`, somewhere in your init file. Here's one way to find it: 1. Start Emacs using `emacs -Q` (no init file). 2. Visit this file - the one that Emacs was trying to load when it barfed: ``` C-x C-f /Users/user/.emacs ``` 3. Comment out 1/2 of that file (roughly), using `M-x comment-region`. 4. Do `M-x eval-buffer`. If you get an error, then comment out half of uncommented part. If you didn't get an error, uncomment half of the commented part. Repeat step 4 till you find the problem in your init file. This is a binary search: 1/2, 1/4, 1/8, 1/16, 1/32,... --- If your init file is small, you might want to instead just look for the extra right paren directly. You might start at the file beginning and use `C-M-f` to move past each sexp. Sooner or later you'll get to the one with an extra `)`. --- As @NickD mentioned in a comment, here's another thing to try, and it's quick: > If you just byte-compile the file, the compiler should tell you where it sees the error (no guarantees that it will actually be there, but it doesn't hurt to check it first, before starting a binary search): > > ``` > Compiling file /tmp/foo.el at Mon Nov 25 17:15:31 2019 > foo.el:6:3:Error: Invalid read syntax: ")" > > ``` --- And as @phils mentions in another comment, unmatched parens can be found by using ``` M-x check-parens ``` which takes you directly to the culprit, so it is quicker. --- Tags: init-file, debugging, syntax ---