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-61756
|
https://emacs.stackexchange.com/questions/61756
|
Replace org link description with org link output (shell type)
|
2020-11-15T16:58:24.253
|
# Question
Title: Replace org link description with org link output (shell type)
I've stored several links to various shell commands and I would like to update each link description with the output of the correspoding shell command. For example:
```
View in text-mode: [[shell:echo "hello"][xxx]]
View in org-mode: xxx
```
after running some post-processing function, I would get:
```
View in text-mode: [[shell:echo "hello"][hello]]
View in org-mode: hello
```
I know how to parse the different links and get the underlying shell command:
```
(org-element-map (org-element-parse-buffer) 'link
(lambda (link)
(when (string= (org-element-property :type link) "shell")
(org-element-property :path link))))
```
but then I don't know how to modify the description using `(org-element-context link)`
# Answer
> 1 votes
The link description is the region in the buffer between the values of the properties `contents-begin` and `contents-end`:
```
#+begin_src emacs-lisp
(defun link-desc-region (link)
(list (org-element-property :contents-begin link)
(org-element-property :contents-end link)))
(defun replace-desc-in-link (link newdesc)
(let ((region (link-desc-region link)))
(goto-char (nth 0 region))
(delete-region (nth 0 region) (nth 1 region))
(insert newdesc))))
#+end_src
```
Evaluating `(replace-desc-in-link (org-element-context) "hello")` with point in the link should do what you want.
---
Tags: org-mode, org-link
---
|
thread-57473
|
https://emacs.stackexchange.com/questions/57473
|
Throttle transient-mark-mode highlighting?
|
2020-03-30T19:01:41.857
|
# Question
Title: Throttle transient-mark-mode highlighting?
When I'm using remote X forwarding to run X toolkit emacs and I press `C-SPC` and move the cursor around, things get very slow. The emacs profiler says all the time is spent in line-move-visual, but I don't think that's it. I think it's an issue with the highlighting being expressed inefficiently at the X layer because it only happens when remoting.
`transient-mark-mode` help says it uses the `region` face to decide the color:
> Transient Mark mode is a global minor mode. When enabled, the region is highlighted with the `region` face whenever the mark is active.
But it doesn't indicate there's any way to toggle the rendering. My thinking is I want to throttle how quickly it will highlight (e.g. wait for 50ms of idleness) since usually I'm highlighting several lines or characters and all the intermediate renderings are going to be short lived.
Is there any way to do this? I assume I have to keep the mode active to not affect editing.
# Answer
> 0 votes
The problem is that in transient mark mode every time you move the cursor at all emacs transmits the entire contents of what you have highlighted in order to put it in the X server clipboard! You can disable the behavior with this:
`(setq select-active-regions nil)`
Note this prevents pasting based on middle clicking. Ideally this behavior would be better throttled, or the clipboard could be updated incrementally (not sure if the X protocol supports that).
---
Tags: performance, remote, rendering, transient-mark-mode
---
|
thread-61720
|
https://emacs.stackexchange.com/questions/61720
|
Magit: cannot commit error, unsure why
|
2020-11-13T10:45:03.177
|
# Question
Title: Magit: cannot commit error, unsure why
I am getting the error below and I have *no* clue what could be causing this. Any help is greatly appreciated:
```
1 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false commit --
hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: Wrong number of arguments: (1 . 4), 5
error: There was a problem with the editor '/usr/local/Cellar/emacs-plus\@28/28.0.50/bin/emacsclient --socket-name=/var/folders/77/7ht3td2j1vb00csyp1l4wlv40000gn/T/emacs501/server'.
Please supply the message using either -m or -F option
```
When I run `toggle-debug-on-error` I get the following backtrace:
```
Debugger entered--Lisp error: (error "Text Mode doesn’t support Hideshow Minor Mode")
signal(error ("Text Mode doesn’t support Hideshow Minor Mode"))
error("%s Mode doesn't support Hideshow Minor Mode" "Text")
hs-grok-mode-type()
hs-minor-mode()
run-hooks(change-major-mode-after-body-hook text-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook text-mode-hook))
run-mode-hooks(text-mode-hook)
text-mode()
set-auto-mode-0(text-mode nil)
#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>)()
apply(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>) nil)
so-long--set-auto-mode(#f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>))
apply(so-long--set-auto-mode #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>) nil)
#f(advice-wrapper :around #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>) so-long--set-auto-mode)()
apply(#f(advice-wrapper :around #f(compiled-function (&optional keep-mode-if-same) "Select major mode appropriate for current buffer.\n\nTo find the right major mode, this function checks for a -*- mode tag\nchecks for a `mode:' entry in the Local Variables section of the file,\nchecks if it uses an interpreter listed in `interpreter-mode-alist',\nmatches the buffer beginning against `magic-mode-alist',\ncompares the filename against the entries in `auto-mode-alist',\nthen matches the buffer beginning against `magic-fallback-mode-alist'.\n\nIf `enable-local-variables' is nil, or if the file name matches\n`inhibit-local-variables-regexps', this function does not check\nfor any mode: tag anywhere in the file. If `local-enable-local-variables'\nis nil, then the only mode: tag that can be relevant is a -*- one.\n\nIf the optional argument KEEP-MODE-IF-SAME is non-nil, then we\nset the major mode only if that would change it. In other words\nwe don't actually set it to the same mode the buffer already has." #<bytecode -0x5bd96aaf9730dd8>) so-long--set-auto-mode) nil)
set-auto-mode()
normal-mode(t)
git-commit-setup()
git-commit-setup-check-buffer()
run-hooks(find-file-hook)
#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>)(nil t)
apply(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) (nil t))
(if (setq doom-large-file-p (and buffer-file-name (not doom-large-file-p) (file-exists-p buffer-file-name) (condition-case nil (progn (> (nth 7 (file-attributes buffer-file-name)) (* 1024 1024 (assoc-default buffer-file-name doom-large-file-size-alist ...)))) (error nil)))) (prog1 (apply orig-fn args) (if (memq major-mode doom-large-file-excluded-modes) (setq doom-large-file-p nil) (if (fboundp 'so-long-minor-mode) (progn (so-long-minor-mode 1))) (message "Large file detected! Cutting a few corners to impr..."))) (apply orig-fn args))
doom--optimize-for-large-files-a(#f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) nil t)
apply(doom--optimize-for-large-files-a #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) (nil t))
#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) doom--optimize-for-large-files-a)(nil t)
apply(#f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) doom--optimize-for-large-files-a) (nil t))
#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) doom--optimize-for-large-files-a) doom-first-file-hook-h)(nil t)
apply(#f(advice-wrapper :before #f(advice-wrapper :around #f(compiled-function (&optional error warn noauto after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function.\nSets buffer mode, parses file-local and directory-local variables.\nOptional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an\nerror in reading the file. WARN non-nil means warn if there\nexists an auto-save file more recent than the visited file.\nNOAUTO means don't mess with auto-save mode.\nFourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored\n(see `revert-buffer-in-progress-p' for similar functionality).\nFifth arg NOMODES non-nil means don't alter the file's modes.\nFinishes by calling the functions in `find-file-hook'\nunless NOMODES is non-nil." #<bytecode -0x9f4460c0a610514>) doom--optimize-for-large-files-a) doom-first-file-hook-h) (nil t))
after-find-file(nil t)
find-file-noselect-1(#<buffer COMMIT_EDITMSG> "~/git/GPH-repo/.git/COMMIT_EDITMSG" nil nil "~/git/GPH-repo/.git/COMMIT_EDITMSG" (1273703 16777220))
find-file-noselect("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")
#f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x194e967cfea8742d>)((("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) #<process server <1>> nil)
apply(#f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x194e967cfea8742d>) ((("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) #<process server <1>> nil))
#f(advice-wrapper :after #f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x194e967cfea8742d>) server-visit-files--with-editor-file-name-history-exclude)((("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) #<process server <1>> nil)
apply(#f(advice-wrapper :after #f(compiled-function (files proc &optional nowait) "Find FILES and return a list of buffers created.\nFILES is an alist whose elements are (FILENAME . FILEPOS)\nwhere FILEPOS can be nil or a pair (LINENUMBER . COLUMNNUMBER).\nPROC is the client that requested this operation.\nNOWAIT non-nil means this client is not waiting for the results,\nso don't mark these buffers specially, just visit them normally." #<bytecode 0x194e967cfea8742d>) server-visit-files--with-editor-file-name-history-exclude) ((("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) #<process server <1>> nil))
server-visit-files((("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) #<process server <1>> nil)
server-execute(#<process server <1>> (("/Users/atanas/git/GPH-repo/.git/COMMIT_EDITMSG")) nil nil nil nil nil)
#f(compiled-function () #<bytecode -0x415a275082ff4d7>)()
server-execute-continuation(#<process server <1>>)
server-process-filter(#<process server <1>> "-dir /Users/atanas/git/GPH-repo/ -current-frame -t...")
```
Any idea what could be causing this error? See below for the relevant systemt info:
```
Mac OS X 10.15.7
Emacs 28.0.50 (emacs-plus distro via homebrew)
Doom v2.0.9 (HEAD -> develop f7293fb67 2020-11-11 20:33:27 -0500)
Magit not sure what exact version but it should be the latest
```
# Update
I had `(add-hook 'markdown-mode-hook #'hs-minor-mode)` which I have since removed and get the error below with no backtrace error...
```
0 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false reset HEAD -- \+custom.el
Unstaged changes after reset:
M +custom.el
0 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false add -u -- \+custom.el
1 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false commit --
hint: Waiting for your editor to close the file...
Waiting for Emacs...
*ERROR*: Wrong number of arguments: (1 . 4), 5
error: There was a problem with the editor '/usr/local/Cellar/emacs-plus\@28/28.0.50/bin/emacsclient --socket-name=/var/folders/77/7ht3td2j1vb00csyp1l4wlv40000gn/T/emacs501/server'.
Please supply the message using either -m or -F option.
0 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false push -v origin master\:refs/heads/master
Pushing to https://github.com/atanasj/.doom.d.git
To https://github.com/atanasj/.doom.d.git
= [up to date] master -> master
updating local tracking ref 'refs/remotes/origin/master'
Everything up-to-date
```
# Answer
This error was related to `magit` with `emacs 28.0.50` (see issues on `magit` repo for further info). I installed `emacs 27.1` via `homebrew emacs-plus@27` formula and everything is working as expected.
> 1 votes
---
Tags: magit, doom
---
|
thread-27147
|
https://emacs.stackexchange.com/questions/27147
|
How to list branches with Magit
|
2016-09-18T01:47:51.297
|
# Question
Title: How to list branches with Magit
How do I list the branches of a repository in Magit (i.e., the equivalent of `git branch --list`)? I expected to find this in the branch popup, but it seems to be neither there nor was I able to find it anywhere in the "Inspecting" section of the User's manual. What am I missing?
# Answer
> 89 votes
Use `magit-show-refs`, bound by default to `y`.
# Answer
> 3 votes
To list branches and tags directly in your Magit status buffer, customize `magit-status-sections-hook` to add any/all of:
* `magit-insert-local-branches`
* `magit-insert-remote-branches`
* `magit-insert-tags`
---
Tags: magit
---
|
thread-61686
|
https://emacs.stackexchange.com/questions/61686
|
Error using diary
|
2020-11-11T16:14:25.033
|
# Question
Title: Error using diary
Currently I try to use `diary`, but unfortunately there seems to be an error or bug in emacs.
Every time I try to create a note in `diary` through the `calendar` and then push key `i` (insert as described in the documentation), I get the following error:
```
command-execute: Wrong type argument: commandp, org-agenda-diary-entry
```
I am on Emacs 27.1/ Fedora 33.
Has anyone had this issue?
I read (emacs help-list) about a renaming of functions in org-mode not synced with emacs, but I don't understand this, because I'm not a developer.
# Answer
> 1 votes
Comment by NickD: "Then you have not loaded Org mode: try evaluating `(require 'org-agenda)` and then see if it works. You can then add this form to your init file, so when you restart emacs, the function will be available."
Yes that was the fault. I insert an autoload command before loading the calendar. Now it works.
---
Tags: org-agenda, diary
---
|
thread-61766
|
https://emacs.stackexchange.com/questions/61766
|
How does emacsclient determine what XDG_RUNTIME_DIRS is supposed to be?
|
2020-11-16T02:11:18.653
|
# Question
Title: How does emacsclient determine what XDG_RUNTIME_DIRS is supposed to be?
When I run `emacsclient` I get this error:
```
$ emacsclient .
emacsclient: Should XDG_RUNTIME_DIR='/run/user/10030' be in the environment?
emacsclient: (Be careful: XDG_RUNTIME_DIR is security-related.)
emacsclient: can't find socket; have you started the server?
emacsclient: To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR)
```
Sure enough setting `XDG_RUNTIME_DIR='/run/user/10030'` and running again fixes the problem but I would like to automate this. I could try running once and parsing this error message but that doesn't seem like the right way to do it. How is `emacsclient` figuring it out?
# Answer
> 3 votes
Normally either `XDG_RUNTIME_DIR` is available and your operating system should arrange for it to be set when you log in, or `XDG_RUNTIME_DIR` isn't available (by Unix time scales, it's a very modern thing). Usually, on most modern Linux systems, it's set by systemd.
If `/run/user/*YOU_USER_ID*` exists, it's extremely unlikely for it not to be a suitable value for `XDG_RUNTIME_DIR`. So you could add this code to your `~/.profile` or whatever sh script sets up the environment in which you run `emacs` and `emacsclient`.
```
if [ -z "$XDG_RUNTIME_DIR" ]; then
XDG_RUNTIME_DIR=/run/user/$(id -u)
if [ -d "$XDG_RUNTIME_DIR" ] && [ -w "$XDG_RUNTIME_DIR" ]; then
export XDG_RUNTIME_DIR
else
unset XDG_RUNTIME_DIR
fi
fi
```
---
Tags: emacsclient
---
|
thread-55388
|
https://emacs.stackexchange.com/questions/55388
|
C-c c c to invoke org-capture
|
2020-02-09T08:59:20.257
|
# Question
Title: C-c c c to invoke org-capture
In my doom-emacs, "C- n n" will invoke `org-capture`,
I want to change it to "C-c c c" as
```
(global-set-key "\C-c c c" 'org-capture)
```
However, it does not work as expected.
How could set `C-c c c` to substitute `C-c n n`
I find such key Binding:
```
Key Bindings
doom-leader-map n n
doom-leader-notes-map n
general-override-mode-map C-c n n
global-map C-c c
mode-specific-map c
```
it seems that `general-override-mode-map C-c n n` will override anything I set.
# Answer
You need to set a prefix command. Generally said this can be used to combine key bindings that fit together. You will probably have already experienced that in specific modes.
Projectile for example has `C-c p ...` where `...` can be a lot of possible commands related to projectile.
Another Example would be Yasnippet with `C-c & ...` where `...` could be `C-n`, `C-s` or `C-v` for new, insert or view.
I for example use that for the terminal program I use.
```
(define-prefix-command 'term-map)
(global-set-key (kbd "C-x .") 'term-map)
(global-set-key (kbd "C-x . t") 'term)
(global-set-key (kbd "C-x . s") 'shell)
(global-set-key (kbd "C-x . e") 'eshell)
```
In your case it would look like this:
```
(define-prefix-command 'example-map)
(global-set-key (kbd "C-c c") 'example-map)
(global-set-key (kbd "C-c c c") 'org-capture)
(global-set-key (kbd "C-c c ...") 'something-else)
```
Where `...` can be any keystroke
> 1 votes
# Answer
I found myself having a similar problem with binding `M-x` in doom emacs. It appears that something like `(map! "M-x" 'helm-M-x)` does not work, but when you try to see how this binding is setup, you realize that it is setup within the map `general-override-mode-map`. So the solution is to do instead:
```
(map! :map general-override-mode-map "M-x" 'helm-M-x)
```
so you may want to do something like:
```
(map! :map general-override-mode-map "C-c c c" 'org-capture)
```
Note that there may be a better solution.
> 0 votes
---
Tags: key-bindings
---
|
thread-56283
|
https://emacs.stackexchange.com/questions/56283
|
org -- preserve white space on export to odt
|
2020-03-22T02:02:48.447
|
# Question
Title: org -- preserve white space on export to odt
i write poetic texts in org mode and i'd like to be able to export them to odt with their horizontal spacing preserved if possible.
it's poetry but not of the traditional kind. text is often heavily indented or spread all over the place. at present i indent text with `M-i`, which runs `tab-to-tab-stop` and inserts 8 spaces at at time.
on exporting to odt, all spacing is lost, my lines are left justified. i tried using verse blocks, but it outputs in monospace, and only indents my lines about 2-3 spaces, rather than say the 40 or 50 i have inserted.
ideally i'd like to be able to do anything i might do in a word processor in emacs, and have it preserved on export, if possible.
EDIT: i run emacs 26.1, org-mode 9.3
# Answer
so after many gloomy moons of poetic gloom, i worked out my issue, which i hereby declare to all posterity:
setting `org-export-preserve-breaks` to `t`, breaks the export of whitespace, even in `org-verse` blocks.
`org-export-preserve-breaks` is also set by `\n:t` in the export template.
> 1 votes
# Answer
> i write poetic texts in org mode and i'd like to be able to export them to odt with their horizontal spacing preserved if possible.
Could you copy-paste the poetic text (i.e., the actual org snippet) that you are exporting?
> on exporting to odt, all spacing is lost, my lines are left justified.
The Org exporter strips the leading whitespace COMMON to all lines. i.e., The leading COMMON whitespace chars in a verse block are insignificant
* if ALL lines in the verse are indendented by 8 spaces, then the Org exporter treats the verse block as if it had ZERO leading indentation
* if ALL BUT ONE line is indented by 8 spaces, and the lone one is indented by 6 spaces, then all lines in the exported verse block will be indented by TWO SPACES, save for that lone line which would have NO indentation.
---
That said, the easiest way for you to achieve what you want is to use the ***FORK*** of the ODT exporter (See Project Summary (OpenDocument Text Exporter for Emacs’ Org Mode)).
The *keyword* you are looking for is`#+ODT_EXTRA_STYLES` (See Applying custom styles (OpenDocument Text Exporter for Emacs’ Org Mode))
Here is a sample snippet and the corresponding output
```
#+odt_preferred_output_format: pdf
#+odt_extra_styles: <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text">
#+odt_extra_styles: <style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.212cm" loext:contextual-spacing="false">
#+odt_extra_styles: <style:tab-stops/>
#+odt_extra_styles: </style:paragraph-properties>
#+odt_extra_styles: <style:text-properties style:font-name="Courier New1" fo:font-family="'Courier New'" style:font-style-name="Regular" style:font-family-generic="modern" style:font-pitch="fixed" fo:font-size="16pt"/>
#+odt_extra_styles: </style:style>
#+odt_extra_styles: <style:style style:name="OrgVerse" style:family="paragraph" style:parent-style-name="Preformatted_20_Text" style:master-page-name="">
#+odt_extra_styles: <loext:graphic-properties draw:fill="none" draw:fill-color="#729fcf"/>
#+odt_extra_styles: <style:paragraph-properties fo:margin-left="0.499cm" fo:margin-right="0cm" fo:text-indent="0cm" style:auto-text-indent="false" style:page-number="auto" fo:background-color="transparent" fo:padding="0cm" fo:border="none" style:shadow="none">
#+odt_extra_styles: <style:tab-stops>
#+odt_extra_styles: <style:tab-stop style:position="1.0cm"/>
#+odt_extra_styles: </style:tab-stops>
#+odt_extra_styles: </style:paragraph-properties>
#+odt_extra_styles: <style:text-properties style:font-name="Comic Sans MS" fo:font-family="'Comic Sans MS'" style:font-style-name="Regular" style:font-family-generic="script" style:font-pitch="variable" fo:font-size="12pt"/>
#+odt_extra_styles: </style:style>
This is a poem by Rudyard Kipling
#+begin_verse
If you can keep your head when all about you
Are losing theirs and blaming it on you,
If you can trust yourself when all men doubt you,
But make allowance for their doubting too;
If you can wait and not be tired by waiting,
Or being lied about, don’t deal in lies,
Or being hated, don’t give way to hating,
And yet don’t look too good, nor talk too wise:
#+end_verse
```
*(In the above verse block, the indented line uses a SINGLE TAB)*
---
Btw, as you might have guessed, the user manual for the ***FORKED VERSION*** of ODT exporter is Top (OpenDocument Text Exporter for Emacs’ Org Mode).
> 1 votes
---
Tags: org-mode, org-export, text-editing
---
|
thread-61785
|
https://emacs.stackexchange.com/questions/61785
|
What does -> mean in library dash.el?
|
2020-11-17T01:46:02.883
|
# Question
Title: What does -> mean in library dash.el?
What does the `->` mean here:
```
(interactive
(list
(-> (dap--completing-read "Select configuration template: "
(-mapcat #'funcall dap-launch-configuration-providers)
'cl-first nil t))))
```
# Answer
> 1 votes
It's the name of a Lisp macro provided by library `dash.el`. Checkout `C-h f`.
---
Tags: dash.el
---
|
thread-61787
|
https://emacs.stackexchange.com/questions/61787
|
What does “:” mean in elisp?
|
2020-11-17T03:13:12.587
|
# Question
Title: What does “:” mean in elisp?
Does the `:` have a special meaning in Elisp?
```
(define-minor-mode dap-mode
"Global minor mode for DAP mode."
:init-value nil
:group 'dap-mode
:global t
:require 'dap-mode
:lighter (:eval (dap-mode-line))
(dap--after-initialize)
(add-hook 'lsp-after-open-hook 'dap--after-open))
```
# Answer
It turns the symbol into a keyword. See chapter 12.2 Variables that Never Change in the Emacs Lisp manual.
Keywords are frequently used to identify named arguments to Lisp functions and macros. When the implementation of `define-minor-mode` needs to know whether the mode should be global or not, it walks down the list of arguments looking for :global, then takes the next value in the list. The caller can supply the keyword arguments in any order, and can leave out any arguments if needed.
The other place they are commonly used is as the keys in property lists (plists). These are key-value stores, conceptually similar to dictionaries, association lists, associative arrays and maps in other languages. See chapter 5.9 Property Lists in the Emacs Lisp manual.
> 13 votes
---
Tags: symbols, keywords
---
|
thread-61791
|
https://emacs.stackexchange.com/questions/61791
|
How to apply a hunk of changes in diff to current branch?
|
2020-11-17T09:27:55.883
|
# Question
Title: How to apply a hunk of changes in diff to current branch?
I have two branches, let's say branch `a` and `b`, I would like to apply some changes from `b` to `a`.
Note that I use `magit-diff` to show the differences between the two branches. Then I would like to apply some changes pointed out by `magit-diff` from `b` to `a`.
So, could please tell me how should I do this. Or is there better ways.
# Answer
Put the cursor on the change in question and press `a` for "apply". Also see Staging and Unstaging and Applying in the manual.
> 2 votes
---
Tags: magit, git, diff
---
|
thread-61282
|
https://emacs.stackexchange.com/questions/61282
|
How to not let a shell to capture the space key in Spacemacs?
|
2020-10-18T09:08:53.190
|
# Question
Title: How to not let a shell to capture the space key in Spacemacs?
In spacemacs, the space key is used to trigger the command shortcut, and an extra space can lead to a input/search of emacs command.
Now I run into this situation:
I use `SPC b n` to switch to next buffer in spacemacs. However when it cycles to the shell window, it captures the space input and I cannot trigger spacemacs options anymore.
Is there any way I stop the shell from capturing the space input?
# Answer
> 0 votes
In spacemacs when in `Insert state`, `Alt-m` works as the first `space` pressed. In your case, I think you could just press `Alt-m`, then `b n` to switch to the next buffer.
Stopping sending `space` to shell might not be a good idea.
# Answer
> 0 votes
This is not really an answer. Just a too long comment to post in as a comment.
EDIT
I have quickly had another look now. I think you could just (globally or in your preferred evil-states) rebind the `next-buffer` and `previous-buffer` functions to your preferred keys. You can use e.g. `C-,` and `C-.`. Although they are bound to flyspell and evil function by default, I never use those. So you can unbind them and bind the buffer switch function by adding the following lines to the `user-config` section of you .spacemacs file:
```
(define-key flyspell-mode-map (kbd "C-,") nil)
(define-key flyspell-mode-map (kbd "C-.") nil)
(define-key evil-normal-state-map (kbd "C-.") nil)
(define-key global-map (kbd "C-,") 'previous-buffer)
(define-key global-map (kbd "C-.") 'next-buffer)
```
Then optionally you could activate also `tab-line-mode`.
END EDIT
Personally I think `SPC b n` is inferior to using e.g. `C-tab` like in most standard applications. Emacs 27 provides tab-bar-mode so that you can use `C-tab` for switching between window configurations. Also there is a tab-line-mode which lets you switch between buffers. I think you should play with these modes and rebind `tab-line-mode`'s `previous-buffer` and `next-buffer` functions (e.g to `C-,` and `C-.` which correspond to the `<` and `>` keys without pressing shift). There is an unfinished centaur-tabs layer that you can try and install and from which you might get some inspiration. I stopped working on the layer as I thought I should start from the basic `tab-bar-mode` and `tab-line-mode` functions. Also I think even the tabs are unnecessary, we could just cycle over buffers while showing them in the minibuffer (instead of listing the buffers in tabs). But a package still has to be developed for that (I think).
---
Tags: spacemacs, shell
---
|
thread-61784
|
https://emacs.stackexchange.com/questions/61784
|
How to use counsel-git-grep without using back slash
|
2020-11-16T23:57:45.173
|
# Question
Title: How to use counsel-git-grep without using back slash
I am using `counsel-git-grep` to grep for a string in the current Git repository.
Lets assume I am searching string " `[ok]` ". In order to obtain correct results I have to provide input as " `\[ok\]` " ; where `\` should be added before some characters like `[`, `]`, `"`, etc.
Is there any way achieve the `grep` results without using `\`?
# Answer
> 1 votes
I think in theory this should be possible by adding `-F` to the grep flags in the `counsel-git-grep-cmd-default` variable by evaluating
```
(setq counsel-git-grep-cmd-default "git --no-pager grep -F -n --no-color -I -e \"%s\"")
```
(of course you could add this to your init.el file)
However, I am not sure if it works in practice (because of some weird behaviors I am not able to test it here quickly).
---
Tags: counsel
---
|
thread-61800
|
https://emacs.stackexchange.com/questions/61800
|
How to export an org file containing code blocks to a code file including comments?
|
2020-11-17T17:51:08.080
|
# Question
Title: How to export an org file containing code blocks to a code file including comments?
Suppose I have the following org file (pdguide.org):
```
* Creating a Pandas =DataFrame=
The pandas =DataFrame= can be created by loading the data from the external, existing storage like a database, SQL or CSV files. But the pandas =DataFrame= can also be created from the lists, dictionary, etc. One of the ways to create a pandas data frame is shown below:
- import pandas library
#+begin_src python
import pandas as pd
#+end_src
- Dictionary of key pair values called data
#+begin_src python
data = {'Name':['NickD', 'John', 'Sam', 'crocefisso', 'Debbie'],
'Age': [24, 23, 22, 19, 10]}
#+end_src
- Calling the pandas DataFrame method by passing the dictionary (data) as a parameter
#+begin_src python
df = pd.DataFrame(data)
df
#+end_src
```
How can I export it to a pdguide.py so the parts that are not code blocks become comments?
Also would it be possible to have it exported as pdguide.ipynb so the part that are not code blocks become markdown?
# Answer
The process is called tangling.
All you have to do is provide a header arg to specify that, e.g.:
```
#+PROPERTY: header-args:python :tangle pdguide.py
```
After you add the line to your buffer, don't forget to refresh it by typing `C-c C-c` on the property line.
Then you can tangle the code into the file with `C-c C-v C-t`.
EDIT: you can include the nearest headline as comments (from the headline to the text before the code block) by using `:comments both` as a header arg: that will include the headline as a comment and will provide links back to the Org mode file for each code block. You can use `:comments org` for just the headline, or `:comment link` for just the links.
As for your last question: "Also would it be possible to have it exported as pdguide.ipynb so the part that are not code blocks become markdown?", AFAIK the answer is no. EDIT: The OP points out in a comment that something like this might be possible using John Kitchin's 'ipynb' exporter.
> 3 votes
---
Tags: org-mode, org-export
---
|
thread-61790
|
https://emacs.stackexchange.com/questions/61790
|
Can I use Right Alt/Ctrl Keys as Alt/Super/Hyper modifier keys of Emacs in Windows 10?
|
2020-11-17T08:25:09.070
|
# Question
Title: Can I use Right Alt/Ctrl Keys as Alt/Super/Hyper modifier keys of Emacs in Windows 10?
I noticed that I've rarely used Right Control Key and Right Alt Key in my keyboard, so I'm wondering if I can use them as Alt/Super/Hyper modifier key in Emacs.
Is such a thing possible in Windows 10?
Taking a look at \`w32fns.c' seems right control key is equivalently treated as left control key, so it may be difficult by Emacs alone. I just want to know if it can be realized by the combination with AutoHotkey or other key event modifier tools.
BTW, assigning Windows (either Left/Right) Key as Super/Hyper key works perfectly in my environment by following codes, and I use Left Windows as functions provided by the Windows OS, so I only use Right Windows key as Superkey.
```
(setq w32-pass-rwindow-to-system nil)
(setq w32-rwindow-modifier 'super)
(w32-register-hot-key [s-])
```
# Answer
Setting
```
RCtrl::F24
```
in Autohotkey Configuration, then setting
```
(setq w32-pass-rwindow-to-system nil)
(setq w32-rwindow-modifier 'super) ; Right Windows key
(w32-register-hot-key [s-])
(setq w32-apps-modifier 'super) ; Microsoft Surface App Key
(bind-key "<f24>" 'event-apply-alt-modifier function-key-map)
```
in init.el solved most of my problems.
RCtrl key now acted as ALT modifier prefix key, and Right windows key act as Super Modifier Key. (Except Win+G and Win+L, which are used by the Windows OS.)
Among Shift, Control, and Super modifier keys which are a supposed to be pressed by little fingers, only two can be pressed simultaneously.
Meta (Alt) modifier keys (left/right) are to be pressed by thumbs of both hands.
By pressing RCtrl (alt) key and then pressing Alt(Meta), Control and Windows Right (Super) key gives the event "A-C-M-s-x" key event in short period of time.
> 0 votes
---
Tags: key-bindings, microsoft-windows, modifier-key
---
|
thread-61806
|
https://emacs.stackexchange.com/questions/61806
|
Iterate only length times over a list
|
2020-11-18T07:23:12.320
|
# Question
Title: Iterate only length times over a list
Let's say have the following list `foo`:
```
(setq foo '(cat dog rat bar))
```
When I iterate over it using say `dolist`, I get an extra nil:
```
(dolist (ele foo)
(print ele))
cat
dog
rat
bar
nil
```
Why is there the extra `nil` ? Shouldn't `dolist` only iterate over the list the lenght times? (Over each element)
Of course having seen `dotimes` in the documentation along with `dolist` I tried to use that as well:
```
(dotimes (i (length foo))
(print (nth i))))
cat
dog
rat
bar
nil
```
I also tried `(- (length foo) 1)`
```
cat
dog
rat
nil
```
### So here are my questions
1. Shouldn't `nil` be omitted in all cases?
2. Is there a way I can omit that nil (and iterate over all elements)
3. I have a feeling that this something to do with linked lists. Can you please explain the missing concept?
**Note:** I am quite new to elisp and lisp in general. Please be gentle while commenting and answering. I actually am iterating over an `alist` and accessing the keys and values using `car` and `cdr`.
# Answer
> 3 votes
Welcome to SE Emacs. The `nil` you are seeing is not an extra iteration: it is simply the return value of the `dolist` or `dotimes` function.
# Answer
> 1 votes
The issue come because the print output stream and the eval output stream are the same. If you create a different output stream as the default one, the trouble diseapear.
```
(setq foo '(cat dog rat bar ))
(dolist (ele foo)
(print ele (get-buffer-create "kill-me")))
```
The print is now int the "kill-me" buffer and the nil in the default output.buffer.
---
Tags: print, eval
---
|
thread-28715
|
https://emacs.stackexchange.com/questions/28715
|
Get pandas data-frame as a table in org-babel
|
2016-11-17T12:19:37.600
|
# Question
Title: Get pandas data-frame as a table in org-babel
In the following example, I create a very simple pandas DataFrame and export results verbatim:
```
#+BEGIN_SRC python :exports both :results verbatim :return test
import pandas as pd
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
#+END_SRC
#+RESULTS:
: A B
: 0 1000 60
: 1 1000 100
```
If I try to have the output as a table, things get messed up:
```
#+BEGIN_SRC python :exports both :results value table :return test
import pandas as pd
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
#+END_SRC
#+RESULTS:
| A B |
```
Is there any way to fix this?
Expected output:
```
| | A | B |
| 0 | 1000 | 60 |
| 1 | 1000 | 100 |
```
# Answer
> 8 votes
**Update for people reading this in 2020**
You can now use `tabulate` Python package and write:
```
#+begin_src python :results value raw :return tabulate(df, headers=df.columns, tablefmt='orgtbl')
from tabulate import tabulate
import pandas as pd
df = pd.DataFrame({
"a": [1,2,3],
"b": [4,5,6]
})
#+end_src
#+RESULTS:
| | a | b |
|---+---+---|
| 0 | 1 | 4 |
| 1 | 2 | 5 |
| 2 | 3 | 6 |
```
See the org-mode documentation.
# Answer
> 7 votes
Here is one way to achieve what you want I think. The key is constructing a list that has what you want in it.
```
#+BEGIN_SRC python :exports both :results value table :return test2
import pandas as pd
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
test2 = [list(test)] + [None] + test.values.tolist()
#+END_SRC
#+RESULTS:
| A | B |
|------+-----|
| 1000 | 60 |
| 1000 | 100 |
```
# Answer
> 4 votes
You probably have to convert the dataframe to a type that org knows what to do with. For example, I can get the table contents, but not the column names or the index column like this:
```
#+BEGIN_SRC python :exports both :results table
import pandas as pd
import numpy
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
return test.as_matrix()
#+END_SRC
#+RESULTS:
| 1000 | 60 |
| 1000 | 100 |
```
I didn't see options to as\_matrix that would let you get at the missing elements, but there might be some other such conversion that is more complete.
EDIT: apparently `test.values` is preferred.
EDIT: ... and this *almost* does it (but it might be fragile):
```
#+BEGIN_SRC python :exports both :results table
import pandas as pd
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]})
return [x.split(',') for x in test.to_csv().split('\n')]
#+END_SRC
#+RESULTS:
| | A | B |
| 0 | 1000 | 60 |
| 1 | 1000 | 100 |
| | | |
```
# Answer
> 1 votes
You can fix for the formatting of the Pandas DataFrame so it includes a value in the top left corner by setting the column name:
```
test = pd.DataFrame({'A': [1000, 1000], 'B' : [60, 100]}, columns=list('AB'))
test.columns.name = 'foo'
```
This will then produce you a table:
```
#+RESULTS:
: foo A B
: 0 1000 60
: 1 1000 100
```
However, I still couldn't get Org to display the result correctly. Perhaps you'll have better luck though.
# Answer
> 0 votes
Found this thread whilst trying to work out how to do exactly this and have another solution that leverages the `to_html()` method.
```
#+BEGIN_SRC python :exports results :results html
import pandas as pd
import numpy as np
n = 1000
low = 0
high = 100
df = pd.DataFrame({'x': np.random.random_integers(low, high, size=n),
'y': np.random.random_integers(low, high, size=n)})
summary = df.describe()
return(summary.to_html())
#+END_SRC
#+RESULTS:
#+begin_export html
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>x</th>
<th>y</th>
</tr>
</thead>
<tbody>
<tr>
<th>count</th>
<td>1000.00000</td>
<td>1000.00000</td>
</tr>
<tr>
<th>mean</th>
<td>51.51800</td>
<td>49.76100</td>
</tr>
<tr>
<th>std</th>
<td>29.75643</td>
<td>28.97149</td>
</tr>
<tr>
<th>min</th>
<td>0.00000</td>
<td>0.00000</td>
</tr>
<tr>
<th>25%</th>
<td>26.00000</td>
<td>25.00000</td>
</tr>
<tr>
<th>50%</th>
<td>52.00000</td>
<td>48.00000</td>
</tr>
<tr>
<th>75%</th>
<td>78.00000</td>
<td>76.00000</td>
</tr>
<tr>
<th>max</th>
<td>100.00000</td>
<td>100.00000</td>
</tr>
</tbody>
</table>
#+end_export
```
I'm not sure why you have to `return()` the object, and the table formatting is fairly crude and doesn't match that of org tables but it works (just about!).
I'd be interested to know if there is an org-babel solution to formatting Pandas data frames though as ultimately I'd like to have one org document that I can render as HTML or LaTeX and the above solution would require a second code block for LaTeX and using the `to_latex()` DataFrame method.
---
Tags: org-babel, python
---
|
thread-35052
|
https://emacs.stackexchange.com/questions/35052
|
How to scroll while using multiple cursor?
|
2017-08-22T12:53:20.297
|
# Question
Title: How to scroll while using multiple cursor?
I use a lot multiple cursor and sometimes I have to select some words which are off the screen, in sublime text I do not encounter any problem, I can just scroll and continue selecting words. This, incredibly, seems not possible in emacs! When I scroll the previous cursors get messed up. You can see this behaviour in the gif I have uploaded. This may help: Let Emacs move the cursor off-screen
Sublime Text behaviour:
emacs behaviour:
# Answer
> 3 votes
In Emacs, the points (cursor) is always on the visible portion of the file you are visiting. This coded deep down in the guts of the program, so you won't be able to change this without a great deal of effort.
As a work around, you can use `C-v` and `M-v` to navigate back and forth from one multiple-cursor selection to the next. You can also hide all lines that don't contain a multiple cursor selection with `C-'`. In order for this last keybinding to work, you need to make sure `mc-hide-unmatched-lines-mode` is enabled, ie., put the following in your config:
```
(require 'mc-hide-unmatched-lines-mode)
```
# Answer
> 0 votes
Call the `mc-mark-next-like-this-then-cycle-forward` instead of `mc/mark-next-like-this` to auto scroll along with the selection.
```
(defun mc-mark-next-like-this-then-cycle-forward (arg)
"Mark next like this then cycle forward, take interactive ARG."
(interactive "p")
(call-interactively 'mc/mark-next-like-this)
(call-interactively 'mc/cycle-forward))
(defun mc-skip-to-next-like-this-then-cycle-forward (arg)
"Skip to next like this then cycle forward, take interactive ARG."
(interactive "p")
(call-interactively 'mc/cycle-backward)
(call-interactively 'mc/skip-to-next-like-this)
(call-interactively 'mc/cycle-forward))
(defun mc-mark-previous-like-this-then-cycle-backward (arg)
"Mark previous like this then cycle backward take interactive ARG."
(interactive "p")
(call-interactively 'mc/mark-previous-like-this)
(call-interactively 'mc/cycle-backward))
(defun mc-skip-to-previous-like-this-then-cycle-backward (arg)
"Skip to previous like this then cycle backward take interactive ARG."
(interactive "p")
(call-interactively 'mc/cycle-forward)
(call-interactively 'mc/skip-to-previous-like-this)
(call-interactively 'mc/cycle-backward))
```
---
Tags: scrolling, multiple-cursors
---
|
thread-61816
|
https://emacs.stackexchange.com/questions/61816
|
Adding a caption to an equation in org-mode
|
2020-11-18T23:10:28.707
|
# Question
Title: Adding a caption to an equation in org-mode
I'd like to add a caption to a LaTeX-formatted equation, using org-mode's build-in `#+caption:` directive. The manual says this is possible, but does not specify exactly how to format it. The most intuitive methods do not work; I tried all of the following:
```
#+caption: Kepler's third law
[\ T^2 = \frac{4\pi^2}{G(M_1+M_2)} \]
```
```
#+caption: Kepler's third law
#+latex: \[ T^2 = \frac{4\pi^2}{G(M_1+M_2)} \]
```
```
#+caption: Kepler's third law
\begin{equation}
T^2 = \frac{4\pi^2}{G(M_1+M_2)}
\end{equation}
```
All three of these formattings result in the equation being rendered, but not the caption. I know it is possible to insert captions directly using LaTeX, but I would like to use the org native method, which the manual says I can do. How can I do it?
# Answer
I managed to guess-and-check my way to finding an answer to this!
The trick is to wrap the equation in a figure:
```
#+caption: Kepler's third law
#+begin_figure
\begin{equation}
T^2 = \frac{4\pi^2}{G(M_1+M_2)} R^3
\end{equation}
#+end_figure
```
This applied the caption correctly.
For posterity's sake, if you want to pass position options to the figure using this method, you need to use `:options []` instead of `:placement []`. I have no idea why, though.
> 2 votes
---
Tags: org-mode, org-export, latex
---
|
thread-61815
|
https://emacs.stackexchange.com/questions/61815
|
Can I read a macOS Extended Journaled Encrypted USB flash using Emacs 27 Dired?
|
2020-11-18T17:36:28.633
|
# Question
Title: Can I read a macOS Extended Journaled Encrypted USB flash using Emacs 27 Dired?
Is there a way to browse a flash USB drive formatted in `Mac OS Extended (Journaled, Encrypted)` using Emacs 27 Dired?
After I `Enter a password to unlock the disk “XYZ”.` I can browse the folders and the files just fine using Finder, but I prefer to operate with Emacs rather than Finder.
When I try to look (through Emacs `Dired-mode`) at the Volume, I get `Listing directory failed but ‘access-file’ worked`.
I am the owner of the volume:
```
drwxrwxr-x 7 calaf staff 306 Nov 18 12:14 XYZ
```
and so this does not seem to be a case of `dr-xr-xr-x` permissions (where the files are readable if their names and paths are, but a directory listing isn't).
**Edit**
This appears to be not related to the disk formatting, but to whether a folder is backed up to iCloud.
It also appears to be related to a recent upgrade to Catalina, rather than to Emacs 27 (or, for that matter, to using `sudo port install gnupg2` rather than `port install gnupg` for Emacs `ps-ccrypt`). But I don't have either Desktop or Documents connected to iCloud, and yet the same issue arises with both.
Can you clarify what this is all about?
# Answer
What if you give Emacs full disk access in System Preferences → Security & Privacy → Files and Folders—*if* Emacs is listed there. Apparently no one can add applications to this list, the +/- buttons are greyed out for everyone?
If Emacs is not listed there, you could try navigating to, for example, `~/Downloads` in dired and see if macOS prompts you to allow access.
Failing that, or if you want Emacs to have access to everything, you can try granting Emacs "Full Disk Access" there in Security & Privacy.
> 0 votes
---
Tags: dired, osx, encryption
---
|
thread-61823
|
https://emacs.stackexchange.com/questions/61823
|
Can't make emacs compile with locally installed harfbuzz
|
2020-11-19T11:53:31.347
|
# Question
Title: Can't make emacs compile with locally installed harfbuzz
Whenever I start the ./configure script for emacs at the end of it I get the following message:
```
configure: WARNING: This configuration uses the Cairo graphics library,
but not the HarfBuzz font shaping library (minimum version 0.9.42).
We recommend the use of HarfBuzz when using Cairo, please install
appropriate HarfBuzz development packages.
```
I compiled and installed harfbuzz 2.7.2 in my ~/opt/harfbuzz-2.7.2 directory. In my .profile I put:
```
export CPPFLAGS="-I/home/myuser/opt/harfbuzz-2.7.2/include/ $CPPFLAGS"
export LDFLAGS="-L/home/myuser/opt/harfbuzz-2.7.2/lib/ $LDFLAGS"
```
But emacs configure doesn't pick it up. I guess it only finds my system harfbuzz-dev (debian 8, not recent enough).
What do I need to do to make configure understand where harfbuzz is? Do I need to recompile Cairo?
# Answer
Emacs' configure uses `pkg-config` to search for HarfBuzz, so you need to ensure that your `PKG_CONFIG_PATH` points at the pkconfig directory for your new installation of HarfBuzz (this is true for a lot of other packages that Emacs tries to use)
> 2 votes
---
Tags: compile
---
|
thread-61819
|
https://emacs.stackexchange.com/questions/61819
|
How can I bind `C-c C-j` to always do `org-journal-new-entry`?
|
2020-11-19T08:24:10.977
|
# Question
Title: How can I bind `C-c C-j` to always do `org-journal-new-entry`?
I did:
```
(use-package org-journal
:ensure t
:defer t
:config
(setq org-journal-dir "~/org/journal/"
org-journal-date-format "%A, %d %B %Y"
org-journal-time-format "%I:%M %p"))
(global-set-key (kbd "C-c C-j") 'org-journal-new-entry)
```
in my `init.el` file. However, `C-c C-j` seems to be bound to `org-goto` instead of `C-c C-j` for some reason. Why is this?
I got this idea from: `(global-set-key (kbd "C-c C-r") 'ivy-resume)` suggested in the Ivy docs and wanted to have a similar global shortcut to get into Org Journal. What is the best way to do this?u
# Answer
> 0 votes
You can use `use-package` to force your keybinding.
```
(use-package org-journal
:ensure t
:defer t
:config
(setq org-journal-dir "~/org/journal/"
org-journal-date-format "%A, %d %B %Y"
org-journal-time-format "%I:%M %p")
:bind* ("C-c C-j" . org-journal-new-entry))
```
---
Tags: org-mode, key-bindings, org-journal
---
|
thread-61825
|
https://emacs.stackexchange.com/questions/61825
|
Assoc in a nested alist
|
2020-11-19T14:42:42.940
|
# Question
Title: Assoc in a nested alist
I have the following nested alist:
```
(setq x '(foo . ((bar . ((chocolate . "edible") (gold . "inedible")))
(jar . "glass"))))
```
How can get entry `(chocolate . "edible")`?
I read this question & and this
But unlike q1, I don't know the "path" to the value, and unlike, q2, I would like an Elisp implementation. Also, I have a larger a list which can have a "depth" of 2 - 5 (by depth I mean alists in alists)
So far this is what I was able to cook up:
```
(defun assoc-recur (key list)
(if (listp (cdr list))
(assoc key (cdr list))
(assoc-reccur key (cdr list))))
```
It's obvious that this code only works as long as the value is isn't a list of alists like `(bar . ((..))`
How can can I access a value in a nested alist with vanilla Elisp (without CL emulation)? Or should I give up and install the CL api and try q2?
The syntax I am looking for is something like `(func key list)`
**ps:** I am quite new to Emacs so I am probably missing out on a convenient function.
# Answer
> 4 votes
> I have the following nested alist:
The example does not show a real alist, because its first element, `foo`, is not a cons cell. I'd personally call it a tree. Functions like `assoc-string` may handle this, others may ignore such elements, but in general alist functions expect every element to be a cons with a car and a cdr. See `(info "(elisp) Lists")` and its subnodes.
> So far this is what I was able to cook up:
Elisp doesn't handle recursion very efficiently, so I'd recommend avoiding it in general, if possible. You may otherwise hit `max-specpdl-size` limits.
> unlike q1, I don't know the "path" to the value
> Also, I have a larger a list which can have a "depth" of 2 - 5 (by depth I mean alists in alists)
Given the irregularity of this data structure, I'd recommend flattening the list first before looking things up in it. This should greatly simplify the code's complexity at the cost of some time and space. In Emacs 27:
```
(setq x '(foo
(bar (chocolate . "edible")
(gold . "inedible"))
(jar . "glass")))
(cadr (memq 'chocolate (flatten-tree x))) ; => "edible"
```
Here's the current implementation of `flatten-tree`, in case you're on an older version of Emacs:
```
(defun flatten-tree (tree)
"Return a \"flattened\" copy of TREE.
In other words, return a list of the non-nil terminal nodes, or
leaves, of the tree of cons cells rooted at TREE. Leaves in the
returned list are in the same order as in TREE.
\(flatten-tree \\='(1 (2 . 3) nil (4 5 (6)) 7))
=> (1 2 3 4 5 6 7)"
(let (elems)
(while (consp tree)
(let ((elem (pop tree)))
(while (consp elem)
(push (cdr elem) tree)
(setq elem (car elem)))
(if elem (push elem elems))))
(if tree (push tree elems))
(nreverse elems)))
```
Alternatively, you could perform an iterative depth-first tree search. It trades Elisp's recursion issues for more complex code. Here's an example of DFS on a HTML DOM taken from https://github.com/abo-abo/swiper/pull/1593#issuecomment-392587760 :
```
(defun counsel--firefox-bookmarks-libxml ()
"Parse current buffer contents as Firefox HTML bookmarks.
Return list of propertized string candidates for
`counsel-firefox-bookmarks'.
Note: This function requires libxml2 support."
;; Perform iterative pre-order depth-first search instead of using
;; `dom.el' because the latter is new to Emacs 25 and uses recursion.
(let ((stack (cddr (libxml-parse-html-region (point-min) (point-max))))
cands)
(while (let ((node (pop stack)))
(if (eq (car-safe node) 'a)
(let* ((text (cl-caddr node))
(attrs (cadr node))
(href (cdr (assq 'href attrs)))
(tags (cdr (assq 'tags attrs))))
(unless (zerop (length href))
(push (counsel--firefox-bookmarks-cand href text tags)
cands)))
(dolist (child (nreverse (cddr node)))
(when (consp child)
(push child stack))))
stack))
cands))
```
In your case the `while` loop would additionally terminate on location of the desired key.
Alternatively, I'd recommend structuring your data such that it is more regular. ;)
# Answer
> 1 votes
You can use the builtin macro `let-alist` to access value from nested alist, e.g.,
```
(let-alist
'((foo . ((bar . ((chocolate . "edible") (gold . "inedible")))
(jar . "glass"))))
.foo.bar.chocolate)
;; => "edible"
```
And your `x` is not an alist, alist is a list of key-value pairs, i.e., `((key1 . val1) (key2 . val2) ...)`.
---
Tags: list, association-lists
---
|
thread-61835
|
https://emacs.stackexchange.com/questions/61835
|
How to bind a keybinding to add `\textit` or `textbf` for the word, where the cursor is pointing?
|
2020-11-19T20:50:42.897
|
# Question
Title: How to bind a keybinding to add `\textit` or `textbf` for the word, where the cursor is pointing?
I am working on a `LaTex` file.
Is it possible to bind a keybinding to add `\textit` or `textbf` for the word, where the cursor is pointing?
For example, cursor is on top of word `hello`:
* `hello` converted into `\textit{hello}` \# with `M-o i`
* `hello` converted into `\textbf{hello}` \# with `M-o b`
# Answer
> 1 votes
You can create commands to achieve the job you want and link them to the key you like.
```
(defun italic-word ()
"your comment"
(interactive)
(easy-mark) (TeX-font nil 9))
(defun bold-word ()
"your comment"
(interactive)
(easy-mark) (TeX-font nil 2))
(bind-key (kbd "M-o i") #'italic-word LaTeX-mode-map)
(bind-key (kbd "M-o b") #'bold-word LaTeX-mode-map)
```
"M-o i" and "M-o b" are already bind. It is not a good idea to use them.
the function easy-mark come with the easy-kill package on elpa. Probably you need to install it.
*edit :* I don't really like this code that operates on the mark. I think easy-mark should be for interactive use only. So I suggest you replace with this more robust code:
```
(defun italic-word ()
"your comment"
(interactive)
(save-excursion
(beginning-of-thing 'word)
(insert "\\textit{")
(end-of-thing 'word)
(insert "}")))
(defun bold-word ()
"your comment"
(interactive)
(save-excursion
(beginning-of-thing 'word)
(insert "\\textbf{")
(end-of-thing 'word)
(insert "}")))
```
---
Tags: key-bindings, latex
---
|
thread-61827
|
https://emacs.stackexchange.com/questions/61827
|
Is it possible to export an org table into an interactive table?
|
2020-11-19T15:05:18.110
|
# Question
Title: Is it possible to export an org table into an interactive table?
Org-mode can nicely export tables into html customly. However, these exported tables cannot be sorted or filtered (i.e. are not interactive). Would it be possible to make these tables sortable and filterable?
# Answer
The standard HTML table is not interactive, you need JavaScript to add these interactive features.
The following uses the DataTables JS library to add search and filter. Save it to an org file then `C-c C-e h o` to view the HTML in browser.
```
#+HTML_HEAD: <link rel="stylesheet" href="https://cdn.datatables.net/1.10.22/css/jquery.dataTables.min.css">
#+NAME: several emacs packages
| Name | Version | Status | Source | Summary |
|--------------------+---------------+-----------+--------+------------------------------------------------|
| origami | 20200331.1019 | available | melpa | Flexible text folding |
| number | 20170901.1312 | available | melpa | Working with numbers at point. |
| helm-lib-babel | 20180510.1324 | available | melpa | helm insertion of babel function references |
| org-snooze | 20181229.1424 | available | melpa | Snooze your code, doc and feed |
| assess | 20200211.1817 | installed | n/a | Test support functions |
| mocker | 20150917.154 | available | melpa | mocking framework for emacs |
| mediawiki | 20200718.1529 | installed | n/a | mediawiki frontend |
| unicode-math-input | 20190813.1436 | available | melpa | Insert Unicode math symbols using TeX notation |
| hgrc-mode | 20150409.2043 | available | melpa | major mode for editing hgrc files |
| abs-mode | 20201021.958 | available | melpa | Major mode for the modeling language Abs |
#+begin_export html
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
<script> $("table").DataTable(); </script>
#+end_export
```
You need basic HTML and JS knowledge to know how to use the library.
1. the link tag is to load CSS, and the first two script tags are to load JS.
2. `$("table")` is a JS function call which selects all HTML tables, and `.DataTable()` is to initialize Datatable.
Customization is performed by defining options in the `$().DataTable()` constructor - for example, in the following code the `pageLength` and `order` options are used to show 18 rows per page and the default sorting to have the 2d column sorted in ascending order.
```
$('table').DataTable({
"pageLength": 18,
"order": [1,'asc']
});
```
Full range of options is documented here.
> 7 votes
# Answer
Here's a proof of concept, along the lines described in the comments. There are several things that need to be done to it in order to turn it into a "real" solution, which I will describe at the end of the answer. In particular, it is **NOT** a complete solution: it's missing the part where Org mode produces the HTML that is needed for this functionality. Instead, this last part requires manual tweaking of the HTML - for now.
Here's the Org mode file I used:
```
#+HTML_HEAD: <script src="./foo.js"></script>
* foo
#+name: myTable
| name | city | state |
|-------+---------------+----------------|
| Alice | Boston | Massachussetts |
| Bob | San Francisco | California |
| Ted | Chicago | Illinois |
| Carol | New York | New York |
```
There are two things of note here that I will explain in the rest of the post:
* the `#+HTML_HEAD:` line
* the `#+name:` line
---
If you start with just the table and none of the extra stuff and you export to HTML, you will find the following HTML in the output file (with most of it elided to save space):
```
...
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-left" />
<col class="org-left" />
<col class="org-left" />
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">name</th>
<th scope="col" class="org-left">city</th>
<th scope="col" class="org-left">state</th>
</tr>
</thead>
<tbody>
...
</tbody>
</table>
```
The first problem here is that in order to manipulate the table you need to be able to get a handle on it. The Document Object Model (DOM) specifies these things and you'll need to learn a bit about it in order to understand JS code that manipulates elements (e.g. tables), but it's beyond what I can cover here. Suffice it to say that the table should have an `id` property which will allow a JS program to get a handle on it.
We can get an id tacked on if we name the table: that's what the `#+name:` line does. If you add that line to the file and export again, you will see that the `<table ...>` tag has changed:
```
<table id="org994c1a3" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
```
We get an `id` but it's something that Org mode produces and there is no easy way to predict what it is going to be. We need the id to be something well-known that we can use in other contexts, e.g. the name we gave to the table: `myTable`. Fortunately, there is an option for that: `org-html-prefer-user-labels` which, if set to `t`, produces an id with the actual value of the `#+name:` keyword. You can customize the variable - or you can set it in your init file:
```
(eval-after-load "ox-html" (setq org-html-prefer-user-labels t))
```
Restart your emacs and check the value with `C-h v org-html-prefer-user-labels` to make sure it is set.
If you now export again, the `<table ...>` line looks like this:
```
<table id="myTable" border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
```
and we can get to the the table using the id `myTable`.
---
Now for the `#+HTML_HEAD:` line which addresses the second problem: providing a JS file containing the sorting function to be used for sorting the table by column.
The `#+HTML_HEAD:` keyword adds its value literally into the HTML file's header, so when the HTML file is transferred from the server to the browser, the `<script src="./foo.js></script>` line will be part of it. When the browser parses the file it will download the file `foo.js` from the same directory as the HTML file and have its JS engine compile it and remember the function(s) defined in it.
In this case, `foo.js` contains a single function, `sortTable`, cribbed from the How to sort a table link I mentioned in a comment. I just cut-and-pasted the definition of it into a local file `foo.js`: it's the one from the `Sort Table by Clicking the Headers` section of that link.
The `sortTable` function takes a single argument, the column number n, and sorts the table by that column, alternating ascending and descending order on every click. It needs to know which table it applies to and if you look at the function, it hardwires the name in its implementation (I changed it from their `myTable2` to `myTable` to match the name of the table above).
---
Finally, here comes the manual tweaking that is required to tie the clicks on the table header with the sorting function. In the exported HTML file, find the part that looks like this:
```
<th scope="col" class="org-left">name</th>
<th scope="col" class="org-left">city</th>
<th scope="col" class="org-left">state</th>
```
and modify it to look like this:
```
<th onclick="sortTable(0)" scope="col" class="org-left">name</th>
<th onclick="sortTable(1)" scope="col" class="org-left">city</th>
<th onclick="sortTable(2)" scope="col" class="org-left">state</th>
```
Save the file and then visit it in the browser, using a `file:///..../foo.html` URL. Or you can copy the HTML file **AND** the JS file to some place on the server and use an `http://.../foo.html` URL. Then click on each column of the table header and watch it sort.
---
OK, this is a proof-of-concept, so manual tweaking of the output is allowed :-), but in general you will want that to happen automatically. I hope the exercise above is useful, so you can understand *what* you need to do.
There is one change that is easy to make: modify the `sortTable` function to take the id of the table as an argument, so that the name of the table is not hardwired into the function. Instead, you specify the table when you set the `onclick` handler:
```
<th onclick="sortTable(0, 'myTable')" scope="col" class="org-left">name</th>
```
That way, you can use the same function for any table.
The final piece needed is to have Org mode produce the `<th onclick=...>` tags without you having to manually add them. That can be done by using a filter to postprocess the HTML output, but if I had to do it, I think I would it with a derived exporter: start with the HTML exporter and then modify the `org-html-table` function to add the `onclick` property appropriately. For now, that's left as an exercise for the interested reader.
> 1 votes
---
Tags: org-mode, org-export, org-table, exporting
---
|
thread-53863
|
https://emacs.stackexchange.com/questions/53863
|
Encrypt excerpts in org file (passwords only)
|
2019-11-19T17:07:17.127
|
# Question
Title: Encrypt excerpts in org file (passwords only)
I keep project info in `.org` file together with passwords.
*When I share a screen it is annoying to show passwords in a buffer accidentally.*
I want to keep `.org` file in plain text format but mark some parts to be obfuscated or hidden or encrypted:
```
This is a normal text.
user: me
password: MAGIC{XXXX}
```
I want to be able to copy content marked as MAGIC as a plain text without a prompt for the decryption master password.
**UPDATE** I saw http://doc.norang.ca/org-mode.html#HandlingEncryption It encrypts entire section of org file and displays it in plain when prompted.
Displaying of passwords is dangerous. I want to hide them visually and without any manual instructions.
# Answer
Partial solution that hides passwords, but does not enctrypt:
```
(defvar mypasshide-prefix-re "^pass: *")
(defun mypasshide--toggle-display (overlay hide)
"Hide or reveal region. Signature follows convention for
`reveal-toggle-invisible' from `reveal' mode."
(if hide
(overlay-put overlay 'display (propertize "****" 'face 'warning))
(overlay-put overlay 'display nil)))
(defun mypasshide--hide ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward mypasshide-prefix-re nil t)
(let* ((beg (match-end 0))
(end (line-end-position))
(overlay (make-overlay beg end)))
(mypasshide--toggle-display overlay t)
(overlay-put overlay 'reveal-toggle-invisible #'mypasshide--toggle-display)
))))
(define-minor-mode mypasshide-mode
"Hide passwords after `mypasshide-prefix-re' and activate
`reveal-mode'. Disabling is not implemented."
:group 'reveal
(if mypasshide-mode
(progn
(mypasshide--hide)
(reveal-mode))))
(provide 'mypasshide)
```
I activated it as `(add-hook 'org-mode-hook #'mypasshide-mode)`.
> 1 votes
---
Tags: org-mode, copy-paste, passwords
---
|
thread-61099
|
https://emacs.stackexchange.com/questions/61099
|
spacemacs: How can I disable flymake and flycheck completely, to speed up performance
|
2020-10-10T03:51:07.207
|
# Question
Title: spacemacs: How can I disable flymake and flycheck completely, to speed up performance
I’m using `spacemacs`. I just installed `syntax-highlighting` layer and `auto-completion` layer, and now my emacs got really really slow.
So slow that going back to PyCharm (IntelliJ) with R-plugin feels waaay better again. initially, emacs had felt better with more freedom, after having slugged through IntelliJ for a few weeks.
The issue is that after installing: polymode, flycheck, autocompletion, poly-r, just to get rmarkdown support, the entire emacs for ESS (R) just feels like a complete slug. Like, 0.5X performance of IntelliJ (on a good day).
I am wondering if any tips on how to disable completely, FlyCheck and FlyMake? I used `SPC t s` to toggle off FlyCheck, that helped a bit, but FlyMake still is slugging it in the background and highlighting my lines of code.
I really appreciate someone kindly developing a nice lintr for Emacs, but it really slows me down more than just eye-balling the code myself, at this point, in Emacs.
# Answer
> 0 votes
Try to using command SPC SPC then search for FlyMake Mode and select it. Selecting it will toggle the mode on or off. Spacemacs makes finding commands simple by filtering down the list of commands as you type it in. For example, do SPC SPC then type fly. It will filter all commands that have "fly" in it's name. You might need to do this time to time for commands that you do not know the exact name for.
SPC SPC is equivalent to the M-x command in plain emacs editor. You can execute any command you want in your emacs environment here. All modes will have a command to toggle them and ussually with it has word "mode" in the command. Spacemacs will also list key bindings to the commands here. If FlyMake Mode Command has a keybinding you will know what to type to execute it next time.
---
Tags: spacemacs, flycheck, ess, flymake
---
|
thread-61846
|
https://emacs.stackexchange.com/questions/61846
|
How to use ivy to select email attachments with mu4e
|
2020-11-21T02:24:09.557
|
# Question
Title: How to use ivy to select email attachments with mu4e
I use the mu4e package to read my emails. However, I also use the ivy completion framework, which includes file completion.
Using both packages together is a bit of a problem though. `mu4e` uses its own file-completion dialog. That's probably fine, but it's different enough that it confuses me when I try to attach files to outgoing messages.
Is there a way to use ivy's completion features for selecting files in `mu4e`?
# Answer
> 0 votes
It appears that `mu4e` uses its own file selection function, which is hard-coded. Which means you have to rewrite the functions in question after loading `mu4e`. The following code accomplishes this for adding attachments to outgoing files:
```
(eval-after-load 'mu4e-compose
'(defun tws-attach-file (file &optional type description disposition)
"Attach a file to the outgoing MIME message.
The file is not inserted or encoded until you send the message with
`\\[message-send-and-exit]' or `\\[message-send]' in Message mode,
or `\\[mail-send-and-exit]' or `\\[mail-send]' in Mail mode.
FILE is the name of the file to attach. TYPE is its
content-type, a string of the form \"type/subtype\". DESCRIPTION
is a one-line description of the attachment. The DISPOSITION
specifies how the attachment is intended to be displayed. It can
be either \"inline\" (displayed automatically within the message
body) or \"attachment\" (separate from the body).
If given a prefix interactively, no prompting will be done for
the TYPE, DESCRIPTION or DISPOSITION values. Instead defaults
will be computed and used."
(interactive
;;; Change added here:
(let* ((file (ivy-read "Attach file: " #'read-file-name-internal))
;;; End of altered code
(type (if current-prefix-arg
(or (mm-default-file-encoding file)
"application/octet-stream")
(mml-minibuffer-read-type file)))
(description (if current-prefix-arg
nil
(mml-minibuffer-read-description)))
(disposition (if current-prefix-arg
(mml-content-disposition type file)
(mml-minibuffer-read-disposition type nil file))))
(list file type description disposition)))
;; If in the message header, attach at the end and leave point unchanged.
(let ((head (unless (message-in-body-p) (point))))
(if head (goto-char (point-max)))
(mml-insert-empty-tag 'part
'type type
;; icicles redefines read-file-name and returns a
;; string w/ text properties :-/
'filename (substring-no-properties file)
'disposition (or disposition "attachment")
'description description)
;; When using Mail mode, make sure it does the mime encoding
;; when you send the message.
(or (eq mail-user-agent 'message-user-agent)
(setq mail-encode-mml t))
(when head
(unless (pos-visible-in-window-p)
(message "The file \"%s\" has been attached at the end of the message"
(file-name-nondirectory file)))
(goto-char head)))))
(define-key mu4e-compose-mode-map (kbd "C-c C-a") 'tws-attach-file)
```
Similarly, for selecting the directory in which to save attachments from incoming emails:
```
(eval-after-load 'mu4e-view
'(defun mu4e~view-request-attachments-dir (path)
"Ask the user where to save multiple attachments (default is PATH)."
(let ((fpath (expand-file-name
(counsel-read-directory-name
(mu4e-format "Save in directory ")
path) path)))
(if (file-directory-p fpath)
fpath))))
```
---
Tags: mu4e, email, ivy, counsel, swiper
---
|
thread-61850
|
https://emacs.stackexchange.com/questions/61850
|
How to resize images when exporting to Markdown format?
|
2020-11-21T10:12:17.050
|
# Question
Title: How to resize images when exporting to Markdown format?
Is there an equivalent of `#+attr_html: :width 500px` for Markdown format ?
# Answer
The markdown exporter doesn't appear to export image sizes defined by `#+attr_html:` or `#+attr_org:` (the `ox-gfm` exporter doesn't either)
so, you could either include raw html in the org file, which does get exported...
`#+html: <img src="img/test.png" width="600px">`
or if you have pandoc installed, you can use it as an external process to convert from org to markdown. The conversion will include image properties defined in the `#+attr_org:` lines...
`pandoc -i test.org -o test.md`
> 2 votes
---
Tags: org-mode, org-export, markdown, exporting
---
|
thread-61852
|
https://emacs.stackexchange.com/questions/61852
|
How to open a file which looks like unicode in emacs
|
2020-11-21T11:10:05.393
|
# Question
Title: How to open a file which looks like unicode in emacs
I have a file in my C: drive on Windows named MSDELog.log and from opening the file with a hex editor I can see that there is a null character after each character. But there is no indicator at the start of the file saying unicode or whatever the encoding is.
If I open this file with the Windows notepad it seems to recognise it and opens correctly.
If I open the file in emacs I see the text but every other character is ^@ - I realise this indicates a null character.
If I hit m-x revert-buffer-with-coding-system and try utf-8 there is no change in the view. If I select utf-16 then I see a load of what looks like Chinese characters.
How do I view this file in emacs?
# Answer
> 6 votes
It's a file encoded in utf-16 little endian format without the byte order mark. You have to specify the endianness selecting utf-16-le when you use `revert-buffer-with-coding-system`
---
Tags: character-encoding, unicode
---
|
thread-61849
|
https://emacs.stackexchange.com/questions/61849
|
Org files take a few seconds longer to open that text files do in Emacs on Windows
|
2020-11-21T10:07:53.393
|
# Question
Title: Org files take a few seconds longer to open that text files do in Emacs on Windows
I tend to prefer working with `org` files in Emacs. However, I have noticed that at least on Windows 10, Emacs (version 27.1) takes a few seconds longer to open an `org` file for the first time that it does opening a `txt` file, in which case it is almost instantaneous. I was wanting to know why this is the case and also if there was a way to have `org` files open as quickly.
Here is the profiler report:
```
- command-execute 72 85%
- call-interactively 72 85%
- funcall-interactively 70 83%
- dired-find-file 70 83%
- find-file 70 83%
- find-file-noselect 70 83%
- find-file-noselect-1 70 83%
- after-find-file 69 82%
- normal-mode 69 82%
- set-auto-mode 69 82%
- set-auto-mode-0 69 82%
- org-mode 69 82%
- org-load-modules-maybe 42 50%
- require 38 45%
- byte-code 38 45%
- require 35 41%
- byte-code 33 39%
- require 29 34%
- byte-code 28 33%
- require 22 26%
- byte-code 21 25%
- require 17 20%
- byte-code 14 16%
- require 12 14%
- byte-code 12 14%
- require 5 5%
- byte-code 5 5%
- require 1 1%
byte-code 1 1%
- custom-declare-face 1 1%
- face-spec-set 1 1%
- face-spec-recalc 1 1%
- make-face-x-resource-internal 1 1%
- set-face-attributes-from-resources 1 1%
set-face-attribute-from-resource 1 1%
- custom-declare-face 1 1%
- face-spec-set 1 1%
- make-empty-face 1 1%
- make-face 1 1%
- make-face-x-resource-internal 1 1%
- set-face-attributes-from-resources 1 1%
set-face-attribute-from-resource 1 1%
- custom-declare-variable 1 1%
- custom-initialize-reset 1 1%
- eval 1 1%
- funcall 1 1%
+ #<compiled 0x26a2271> 1 1%
- byte-code 21 25%
- require 14 16%
- byte-code 10 11%
- custom-declare-face 3 3%
- face-spec-set 3 3%
- face-spec-recalc 3 3%
- make-face-x-resource-internal 3 3%
- set-face-attributes-from-resources 3 3%
+ set-face-attribute-from-resource 3 3%
- require 2 2%
- byte-code 2 2%
- require 2 2%
byte-code 1 1%
- custom-declare-variable 1 1%
- custom-initialize-reset 1 1%
- eval 1 1%
- funcall 1 1%
+ #<compiled 0x2190c65> 1 1%
- org-macro-initialize-templates 3 3%
- require 3 3%
- byte-code 2 2%
require 1 1%
- defconst 1 1%
- org-version 1 1%
- locate-library 1 1%
locate-file 1 1%
- normal-backup-enable-predicate 1 1%
file-truename 1 1%
- byte-code 2 2%
- read-extended-command 2 2%
- completing-read 2 2%
- completing-read-default 2 2%
- read-from-minibuffer 2 2%
- redisplay_internal (C function) 1 1%
- #<compiled 0x10be1df> 1 1%
apply 1 1%
- ... 12 14%
Automatic GC 12 14%
```
# Answer
Your question provides not enough information to be really sure, but:
> takes a few seconds longer to open an org file **for the first time**
This sounds like org is lazy loaded right in the moment you open an org-file for the first time.
This is easily achieved, by configuring `org` with `use-package` or a startet kit like `Doom`.
To verify if it is lazy loading, which kicks in, eval `M-: (require 'org) <RET>`, then load a org file for the first time. If loading is faster, then lazy loading is the culprit. Lazy loading is a good thing, btw.
> 2 votes
---
Tags: org-mode
---
|
thread-61841
|
https://emacs.stackexchange.com/questions/61841
|
How to look for all active stamps in Agenda?
|
2020-11-20T08:25:44.280
|
# Question
Title: How to look for all active stamps in Agenda?
Sometimes I do not use SCHEDULE or DEADLINE, but a simple active date stamp.
With SCHEDULED items, they always show as pending, but not with active date stamps, as they are left behind if you don't mark them as DONE.
How could I retrieve all these "left behind" active stamped tasks? Thank you.
# Answer
Assuming you have the Org agenda dispatcher on `C-c a`, then `C-c a m TIMESTAMP<="<now>" RET` should show you all the left-behind timestamps, although I'm not sure it distinguishes actives from inactives. See Matching tags and properties and Special Properties.
EDIT: The above finds active timestamps only. Finding both active and inactive timestamps is just a matter of OR'ing the searches:
```
C-c a m TIMESTAMP<="<now>"|TIMESTAMP_IA<="<now>"
```
> 1 votes
---
Tags: org-agenda
---
|
thread-61782
|
https://emacs.stackexchange.com/questions/61782
|
How can I tell counsel's `counsel-git` to ignore certain file endings and folders
|
2020-11-16T22:13:09.100
|
# Question
Title: How can I tell counsel's `counsel-git` to ignore certain file endings and folders
I am using `counsel-git` to find and open files.
Is there any way to ignore folders and files that are ending with specific pattern.
For example: ignore folders named: `.idea` ; and files ended with `*.save` and `*.xml` or specific as `-i` or `.gitignore`. All the folders starting with `.` always show up on top; I just want to ignore some of them which I do not use.
---
config file:
```
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(global-set-key (kbd "C-c g") 'counsel-git)
```
# Answer
> 1 votes
`counsel-git` is calling `counsel-git-cands` to build the list of files.
`counsel-git-cands` is running the shell command, which is stored in variable `counsel-git-cmd`, which has the value `"git ls-files -z --full-name --"`.
So you have two different options:
1. modify the result of function `counsel-git-cands` to remove files from the list, you do not want. i.e. add an advice, which filters the results: `(advice-add 'counsel-git-cands :filter-return #'my-filter-counsel-git-cands)`. Read more about advicing at the elisp manual.
2. change the shell command line `git ls-files....` to sort out files you do not want. i.e. by using the command line option `--exclude`. You need to experiment with `git ls-files` a bit with that here. Read man page of `git-ls-files (1)`.
---
Tags: counsel
---
|
thread-61862
|
https://emacs.stackexchange.com/questions/61862
|
How to prevent emacs from converting short form quote ( ' ) to literal "quote" in custom set variables, etc?
|
2020-11-21T20:14:02.407
|
# Question
Title: How to prevent emacs from converting short form quote ( ' ) to literal "quote" in custom set variables, etc?
I usually use Emacs 27.1, but on a particular remote machine, it has Emacs 26.3 installed instead. After cloning my dotfiles repository onto this remote machine, all of the "custom set variables" that Emacs automatically sets for me in `init.el` have the literal word "quote" instead of the quote symbol ( ' ) that I have on my usual machine.
This is leading to git thinking that my `init.el` files have been modified when they really haven't changed. What is a good fix for this? Would shifting these custom set variables to another location help, or can I suppress this changing of quote symbol to the literal word "quote"?
Before
```
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default))
'(org-agenda-custom-commands
'(("n" "Agenda and all TODOs"
......
```
After:
```
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
(quote
("7451f243a18b4b37cabfec57facc01bd1fe28b00e101e488c61e1eed913d9db9" default)))
'(org-agenda-custom-commands
(quote
(("n" "Agenda and all TODOs"
......
```
# Answer
> 1 votes
You can't stop Emacs 26 from writing the custom file in this format, unless you patch Emacs 26 with the same changes which were made to Emacs 27 to make it start using the more concise syntax.
You could certainly tell your config to use a different `custom-file` when `emacs-major-version` is \< 27.
Or if you didn't particularly care about changes made to that file in the Emacs 26 instance, you could make git ignore it entirely with
```
git update-index --assume-unchanged custom.el
```
(or whatever the filename is)
Git would ignore it in that working copy until such time as you manually repeat that command with `--no-assume-unchanged`
# Answer
> 0 votes
@phils answered this.
If you really want to fiddle with this for Emacs prior to Emacs 27, you can advise the Customize functions that save settings (`custom-save-all`, `custom-save-variables`, `custom-save-faces`), by let-binding **`print-quoted`** to `t` around their bodies.
---
Tags: init-file
---
|
thread-61855
|
https://emacs.stackexchange.com/questions/61855
|
Animate text in an emacs buffer
|
2020-11-21T14:44:38.523
|
# Question
Title: Animate text in an emacs buffer
For educational purposes I wish to replay the characters that I enter in the buffer at some slow typing speed. Selecting the regions I could do this in would also be great.
Is there any emacs package that provides such a feature?
# Answer
This will get you part way there:
```
(defun pause () (sleep-for 0.7))
(define-minor-mode slowdown-mode "..." nil nil nil
(if slowdown-mode
(add-hook 'post-command-hook #'pause)
(remove-hook 'post-command-hook #'pause)))
```
This doesn't "replay", and you can't apply it to a region. But it does show you how to slow things down.
`M-x slowdown-mode` to turn it on/off.
Change the `0.7` to whatever pause length you like.
> 1 votes
---
Tags: animate
---
|
thread-61858
|
https://emacs.stackexchange.com/questions/61858
|
wrap each line with a function and collect each value outputs from an org src block
|
2020-11-21T16:41:41.160
|
# Question
Title: wrap each line with a function and collect each value outputs from an org src block
How do I wrap each line with a function and collect all value outputs from an org src block and collect all value outputs from an org src block?
For example,
If I have
```
#+begin_src python
3492-134.2
3492-134.2+1428
#+end_src
```
I would like
```
#+RESULTS:
: 3357.8
: 4785.8
```
Not
```
#+RESULTS:
: 4785.8
```
According to https://orgmode.org/manual/Results-of-Evaluation.html, adding `:results output` to the header will collect every output to the standard stream. But that would require me to add a print statement to each line manually.
# Answer
> 1 votes
Would changing the input to a table work? Something like this:
```
#+name: foo
| 3492-134.2 |
| 3492-134.2+1428 |
#+begin_src python :var tbl=foo :results output
for row in tbl:
print(eval(row[0]))
#+end_src
#+RESULTS:
: 3357.8
: 4785.8
```
I think that's about the simplest you can do. You can add entries to the table, but the source block does not need to change.
---
Tags: org-babel
---
|
thread-61853
|
https://emacs.stackexchange.com/questions/61853
|
How can I make sure that Emacs opens files with extension `*.rec` as normal text files?
|
2020-11-21T14:05:30.953
|
# Question
Title: How can I make sure that Emacs opens files with extension `*.rec` as normal text files?
How can I make sure that Emacs opens files with extension `*.rec` as normal text files?
When I try to open a file with the extnsion `*.rec`, I get the error message `Running someFile.rec...done` without the file being opened.
I assume that `rec-mode` is not installed because its status is `Available from gnu` (see below).
What can I do in order for Emacs to open `*.rec` files as plain, normal text files?
# Answer
> 2 votes
To tell Emacs that `*.rec` files should be opened in `text-mode`:
```
(add-to-list 'auto-mode-alist '("\\.rec\\'" . text-mode))
```
# Answer
> 1 votes
Use `M-x find-file-literally` Emacs will use `fundamental-mode` as the major mode. Then change to txt mode.
---
Tags: find-file, auto-mode-alist
---
|
thread-59437
|
https://emacs.stackexchange.com/questions/59437
|
Org-ref: how to get absolute path of bibliography in exported LaTeX file
|
2020-07-04T04:40:07.503
|
# Question
Title: Org-ref: how to get absolute path of bibliography in exported LaTeX file
I use Org-ref to insert references in Org mode when writing articles. I prefer to put bib files in a separate place, say `/bib/ref.bib`, instead of putting together with org files in `~/org/`. After inserting references with absolute path `bibliography:/bib/ref.bib`, I exported the Org file to LaTeX file by `C-c C-e l l`. However, the bibliography in the exported LaTeX file is specified by relative path, `\bibliography{../../../bib/ref}`.
How to get bibliography with absolute path `\bibliography{/bib/ref}` in the exported LaTeX file?
The reason I want to use absolute path is that the exported LaTeX file may be copied to other location and compiled. In that case, I have to manually change the relative path. Thanks for your time.
# Answer
A feature to set absolute path for bib file has been merged in org-ref. Update org-ref and add `(setq org-ref-latex-bib-resolve-func #'expand-file-name)`. See org-ref github issues here and here.
> 1 votes
---
Tags: org-mode, latex, org-ref
---
|
thread-61865
|
https://emacs.stackexchange.com/questions/61865
|
Prevent flycheck warning window
|
2020-11-21T22:14:42.053
|
# Question
Title: Prevent flycheck warning window
When flycheck finds too many warnings that do not fit in the mini-buffer, it opens up a window on a buffer named *Warnings* that looks something like this:
```
Warning (flycheck): Syntax checker python-pylint reported too many errors (665) and is disabled.
Use ‘M-x customize-variable RET flycheck-checker-error-threshold’ to
change the threshold or ‘C-u C-c ! x’ to re-enable the checker.
Warning (flycheck): Syntax checker python-pylint reported too many errors (665) and is disabled.
Use ‘M-x customize-variable RET flycheck-checker-error-threshold’ to
change the threshold or ‘C-u C-c ! x’ to re-enable the checker.
Warning (flycheck): Syntax checker python-pylint reported too many errors (659) and is disabled.
Use ‘M-x customize-variable RET flycheck-checker-error-threshold’ to
change the threshold or ‘C-u C-c ! x’ to re-enable the checker.
Warning (flycheck): Syntax checker python-pylint reported too many errors (667) and is disabled.
Use ‘M-x customize-variable RET flycheck-checker-error-threshold’ to
change the threshold or ‘C-u C-c ! x’ to re-enable the checker.
```
**How to stop this window from opening?** It is extremely obtrusive and annoying.
# Answer
I do not have a better answer than this one: Use `M-x customize-variable RET flycheck-checker-error-threshold` to change the threshold. Mine is currently set to 400.
If someone has a better solution, I gladly remove this answer.
> 0 votes
---
Tags: flycheck, warning
---
|
thread-61876
|
https://emacs.stackexchange.com/questions/61876
|
Melpa upgrade ignores url-proxy-service
|
2020-11-22T15:41:01.460
|
# Question
Title: Melpa upgrade ignores url-proxy-service
I use Emacs in a corporate environment behind a proxy.
I have customized `url-proxy-services`:
```
'(url-proxy-services
(quote
(("http" . "proxy:3128")
("https" . "proxy:3128"))))
```
I use the package tool:
```
(require 'package)
```
And I have customized the Melpa archives:
```
'(package-archives (quote (("melpa" . "http://melpa.org/packages/"))))
```
When I run `package-list-packages` I see the packages and the list gets updated. This means the proxy gets used for this.
But when I try to install a package, Emacs stalls:
```
Importing package-keyring.gpg...done
Package refresh done
2 packages can be upgraded; type ‘U’ to mark them for upgrading.
2 packages marked for upgrading.
Upgrade these 2 packages (groovy-mode-2.0, s-1.12.0)? y
Package menu: Operation started [Upgrading 2]
Contacting host: melpa.org:80
Quit
```
When I sniff the network with `tcpdump`, I can see packets send directly to some hosts on port 80. This matches the last message "Contacting host: melpa.org:80".
Why does Melpa ignore the proxy for the download? And how can I change this?
# Answer
This is probably a bug in version 26. I just compiled 27 and it works as expected.
> 0 votes
---
Tags: package-repositories, proxy
---
|
thread-61883
|
https://emacs.stackexchange.com/questions/61883
|
What are these characters?
|
2020-11-22T21:33:12.793
|
# Question
Title: What are these characters?
I have been on the agenda of actually applying the formatting done by various programs within various types of Emacs major modes, e. g., the compilation major mode. I found this and added this to my configuration file:
```
(use-package ansi-color
:config
(defun my-colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(ansi-color-apply-on-region compilation-filter-start (point-max))))
:hook (compilation-filter . my-colorize-compilation-buffer))
```
This got me most of the colours! Although every now and then I still see some uninterpreted (what looks like) escape codes. Here I show an example in compilation mode buffer `*Compile-Log*`,
What is this "^L" and how can I apply its effects as desired rather just printing out some representation of the actual code.
# Answer
Emacs displays the control characters 0 through 31 with a caret followed by another character. This convention dates back to the early teletype machines which were adopted by the first computers as input and output devices.
You can find out what ^L represents by looking at the table of ASCII characters:
```
Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex
0 00 NUL 16 10 DLE 32 20 48 30 0 64 40 @ 80 50 P 96 60 ` 112 70 p
1 01 SOH 17 11 DC1 33 21 ! 49 31 1 65 41 A 81 51 Q 97 61 a 113 71 q
2 02 STX 18 12 DC2 34 22 " 50 32 2 66 42 B 82 52 R 98 62 b 114 72 r
3 03 ETX 19 13 DC3 35 23 # 51 33 3 67 43 C 83 53 S 99 63 c 115 73 s
4 04 EOT 20 14 DC4 36 24 $ 52 34 4 68 44 D 84 54 T 100 64 d 116 74 t
5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u
6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v
7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w
8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x
9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y
10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z
11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B {
12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \ 108 6C l 124 7C |
13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D }
14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~
15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL
```
Find the row with L in it, then read the corresponding character in the first column, which is FF, or Form Feed. The form-feed character caused the teletype to feed enough paper that it could be torn off below the current line, so most terminals simply clear the screen and return the cursor position to the origin when they see a ^L. This is probably the behavior that your program is expecting.
These characters also informed the default key bindings for Emacs and many other programs, which is why C-l is used for clearing or redrawing the screen in so many programs. It's also why C-h is used for backspace, and C-i for tab.
I'm sure you could implement something that examines incoming text and clears the current buffer when it sees a form-feed character. Or you could arrange to run this program inside `term-mode`, which already implements this and many other terminal-like behaviors. You should be able to find instructions for that elsewhere.
> 2 votes
---
Tags: control-characters, ascii
---
|
thread-34123
|
https://emacs.stackexchange.com/questions/34123
|
Smarter and more efficient way to add font lock keywords to org-mode?
|
2017-07-12T23:40:52.520
|
# Question
Title: Smarter and more efficient way to add font lock keywords to org-mode?
I really hate looking at raw markup in org-mode documents, so I am trying to replace as much of it with symbols as possible.
So `#=begin_` becomes `{`, `src` becomes `some-glyph` etc.
My current approach is to just list a bunch of regexes for each case:
```
(font-lock-add-keywords
'org-mode `(("^\s*\\#\\+BEGIN_\\(QUOTE\\) "
(1 (progn (compose-region (match-beginning 1) (match-end 1) "")
nil)))
("^\s*\\#\\+END\\(QUOTE\\) "
(1 (progn (compose-region (match-beginning 1) (match-end 1) "")
nil)))
("^\s*\\(\\#\\+BEGIN_\\)[:alpha:]"
(1 (progn (compose-region (match-beginning 1) (match-end 1) "{")
nil)))
("^\s*\\(\\#\\+END_\\)[:alpha:]"
(1 (progn (compose-region (match-beginning 1) (match-end 1) "}")
nil)))
```
I wish I knew elisp better to refactor this but I don't. With this approach, you're searching for related syntax elements separately. It seems like it would be much more efficient to first look for an occurrences of `#+begin_`, replace them with `{`, then **search forward** for words like `src`, `quote`, `comment` etc.
I am not sure yet what the performance implications of this are for longer documents (perhaps someone will enlighten me), but I'd like to get off too a good start. Some interesting stuff on font-locking here by @lunaryorn, but it's totally over my head at the moment, and it seems to be about writing new major modes, instead of augmenting the font-locking in org-mode.
# Answer
> 0 votes
It looks like you want to only specify the regexp and the string,
so just write a little function to add all the rest.
```
(defun myfun (regexp str)
`(,regexp (1 (progn (compose-region
(match-beginning 1) (match-end 1) ,str) nil))))
```
Then you can use it in your expression:
```
(font-lock-add-keywords
'org-mode `(,(myfun "^\s*\\#\\+BEGIN_\\(QUOTE\\) " "")
,(myfun "^\s*\\#\\+END\\(QUOTE\\) " "")
,(myfun "^\s*\\(\\#\\+BEGIN_\\)[:alpha:]" "{")
,(myfun "^\s*\\(\\#\\+END_\\)[:alpha:]" "}") ))
```
Still pretty ugly... what you really want to do is
```
(MY-simple-font-lock-add-keywords
'org-mode '(("^\s*\\#\\+BEGIN_\\(QUOTE\\) " "")
("^\s*\\#\\+END\\(QUOTE\\) " "")
("^\s*\\(\\#\\+BEGIN_\\)[:alpha:]" "{")
("^\s*\\(\\#\\+END_\\)[:alpha:]" "}")))
```
The parentheses on each line might seem annoying, and you could get rid of them (change this code below) but they keep things straight.
```
(defun MY-simple-font-lock-add-keywords (mode list-regexp-str)
(font-lock-add-keywords
mode
(mapcar (lambda (arg) (apply #'myfun arg)) list-regexp-str)))
```
The question is old, but if we keep the question it should be answered.
This question (answer) has nothing to do with font-lock and highlighting but only changing the format it's coded in.
---
Tags: org-mode, font-lock
---
|
thread-61887
|
https://emacs.stackexchange.com/questions/61887
|
How to get more control over starting and ending itemize and description sections in LaTeX export?
|
2020-11-22T23:10:37.147
|
# Question
Title: How to get more control over starting and ending itemize and description sections in LaTeX export?
I'm wondering if there are some ways to control where org-mode decides to end itemize and description environments in LaTeX export. For example, the following org-mode file:
```
- Likelihood methods :: missing data are latent variables, find or estimate MLE
- Imputation methods :: use $X$ to impute $Y$, then proceed as with full data
- Inverse propensity weighting (IPW) :: just use complete cases, but weight by propensity
- Likelihood methods are general and elegant, but often difficult to apply
- We will focus on the latter two methods
- Here's another bullet
\[
x+y
\]
- I want this to be in the same itemize block as the previous item
```
exports to
```
\begin{description}
\item[{Likelihood methods}] missing data are latent variables, find or estimate MLE
\item[{Imputation methods}] use \(X\) to impute \(Y\), then proceed as with full data
\item[{Inverse propensity weighting (IPW)}] just use complete cases, but weight by propensity
\item Likelihood methods are general and elegant, but often difficult to apply
\item We will focus on the latter two methods
\item Here's another bullet
\end{description}
\[
x+y
\]
\begin{itemize}
\item I want this to be in the same itemize block as the previous item
\end{itemize}
```
1. How can I end the description environment after the first 3 items, and then start an itemize environment after that.
2. How can I get the display equation to be part of the item, without ending the itemize environment and then starting a new one immediately after the displayed equation. (It messes up the spacing when I do this in Beamer.)
# Answer
Both questions hang on how Org defines plain lists, and on how they end.
A list ends after two blank lines. So, for the first question, a couple of blank lines will do.
For the second, the syntax of plain list items requires that items of the same list must have the same indention on the first line. However, your equation breaks the list's indentation, and thus creates a second list.
It is sufficient that you add the proper lines and indent the equation appropriately:
```
- Likelihood methods :: missing data are latent variables, find or estimate MLE
- Imputation methods :: use $X$ to impute $Y$, then proceed as with full data
- Inverse propensity weighting (IPW) :: just use complete cases, but weight by propensity
- Likelihood methods are general and elegant, but often difficult to apply
- We will focus on the latter two methods
- Here's another bullet
\[
x+y
\]
- I want this to be in the same itemize block as the previous item
```
This exports to:
```
\begin{description}
\item[{Likelihood methods}] missing data are latent variables, find or estimate MLE
\item[{Imputation methods}] use \(X\) to impute \(Y\), then proceed as with full data
\item[{Inverse propensity weighting (IPW)}] just use complete cases, but weight by
propensity
\end{description}
\begin{itemize}
\item Likelihood methods are general and elegant, but often difficult to apply
\item We will focus on the latter two methods
\item Here's another bullet
\[
x+y
\]
\item I want this to be in the same itemize block as the previous item
\end{itemize}
```
> 2 votes
---
Tags: org-mode
---
|
thread-61889
|
https://emacs.stackexchange.com/questions/61889
|
How to highlight without one rule breaking another (font-lock-add-keywords)
|
2020-11-23T00:47:36.030
|
# Question
Title: How to highlight without one rule breaking another (font-lock-add-keywords)
I have 2 rules and the second one highlighting text disables the first...
```
(font-lock-add-keywords 'org-mode '(("^rtfm .*$" 0 '(:foreground "red"))))
(font-lock-add-keywords 'org-mode '(("'.*'" 0 '(:background "OrangeRed"))))
```
rtfm ... works
and 'this' works
but when I use them together only the second works.
rtfm whatever but then 'xx' and now only 'xx' is highlighted
This maybe sloppy, any tips are appreciated. (quote matching simplified here)
# Answer
> 0 votes
Try this:
```
(font-lock-add-keywords 'org-mode '(("^rtfm .*$" 0 '(:foreground "red"))))
(font-lock-add-keywords 'org-mode '(("'.*'" 0 '(:background "OrangeRed") 'keep)))
```
See the Elisp manual, node Search-based Fontification \- look for **`keep`**:
> **`(MATCHER . SUBEXP-HIGHLIGHTER)`**
>
> In this kind of element, `SUBEXP-HIGHLIGHTER` is a list which specifies how to highlight matches found by `MATCHER`. It has the form:
>
> ```
> (SUBEXP FACESPEC [OVERRIDE [LAXMATCH]])
>
> ```
>
> The `CAR`, `SUBEXP`, is an integer specifying which subexpression of the match to fontify (`0` means the entire matching text). The second subelement, `FACESPEC`, is an expression whose value specifies the face, as described above.
>
> The last two values in `SUBEXP-HIGHLIGHTER`, **`OVERRIDE`** and `LAXMATCH`, are optional flags. If `OVERRIDE` is `t`, this element can override existing fontification made by previous elements of `font-lock-keywords`. If it is **`keep`**, then each character is fontified if it has not been fontified already by some other element. If it is `prepend`, the face specified by `FACESPEC` is added to the beginning of the `font-lock-face` property. If it is `append`, the face is added to the end of the `font-lock-face` property.
If you want both faces used for the text that both regexps match then use `prepend` or `append` instead of `keep`. That will combine the OrangeRed background with the Red foreground. (It's not clear from your question just what behavior you really want.)
---
Tags: font-lock
---
|
thread-61878
|
https://emacs.stackexchange.com/questions/61878
|
How to control image sizes inside of table
|
2020-11-22T16:50:59.537
|
# Question
Title: How to control image sizes inside of table
I know that you can write something like:
```
#+attr_html: :width 250 px
[[./linl/to/image.jpg]]
```
But what if I have them inside of a table like:
```
| [[./linl/to/image.jpg]] | [[./linl/to/image2.jpg]] |
```
Alternatively, is there another way to visualize images side by side in org mode?
# Answer
Assuming you are happy with just HTML export and that all the images in the table should have the same width, you can use CSS:
```
#+HTML_HEAD: <style> td img {width: 250px;} </style>
```
It's a blunt instrument but if you don't ask too much of it, it can work. If you are trying to tweak each image differently, I think the best you can do is edit the HTML file to change:
```
<td class="org-left"><img src="./img/image1.jpg" alt="image1.jpg" /></td>
```
to
```
<td class="org-left"><img src="./img/image1.jpg" alt="image1.jpg" width="250px" /></td>
```
I don't know of a way to add a distinguishing id to each image so you can target your CSS to each image and tweak it.
I don't know of a generic way to deal with side-by-side images in all backends (other than the table method you are using).
> 1 votes
---
Tags: org-mode, org-table, images
---
|
thread-61898
|
https://emacs.stackexchange.com/questions/61898
|
Initializing forge-alist
|
2020-11-23T14:41:04.573
|
# Question
Title: Initializing forge-alist
I am trying to initialize Magit Forge's `forge-alist` programatically. Therefore I put together my first couple of emacs-lisp code. It looks like the following:
```
(let ((gitlab-install (lambda (host) (list host (concat host "/api/v4") host forge-gitlab-repository))))
(dolist (host '("gitlab.example.com" "gitlab.foobar.com"))
(print host)
(print (funcall gitlab-install host))
(add-to-list 'forge-alist (funcall gitlab-install host))))
```
Unfortunately it seems that the final `forge-alist` has strange entries even though the `(print)` statement prints out the entries correctly.
```
((#1="gitlab.foobar.com" "gitlab.foobar.com/api/v4" #1# forge-gitlab-repository)
(#2="gitlab.example.com" "gitlab.example.com/api/v4" #2# forge-gitlab-repository)
...)
```
What am I doing wrong?
# Answer
You've created a list (using `list`) that shares structure. That's what that `#1` syntax tells you.
```
(list host (concat host "/api/v4") host forge-gitlab-repository)
```
You pass, as the value of variable `host`, a string (e.g. `"gitlab.example.com"`).
The anonymous function (lambda) then constructs a list whose first and third elements are each the value you pass it. That is, those elements are **identical** \- the same string in this case. They're not copies (separate strings).
This tells you that:
```
(#1="gitlab.foobar.com" "gitlab.foobar.com/api/v4" #1# forge-gitlab-repository)
```
It shows a list whose first element is `"gitlab.foobar.com"`, and which it identifies as the `#1`, and whose third element is shown as `#1#`, which refers to that same element - same string exactly.
If you don't want such shared structure then use `copy-sequence` to get separate strings with the same chars.
But maybe you do want to reuse exactly the same string. Only you can answer that (or perhaps someone acquainted with `gitlab-install`).
> 1 votes
---
Tags: init-file, magit
---
|
thread-61875
|
https://emacs.stackexchange.com/questions/61875
|
How can I move the cursor from a shell window to another window in Evil mode?
|
2020-11-22T15:23:43.983
|
# Question
Title: How can I move the cursor from a shell window to another window in Evil mode?
Imagine I have following four windows in Emacs:
Window 1 is a shell window (`M-x shell`). Windows 2, 3, and 4 are normal windows with files open. Evil mode is enabled.
**If I am the shell window, how can I go to any other window (2, 3, 4) without using the mouse?**
The obvious choice is to use, for example, `CTRL-w j` to go from 1 to 2, but it does not work.
Emacs version: `GNU Emacs 27.1 (build 1, x86_64-apple-darwin19.6.0, Carbon Version 162 AppKit 1894.6) of 2020-10-06` OS: MacOS Catalina Version 10.15.7
# Answer
The evil keybindings seem not to work for me in every major mode as either.
What might help is to add the evil-collection package.
But what I did to really make sure that my keybinding for switching windows is:
```
(with-eval-after-load 'term
(define-key term-raw-map (kbd "C-<left>") 'evil-window-left)
(define-key term-raw-map (kbd "C-<right>") 'evil-window-right)
(define-key term-raw-map (kbd "C-<up>") 'evil-window-up)
(define-key term-raw-map (kbd "C-<down>") 'evil-window-down))
```
The "with-eval-after-load" part seems to do it.
You might want to swap "term" for "shell" in your case though. This might not be the most elegant way to do this, but it worked for me beautifully.
> 1 votes
---
Tags: evil, shell, navigation
---
|
thread-61893
|
https://emacs.stackexchange.com/questions/61893
|
Why do these two different use-package declarations (for the same package) have different effects?
|
2020-11-23T04:49:42.643
|
# Question
Title: Why do these two different use-package declarations (for the same package) have different effects?
What I want to accomplish is to add a keybinding `C-<backspace>` to the `eshell-mod-map` that calls `func`. That can be done like this,
```
(use-package eshell
:init
(defun add-func-keybinding ()
(define-key
eshell-mode-map
(kbd "C-<backspace>")
(lambda ()
(interactive)
(func "arg"))))
:hook
(eshell-mode . add-func-keybinding))
```
Now `C-<backspace>` *only* calls `func` when inside an eshell buffer. I thought this should be equivalent to,
```
(use-package eshell
:after esh-mode
:bind
(:map eshell-mode-map
("C-<backspace>" . (lambda () (interactive) (func "arg")))))
```
However, this binds `C-<backspace>` to `func` everywhere, e. g., if I press `C-<backspace>` in the `*scratch*` buffer, that also calls `func`. This does not happen when the configuration is done as in the former `use-package` declaration, there the keybinding is kept only inside the eshell buffer.
However, I fail to see the difference between the two declarations. I would like to fix the latter so it has the same effect as the former, since the latter is a bit clearer and nicer. How can I do this?
# Answer
> 1 votes
I would write it that way.
```
(use-package esh-mode
:bind (:map eshell-mode-map
("C-<backspace>" . my-eshell-mode-func))
:config (defun my-eshell-mode-func ()
(interactive)
(func "arg")))
```
For two reasons:
---
To answer your "why":
Because your first use-package form binds a define-key form to the hook `eshell-mode-hook`, which is sort of unrelated to feature eshell (because it belongs to feature esh-mode). But this hook triggers everytime, the feature esh-mode goes into action.
In your second use-package form this connection to feature esh-mode is missing (`:after esh-mode` results in something different).
*Edit:* Here is some fun: in old versions of file esh-mode.el `eshell-mode-map` gets fille as local variable, right in that moment, when `eshell-mode` was enabled by the user. With killing of the buffer `eshell-mode-map` went nil again. There is even a comment in source code:
> ;; FIXME: What the hell!?
That is probably the reason why your first use-package form uses a hook.
This setup of `eshell-mode-map` as a buffer local variable is still present in version 26.3 of Emacs. So binding your `define-key` to hook `eshell-mode-hook` is a valid option until you upgrade.
In more recent versions this has been fixed and my above solution should work.
---
Be aware, I cannot test this solution, because my emacs is way to old and does not has the line `(provide 'esh-mode)` in file esh-mode.el. And my OS does not map a `backspace` key to my physical keyboard.
---
Tags: key-bindings, eshell, use-package
---
|
thread-54137
|
https://emacs.stackexchange.com/questions/54137
|
How to add a syntax checker to a major mode for flycheck?
|
2019-12-03T21:39:43.067
|
# Question
Title: How to add a syntax checker to a major mode for flycheck?
I have the following flycheck setup in my init.el
```
(use-package flycheck
:after web-mode
:config
(global-flycheck-mode)
(flycheck-add-mode 'javascript-eslint 'web-mode)
:diminish flycheck-mode)
```
Now, I expect the line `(flycheck-add-mode 'javascript-eslint 'web-mode)` to add javascript-eslint as a linter whenever I have a buffer running web-mode. However, when inside a buffer using web-mode I get the following setup:
```
Syntax checkers for buffer .eslintrc.js in web-mode:
No checker to run in this buffer.
Checkers that are compatible with this mode, but will not run until properly configured:
handlebars (disabled)
- may enable: Automatically disabled!
- predicate: nil
- executable: Not found
Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.
--------------------
Flycheck version: 32snapshot (package: 20191108.2129)
Emacs version: 25.2.2
System: x86_64-pc-linux-gnu
Window system: x
```
And if I try to manually select the syntax checker, I get:
```
Syntax checker in buffer .eslintrc.js in web-mode:
javascript-eslint
- major mode: `web-mode' not supported
- may enable: yes
- executable: Found at /home/mfb/src/MyFantasyBasketball/frontend/mfb-spa/node_modules/eslint/bin/eslint.js
- config file: found
Flycheck cannot use this syntax checker for this buffer.
Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled checkers.
--------------------
Flycheck version: 32snapshot (package: 20191108.2129)
Emacs version: 25.2.2
System: x86_64-pc-linux-gnu
Window system: x
```
Anyone have an idea what I'm missing?
P.S. For some reason my `:diminish flycheck-mode` line also doesn't work...
Edit: expanded use-package command
```
(progn
(use-package-ensure-elpa 'flycheck
'(t)
'nil)
(defvar use-package--warning313
#'(lambda
(keyword err)
(let
((msg
(format "%s/%s: %s" 'flycheck keyword
(error-message-string err))))
(display-warning 'use-package msg :error))))
(condition-case-unless-debug err
(eval-after-load 'web-mode
'(if
(not
(require 'flycheck nil t))
(display-warning 'use-package
(format "Cannot load %s" 'flycheck)
:error)
(condition-case-unless-debug err
(progn
(global-flycheck-mode)
(flycheck-add-mode 'javascript-eslint 'web-mode)
(if
(fboundp 'diminish)
(diminish 'flycheck-mode))
t)
(error
(funcall use-package--warning313 :config err)))))
(error
(funcall use-package--warning313 :catch err))))
```
Also, I noticed it will work if I add the single line `(flycheck-add-mode 'javascript-eslint 'web-mode)` to my init.el. I just can't get it to work with use-package for some reason
Edit 2: `flychecker-describe-checker` output
```
javascript-eslint is a Flycheck syntax checker in `flycheck.el'.
This syntax checker checks syntax in the major mode(s) `web-mode', `js-mode',
`js-jsx-mode', `js2-mode', `js2-jsx-mode', `js3-mode', `rjsx-mode',
`typescript-mode'.
This syntax checker executes "eslint". The executable can be overridden with
`flycheck-javascript-eslint-executable'.
This syntax checker can be configured with these options:
* `flycheck-eslint-args'
* `flycheck-eslint-rules-directories'
Documentation:
A Javascript syntax and style checker using eslint.
See URL `https://eslint.org/'.
[back]
```
# Answer
> 3 votes
You gave us the answer yourselves. The `(flycheck-add-mode 'javascript-eslint 'web-mode)` statement has to be run before enabling flycheck-mode. Simply moving the addition of `web-mode` as supported mode of `javascript-eslint` before enabling the global mode worked for me:
```
(use-package flycheck
:config
(flycheck-add-mode 'javascript-eslint 'web-mode)
(global-flycheck-mode t))
```
You could also do it the other way around, enabling flycheck in the web-mode hook (not using global mode, though) :
```
(use-package web-mode
:ensure t
:after flycheck
:config
(add-hook 'web-mode-hook
#'(lambda ()
(unless (flycheck-checker-supports-major-mode-p
'javascript-eslint 'web-mode)
(flycheck-add-mode 'javascript-eslint 'web-mode))
(flycheck-mode t))))
```
---
Tags: flycheck
---
|
thread-50249
|
https://emacs.stackexchange.com/questions/50249
|
How can i prevent current clocked task from showing in modeline?
|
2019-04-30T19:56:27.240
|
# Question
Title: How can i prevent current clocked task from showing in modeline?
Is there any way to disable clocked task from being shown in modeline? I tried searching for variables, but i couldn't find any that turns it off.
# Answer
You can set the variable `org-clock-clocked-in-display`. The docstring reads:
```
Documentation:
When clocked in for a task, Org can display the current
task and accumulated time in the mode line and/or frame title.
Allowed values are:
both displays in both mode line and frame title
mode-line displays only in mode line (default)
frame-title displays only in frame title
nil current clock is not displayed
```
> 3 votes
---
Tags: org-mode, org-clock
---
|
thread-61910
|
https://emacs.stackexchange.com/questions/61910
|
org-publish gives multiple entry with quote one of them
|
2020-11-24T08:41:03.810
|
# Question
Title: org-publish gives multiple entry with quote one of them
So, I have the following content in the `.dir-locals.el` file for my project:
```
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((org-mode
(org-twbs-link-up . "https://psibi.in/prometheus/")
(org-twbs-link-home . "https://psibi.in/")
(org-publish-project-alist . '("prometheus"
:base-directory "~/github/prometheus/"
:recursive t
:base-extension "org"
:auto-sitemap t
:publishing-function org-twbs-publish-to-html
:publishing-directory "~/github/prometheus/docs/"))))
```
Now when I invoke `org-publish` from a file, it gives me two entries:
* quote
* prometheus
Now I don't understand what `quote` is and why it's populated ? What am I doing wrong ? Reproducible repository is here: https://github.com/psibi/prometheus
# Answer
You are quoting the value of `org-publish-project-alist`, i.e. you are telling it that the value is
```
(quote ("prometheus" ...))
```
which causes the confusion you are seeing. You don't want to quote it but you need to fix the structure, since `org-publish-project-alist` is an alist, i.e. a list of dotted pairs:
```
((org-mode . (
(org-twbs-link-up . "https://psibi.in/prometheus/")
(org-twbs-link-home . "https://psibi.in/")
(org-publish-project-alist . (("prometheus"
:base-directory "~/github/prometheus/"
:recursive t
:base-extension "org"
:auto-sitemap t
:publishing-function org-twbs-publish-to-html
:publishing-directory "~/github/prometheus/docs/"))))))
```
> 1 votes
---
Tags: org-mode, org-export
---
|
thread-61915
|
https://emacs.stackexchange.com/questions/61915
|
I need a key binding of: "M-x compile" then in Compile commant type the "Compile command: love2d /home/huseyin/Documents/Programming/Lua/"
|
2020-11-24T14:26:52.460
|
# Question
Title: I need a key binding of: "M-x compile" then in Compile commant type the "Compile command: love2d /home/huseyin/Documents/Programming/Lua/"
I need a key binding of: `M-x compile` then in compile command type like `Compile command: love2d /home/huseyin/Documents/Programming/Lua/` I am tired of doing that again and again.
# Answer
Sure, just add something like this to your init file:
```
(defun oleg/compile-lua ()
"use love2d to compile my lua code"
(interactive)
(compile "love2d /home/huseyin/Documents/Programming/Lua/"))
(global-set-key (kbd "<f5>") #'oleg/compile-lua)
```
You can name the function whatever you prefer, and bind it to whichever key you like.
> 1 votes
---
Tags: key-bindings, init-file, hooks
---
|
thread-50602
|
https://emacs.stackexchange.com/questions/50602
|
Cannot open URL link in emacs under msys
|
2019-05-19T16:09:37.620
|
# Question
Title: Cannot open URL link in emacs under msys
When trying to open URL link in emacs under MSYS2 I get the error *browse-url-default-windows-browser: Searching for program: No such file or directory, cygstart*. Looking into the function `browse-url-default-windows-browser` I found out that it needed to call process `cygstart`:
```
(defun browse-url-default-windows-browser (url &optional _new-window)
"Invoke the MS-Windows system's default Web browser.
The optional NEW-WINDOW argument is not used."
<...>
((eq system-type 'cygwin)
(call-process "cygstart" nil nil nil url))
```
But there is no `cygstart` in MSYS2 according to its wiki How does MSYS2 differ from Cygwin. Though the variable `system-type` really equals `'cygwin` and cannot be changed to anything more appropriate.
How to fix this error?
# Answer
Building on @rucarden's solution I found you can use `browse-url-browser-function` to replace the original one inside your `.emacs`. It's a documented setting in `browser.el`.
```
(when (eq system-type 'cygwin)
(setq
browse-url-browser-function
(lambda (url &optional _new-window)
(interactive (browse-url-interactive-arg "URL: "))
(shell-command (concat "start " (shell-quote-argument url)())))))
```
> 0 votes
# Answer
It seems that start works. I made the following change to browse-url.el and then reloaded it with load-file. There is probably a more elegant way of doing this that doesn't involve modifying browse-url.el.
```
((eq system-type 'cygwin)
(shell-command (concat "start " (shell-quote-argument url)))))
```
> 0 votes
---
Tags: url
---
|
thread-61936
|
https://emacs.stackexchange.com/questions/61936
|
From one-line list to one element per line in python-mode
|
2020-11-25T14:39:33.527
|
# Question
Title: From one-line list to one element per line in python-mode
How do I turn a long one-line list, such as
```
test_list = ['a0000000', 'b1111111', 'c2222222', 'd3333333', 'e4444444', 'f5555555', 'g6666666']
```
into a one element per line list:
```
test_list = ['a0000000',
'b1111111',
'c2222222',
'd3333333',
'e4444444',
'f5555555',
'g6666666']
```
Or:
```
test_list = [
'a0000000',
'b1111111',
'c2222222',
'd3333333',
'e4444444',
'f5555555',
'g6666666',
]
```
With `fill-paragraph` long one-line lists are at least broken up into multiline lists:
```
test_list = ['a0000000', 'b1111111', 'c2222222', 'd3333333',
'e4444444', 'f5555555', 'g6666666' ]
```
But I would find a one element per line list in many cases more useful. Is anyone aware of such a elisp function (e.g. in elpy or anywhere else)?
# Answer
You can always write a function to do what you want and bind it to a key sequence. The following will deal with the vast majority of cases, but it will fail if a list element contains the string ", ". It assumes that your cursor is at the beginning of the line in question (and leaves `point` unchanged), searches for the string ", " in the line and calls `newline` after each one (which deals intelligently with the space-to-newline conversion). It then calls `indent-region` between the original `point` and the final end-of-line, to reindent everything properly. It will also work on multi-line lists (e.g. the two-line list after `M-q`) although you will have to call it once on each line:
```
(defun python-list-break-and-indent ()
"Convert a single-line list into a block list, indented properly.
ASSUMPTION: the only occurrences of the string \", \" are between
list elements."
(interactive)
(save-excursion
(let ((beg (point)))
(while (search-forward ", " (save-excursion (end-of-line) (point)) t)
(newline))
(end-of-line)
(indent-region beg (point)))))
(define-key python-mode-map (kbd "C-c b") #'python-list-break-and-indent)
```
I bound the function to `C-c b` because it was undefined in `python-mode-map` in my case, but you should check with `C-h c C-c b` in a python mode buffer and choose something else if it is taken (`C-c <letter>` keys are supposed to be reserved for users).
> 1 votes
---
Tags: python, fill-paragraph
---
|
thread-61930
|
https://emacs.stackexchange.com/questions/61930
|
How to Configure AucTeX to Preview .pdf File Generated by XeLaTeX?
|
2020-11-25T03:34:41.287
|
# Question
Title: How to Configure AucTeX to Preview .pdf File Generated by XeLaTeX?
How can I achieve this by adding something to ~/.emacs
This is my .emacs
OS: Ubuntu20.04LTS (WSL)
Emacs: 26.3
XeLaTeX: 6.3.2
# Answer
This is covered in the AucTeX manual, specifically the section `(auctex) Starting Viewers`.
The command to launch a viewer is:
> -- Command: TeX-view
> ('C-c C-v') Start a viewer without confirmation. The viewer is
> started either on a region or the master file, depending on the
> last command issued. This is especially useful for jumping to the
> location corresponding to point in the viewer when using
> 'TeX-source-correlate-mode'.
If you want to customize the program used to view pdfs, the variable to start with is `TeX-view-program-selection`:
> The association between the tests for the conditions mentioned above and the viewers is made in the variable 'TeX-view-program-selection'. Therefore this variable is the starting point for customization if you want to use other viewers than the ones suggested by default.
>
> -- User Option: TeX-view-program-selection
> This is a list of predicates and viewers which is evaluated from
> front to back in order to find out which viewer to call under the
> given conditions. In the first element of each list item you can
> reference one or more predicates defined in
> 'TeX-view-predicate-list' or 'TeX-view-predicate-list-builtin'. In
> the second element you can reference a viewer defined in
> 'TeX-view-program-list' or 'TeX-view-program-list-builtin'. The
> viewer of the first item with a positively evaluated predicate is
> selected.
Check the manual for further details. If you still have specific questions after that, please come back and ask again!
> 0 votes
---
Tags: latex, auctex
---
|
thread-61925
|
https://emacs.stackexchange.com/questions/61925
|
Retrieve alist from list of alists by value of specific key inside of it
|
2020-11-25T00:39:06.897
|
# Question
Title: Retrieve alist from list of alists by value of specific key inside of it
I'm probably missing something simple here but... I've got a list of alists parsed from JSON using `json-parse-string`. The list of alists is like the following (details omitted for brevity):
```
( ((id . 1) (url . "http://gnu.org") (description . "GNU Operating System"))
((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation")) ... )
```
I'm trying to retrieve an alist from the list by the value associated to `id` in the alist.
E.g. `(function 2 list)` would return `((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation"))`
Obviously I could `while` or `cl-loop` over the list to find this out, but what is more a Lispy way of doing this?
# Answer
If the structure/sequence is very dependable then you might just do this:
```
(require 'cl-lib)
(cl-find 2 list :key #'cdar)
;; or
(car (cl-member 2 list :key #'cdar))
```
More robustly, you'd use one of the alist functions to obtain the correct value to test against.
```
(cl-find 2 list :key (apply-partially #'alist-get 'id))
=> ((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation"))
(cl-find "http://fsf.org" list
:key (apply-partially #'alist-get 'url)
:test #'string=)
=> ((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation"))
```
> 4 votes
# Answer
I'd probably do something like this:
```
(setq toto '(((id . 1)
(url . "http://gnu.org")
(description . "GNU Operating System"))
((id . 2)
(url . "http://fsf.org")
(description . "Free Software Foundation"))))
(defun foo (val lst)
"..."
(let ((al (cl-member val lst :key `(lambda (xx) (cdr (rassoc ',val xx))))))
(car al)))
(foo 2 toto) ; => ((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation"))
```
Or if you have `lexical-binding` turned on (i.e., non-`nil`), then just use this for `:key` \- no need for the backquoting to insert the *value* of `val`, which would otherwise be a free variable:
```
(lambda (xx) (cdr (rassoc val xx)))
```
> 3 votes
# Answer
To find a item from a list, I will probably use `seq-find`
```
(seq-find
(lambda (alist)
(= (alist-get 'id alist) 1))
'(((id . 1) (url . "http://gnu.org") (description . "GNU Operating System"))
((id . 2) (url . "http://fsf.org") (description . "Free Software Foundation"))))
;; => ((id . 1) (url . "http://gnu.org") (description . "GNU Operating System"))
```
> 2 votes
---
Tags: list, alists
---
|
thread-61941
|
https://emacs.stackexchange.com/questions/61941
|
How to fix: [Suspicious state from syntax checker python-mypy: Flycheck checker python-mypy returned 2, but its output contained no errors]
|
2020-11-25T19:30:09.893
|
# Question
Title: How to fix: [Suspicious state from syntax checker python-mypy: Flycheck checker python-mypy returned 2, but its output contained no errors]
I keep having following warning message, even I have the recent version of `python-mypy` not sure why this warning message is generated; is there any way to fix this:
```
Suspicious state from syntax checker python-mypy: Flycheck checker python-mypy returned 2, but its output contained no errors:
utils.py: error: Source file found twice under different module names: 'Program.utils' and 'utils'
Found 1 error in 1 file (checked 1 source file)
Try installing a more recent version of python-mypy, and please open a bug report if the issue persists in the latest release.
Thanks!
```
---
pip-setup:
```
$ pip freeze | grep mypy
flake8-mypy==17.8.0
mypy==0.790
mypy-extensions==0.4.3
```
output of `elpy-config` within the `emacs`:
```
Elpy Configuration
Emacs.............: 26.3
Elpy..............: 1.34.0
Virtualenv........: venv (/home/alper/venv)
Interactive Python: python3 3.7.5 (/home/alper/venv/bin/python3)
RPC virtualenv....: rpc-venv (/home/alper/.emacs.d/elpy/rpc-venv)
Python...........: python 3.7.5 (/home/alper/.emacs.d/elpy/rpc-venv/bin/python)
Jedi.............: 0.17.2
Rope.............: 0.16.0
Autopep8.........: 1.5.4
Yapf.............: 0.30.0
Black............: 20.8b1
Syntax checker....: flake8 (/home/alper/venv/bin/flake8)
```
# Answer
You're getting this message because Flycheck ran mypy to see if your code was correct and while mypy returned an error code, it didn't print out a list of errors (at least not as far as Flycheck could tell.)
The error message includes the output from mypy:
```
utils.py: error: Source file found twice under different module names: 'Program.utils' and 'utils'
Found 1 error in 1 file (checked 1 source file)
```
A human might interpret this as an error message, I suppose, but it doesn't match any of the regular expressions that Flycheck uses to look for errors. You could update those regular expressions yourself, or even file a bug asking the Flycheck developers to fix it.
> 1 votes
---
Tags: elpy
---
|
thread-61926
|
https://emacs.stackexchange.com/questions/61926
|
Is there a way to show python generated plots in the python interpreter console?
|
2020-11-25T01:21:02.170
|
# Question
Title: Is there a way to show python generated plots in the python interpreter console?
I use emacs for most python programming, but really miss the inline plot feature combined with printed output in Spyder. See picture.
I've been experimenting with various interpreter settings but none seem to work:
```
(use-package python
:config
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "-i --simple-prompt")
(setq python-shell-interpreter "jupyter"
python-shell-interpreter-args "console --simple-prompt"))
```
Is there a way to setup this functionality in Emacs?
# Answer
You may wanna checkout ein. Also, spacemacs has a ipython-notebook layer setup based on that; perhaps you can use that as a reference for your own config.
> 2 votes
# Answer
Yes, use emacs-jupyter.
Try installing with `M-x package-install jupyter` (it's in Melpa) or follow the instructions on the Github.
Then configure it to put output (such as plots) into the REPL buffer with `(setq jupyter-repl-echo-eval-p t)`. Without this, output from plots will go into a separate pop-up buffer.
Then call a Jupyter shell as `M-x jupyter-run-repl` (instead of the usual `M-x run-python`).
You should be able to verify that it is working quickly (inside the shell you opened). A tip, when you are plotting: you want to say (in your python code) `fig.set_facecolor('w')` to make things more readable.
```
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(10,10))
fig.set_facecolor('w')
plt.scatter([1,2,3], [4,5,3])
```
> 1 votes
---
Tags: python, ipython, jupyter
---
|
thread-56407
|
https://emacs.stackexchange.com/questions/56407
|
How to use prefix C-SPC instead of prefix C-h, for `which-key-mode-map`?
|
2020-03-27T19:07:07.277
|
# Question
Title: How to use prefix C-SPC instead of prefix C-h, for `which-key-mode-map`?
I'd like to change the `C-h` prefix to `C-SPC` and so I added the following to my init.el, but it has no effect.
`(define-key which-key-mode-map (kbd "<C-SPC>") 'which-key-C-h-dispatch)`
Help understanding how to make this change would be appreciated. Thanks.
# Answer
> 0 votes
Ctrl is 2^26, SPC is 0x20, so C-SPC is 0x4000020.
Set variable help-char to C-SPC: (setq help-char #x4000020)
See elisp manual for more detail: https://www.gnu.org/software/emacs/manual/html\_node/elisp/Keyboard-Events.html#Keyboard-Events
---
Tags: prefix-keys, which-key
---
|
thread-61952
|
https://emacs.stackexchange.com/questions/61952
|
dnd-unescape-uri is undefined
|
2020-11-26T09:30:43.013
|
# Question
Title: dnd-unescape-uri is undefined
After updating packages from MELPA, I'm getting the message:
`Warning (emacs): dnd-unescape-uri is undefined. Some things may not work.`
It is a separate buffer. Not in the messages buffer. I can just close the buffer and Emacs seems to be working alright.
I'm using Emacs 27.1 with the Spacemacs layer.
Two questions: Is this dangerous? And what can I do about this?
# Answer
Same problem for me after updating org-ref. It is linked to the fix related to the issue mentioned by @Philopolis: https://github.com/jkitchin/org-ref/commit/a7d24f48fe6416162cb1f32d9b87934b9e6c563d
If you want to avoid this warning message at startup, a (temporary) solution is to set
```
(setq warning-minimum-level :emergency)
```
> 3 votes
---
Tags: warning, emacs27
---
|
thread-61951
|
https://emacs.stackexchange.com/questions/61951
|
org export with interleaved output
|
2020-11-26T07:09:29.883
|
# Question
Title: org export with interleaved output
I have an Org mode file with the following source block in it:
```
#+begin_src sh :exports both
echo "first line"
echo "second line"
#+end_src
#+RESULTS:
| first | line |
| second | line |
```
But when I export it as HTML, I get the following output:
I would like to export it so that the output is interleaved with the execution of each command:
```
$ echo "first line"
first line
$ echo "second line"
second line
```
How can I do that?
# Answer
There is nothing like that: Org babel evaluates the source block by storing *all* the commands in a temp file, runs the file using the appropriate language interpreter, collects the output, does minor munging to it and writes it out as the results block. What you are asking for (a header argument that modifies this work flow) is fundamentally incompatible with the basic babel model.
EDIT: I should have added a couple of possible ways to get what you want even if a bit inconveniently:
* one way is to have separate code blocks for each command as mentioned in the comments:
```
#+begin_src sh :exports both
echo "first line"
#+end_src
#+begin_src sh :exports both
echo "second line"
#+end_src
```
* a second way is to forego the export of the code and just export results, but make the code block output the commands as well as the output of those commands:
```
#+begin_src shell :results output :exports results :wrap example
cmd='echo "first line"'
echo "\$ $cmd"
eval $cmd
cmd='echo "second line"'
echo "\$ $cmd"
eval $cmd
#+end_src
```
* If you are using `bash`, you can use arrays to make the second method much more palatable:
```
#+begin_src shell :results output :exports results :wrap example
declare -a cmds=('echo "first line"'
'echo "second line"')
for cmd in "${cmds[@]}" ;do
echo "\$ $cmd"
eval $cmd
done
#+end_src
```
All you need to do is add more commands to the `cmds` array: the rest of the code does not need to be touched.
> 2 votes
---
Tags: org-mode, org-export, org-babel
---
|
thread-61962
|
https://emacs.stackexchange.com/questions/61962
|
What is Interlocking about?
|
2020-11-26T21:27:33.910
|
# Question
Title: What is Interlocking about?
Recently I "fixed" issue with locking when I access LXSS backed P9 network FS mounted in Cygwin by:
```
(setq create-lockfiles nil)
```
I read `(info "(emacs.info) Interlocking")` but still didn't get it.
Is it defense against simultaneous writing from another Emacs? Or general outside edits?
Is it the "fancy" way to save file's timestamp?
Is it make sense to use this feature from Cygwin Emacs (which emulated symlink API)?
I believe that Emacs is doing mtime check (what about fsize??) anyway and this "symlink" business looks stupid...
# Answer
They are a protection against simultaneous editing by two Emacs sessions, yes. This can even be between instances of Emacs running on different computers, which can happen when both computers can access the same file system over the network. This was a more frequent occurrence when dozens or hundreds of people would log into the same computer. The symlink contains the username and process id of the Emacs session specifically so that you can go to their office/lab/desk/etc and ask them if they are done with the file or not.
Most tools can be configured to ignore them. For example, if you add these rules to your Git repository's `.gitignore` file, git commands will ignore them:
```
*~
.\#*
```
It's been so long since I've used Cygwin that I can't say with certainty whether or not it's useful there. Honestly, I would just use the native Windows builds of Emacs, even if I was using Cygwin to provide other command-line tools.
> 1 votes
---
Tags: file-locking
---
|
thread-61965
|
https://emacs.stackexchange.com/questions/61965
|
Alternative to `read-number' that does not truncate floating point zeros
|
2020-11-26T23:56:43.193
|
# Question
Title: Alternative to `read-number' that does not truncate floating point zeros
The function `read-number` truncates floating point zeros; e.g., `(read-number "PROMPT: ") RET 100.00` =\> **100.0**
I am seeking a similar alternative to `read-number` that will not truncate; e.g., `(new-func "PROMPT: ") RET 100.00` =\> **100.00**
# Answer
If you enter `100.00` at the `read-number` prompt, then you get back a `float`, which might be printed differently to how it was entered.
For instance, `0.0000000000000000000001` prints in scientific notation as `1e-22`
If you want Emacs to show the same thing that was typed, your best bet is to read a string.
If you just want to `format` the float differently, you can do that. E.g.:
```
(format "%.2f" (read-number "?"))
```
> 1 votes
---
Tags: numbers
---
|
thread-61968
|
https://emacs.stackexchange.com/questions/61968
|
Saving filter list for Bookmark+ package
|
2020-11-27T01:41:25.423
|
# Question
Title: Saving filter list for Bookmark+ package
I've recently started using the BookmarkPlus package and I've been loving it. However there is one thing that I can't seem to figure out. I want, from my big list of bookmarks, to create a set of smaller lists, that would function as sort of projects, so I can have only the bookmarks related to a certain project in the `*Bookmark List*` visible.
**Edit:** Maybe I should also mention I'm working on Windows 10 with the windows version of emacs. What I tried was this (It was based on the description here).
I will describe my problem in the form of a minimum working example. Let's say we have a bookmark file with three bookmarks:
```
Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp
All Bookmarks
-------------
t file A fileA.txt
t file B fileB.txt
t file C fileC.txt
```
with tags:
* `file A` has tag `proj1`
* `file B` has tag `proj2`
* `file C` has tag `proj1`
Then to view just the files from "Project 1", I do one of the following:
* In the `*Bookmark List*` buffer use `P T proj1 <ret>` which gives me the filtered view:
```
Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp
Bookmarks with Tags Matching Regexp `proj1'
-------------------------------------------
t file A fileA.txt
t file C fileC.txt
```
Now I wish to save this view as for later use so I do `C-x r m Project1 <ret>`. This throws me back to the bookmark list with a new bookmark like so:
```
Bookmark file:
c:/Users/me/.emacs.d/bookmark_test.bmkp
All Bookmarks
-------------
t file A fileA.txt
t file B fileB.txt
t file C fileC.txt
Project1 *Bookmark List*
```
Now when I go to the bookmark `Project1` and press `<ret>`, I expect to get back to the filtered view like above, yet this does not happen and doing so simply moves point to the bookmark `file A`.
* The second approach is much the same, except instead of filtering with `P T` I use `T m * proj1 <ret> <ret>` to first tag the files and then filter them with `>` and again save with `C-x r m`. The end result is the same.
My init file for the example is the following
```
(let ((default-directory "~/.emacs.d/packages/"))
(normal-top-level-add-subdirs-to-load-path))
(require 'bookmark+)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(bmkp-last-as-first-bookmark-file "c:/Users/me/.emacs.d/bookmark_test.bmkp")
'(bookmark-default-file "~/.emacs.d/bookmark_test.bmkp"))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
```
The file `bookmark_test.bmkp` looks like:
```
;;;; Emacs Bookmark Format Version 1 ;;;; -*- coding: utf-8 -*-
;;; This format is meant to be slightly human-readable;
;;; nevertheless, you probably don't want to edit it.
;;; -*- End Of Bookmark File Format Version Stamp -*-
(#1=(#("file C" 0 6
(bmkp-full-record #1#))
(tags "proj1")
(filename . "~/Documents/fileC.txt")
(buffer-name . "fileC.txt")
(front-context-string)
(rear-context-string . "s the last file.")
(front-context-region-string)
(rear-context-region-string)
(visits . 1)
(time 24513 1396 891997 0)
(created 24512 60521 908157 0)
(position . 23))
#1=(#("file B" 0 6
(bmkp-full-record #1#))
(tags "proj2")
(filename . "~/Documents/fileB.txt")
(buffer-name . "fileB.txt")
(front-context-string)
(rear-context-string . "is the last one.")
(front-context-region-string)
(rear-context-region-string)
(visits . 1)
(time 24513 355 491409 0)
(created 24512 60464 541235 0)
(position . 69))
#1=(#("file A" 0 6
(bmkp-full-record #1#))
(tags "proj1")
(filename . "~/Documents/fileA.txt")
(buffer-name . "fileA.txt")
(front-context-string)
(rear-context-string . "t has two lines.")
(front-context-region-string)
(rear-context-region-string)
(visits . 0)
(time . #2=(24512 60394 692321 0))
(created . #2#)
(position . 42))
)
```
Saving the filtered view adds the following bookmark to the bookmark file:
```
(#1=(#("Project1" 0 8
(bmkp-full-record #1#))
(buffer-name . "*Bookmark List*")
(visits . 1)
(time 24513 2965 108585 0)
(created 24513 2958 669730 0)
(position . 147)
(filename . " - no file -")
(bookmark-list
(last-sort-comparer
(bmkp-info-node-name-cp bmkp-gnus-cp bmkp-url-cp bmkp-local-file-type-cp)
bmkp-alpha-p)
(last-reverse-sort-p)
(last-reverse-multi-sort-p)
(last-bmenu-filter-function)
(last-bmenu-filter-pattern . "proj1")
(last-bmenu-omitted-bookmarks)
(last-bmenu-title . "")
(last-bmenu-toggle-filenames . t))
(handler . bmkp-jump-bookmark-list))
```
# Answer
You don't give details of what you tried, but from your use case it sounds like the best approach is to create one or more **bookmark-list** bookmarks. Jumping to such a bookmark opens the bookmark-list display state that was bookmarked.
For that, you should be able to just use `C-x r m` in the bookmark-list display, once you have it the way you want it, to create a bookmark recording its state. When you later jump to that bookmark you should see that state you recorded.
For example, do this in the bookmark-list display:
1. `I S`, to show only Info bookmarks (bookmarks to Info manual pages). (Using menu *Bookmark+* this is *Show* \> *Only Bookmarks of Type* \> *Info Nodes*.)
2. `C-x r m`, and enter a name for the bookmark to be created.
Later, to restore the bookmark-list display to what was recorded, just jump to that bookmark.
As you mentioned, there are other, related ways to record a bookmark-list display, depending on what you need. But this one is quite simple, and from what you describe it should do what you want.
Maybe you need to give more details about the filtering you are doing.
---
**UPDATE** after you added more detail in the question (thanks).
1. A bookmark-list display state arrived at with *incremental* pattern matching (e.g. `P T`), as opposed to, say using a filtering command (I gave an example of that, above), was *not* captured in a bookmark-list bookmark. I fixed that (i.e., implemented that missing feature) yesterday, having guessed that that's maybe what you tried. (Had you happened to download yesterday's `bookmark+-bmu.el` that would have been fixed.)
2. As the doc says, *markings* are *not* captured by bookmark-list bookmarks. They are also *not* captured by the commands you create using **`C-c C-c`** (command `bmkp-bmenu-define-command`) -- that captures only the current sort order, filter, and omit list.
3. As the doc also says, markings *are* captured by the much heavier-weight `C-c C-S-c` (aka **`C-c C-C`**, command `bmkp-bmenu-define-full-snapshot-command`). That captures pretty much everything, at the cost of storing a full bookmark list, list of markings, etc.
4. However, there were some bugs in #3 (`C-c C-C`). I've think I've fixed those today.
Please try the latest **`bookmark+-bmu.el`**. And please read up again on the differences between the different ways of capturing and restoring bookmark-list state. Each method has its advantages.
---
BTW, if you turn off option `bmkp-propertize-bookmark-names-flag` then the bookmark list you copy and paste somewhere (e.g. here) is much simpler to read and understand. It then has no shared structure that allows for multiple bookmarks with the same name but different behavior/targets. The toggle command for flipping this option value is `bmkp-toggle-propertize-bookmark-names`. It's also *Bookmark+* menu item *Toggle* \> *Allowing Identical Bookmark Names*.
The ability to have multiple bookmarks with the same name is importantly primarily for *autofile* bookmarks, whose names are their relative file names: you can have multiple files named `foo.el` in different directories..
> 1 votes
---
Tags: bookmarks, filtering
---
|
thread-61966
|
https://emacs.stackexchange.com/questions/61966
|
Make customize save lists newline separated
|
2020-11-27T00:26:50.033
|
# Question
Title: Make customize save lists newline separated
When saving changes using `customize` Emacs serializes lists space separated. This makes for example the `package-selected-packages` variable extremely long and hard to scan over.
Is it possible to make Emacs serialize lists more like it does with alists (like `package-archives` below)? That is, one element per line?
Basically, I want this:
```
;;;; Custom mode ;;;;
(custom-set-variables
…
'(package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")))
'(package-quickstart t)
'(package-selected-packages '(ace-jump-mode add-node-modules-path … yaml-mode yatemplate))
'(projectile-keymap-prefix "p")
…
)
```
… to turn into this:
```
;;;; Custom mode ;;;;
(custom-set-variables
…
'(package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")))
'(package-quickstart t)
'(package-selected-packages
'(ace-jump-mode
add-node-modules-path
…
yaml-mode
yatemplate))
'(projectile-keymap-prefix "p")
…
)
```
# Answer
The function that does this serializing (printing to your `custom-file` or init file) is `custom-save-variables`.
You would need to redefine or advise that function, to have it use *pretty-printing* (functions from library `pp.el`, such as `pp-to-string` and `pp-display-expression`) instead of regular printing.
For example, `(pp-display-expression auto-mode-alist SOME-BUFFER)` pretty-prints the value of `auto-mode-alist`, inserting newlines etc.
---
(You might also want to file an enhancement request, to have Emacs do this by default. To do that, use `M-x report-emacs-bug`.)
> 2 votes
---
Tags: customize
---
|
thread-61972
|
https://emacs.stackexchange.com/questions/61972
|
Add note to clock entry when moving item to DONE
|
2020-11-27T07:48:22.023
|
# Question
Title: Add note to clock entry when moving item to DONE
For my Org buffer, I configured `#+STARTUP: lognoteclock-out` for adding notes to my logbook entries when clocking out, which basically works fine. However, when the clock is stopped due to the item being marked as DONE (since `org-clock-out-when-done` is enabled as well), I am *not* asked for a log message. Is there a way to make this happen?
Of course it would work if I clocked out first and marked the item as DONE in a separate step afterwards, but this would somewhat defeat the purpose of `org-clock-out-when-done`.
# Answer
> 2 votes
You can either:
* Ask for a note when you mark an item `DONE`, which is the simplest option:
```
(setq org-log-done 'note)
```
* check the appropiate hook to track the desired state change, catch the condition you want, and execute what you want. It could be, for example, using org-after-todo-state-change-hook.
Also, take a look to the manual.
---
Tags: org-mode
---
|
thread-61960
|
https://emacs.stackexchange.com/questions/61960
|
Understanding emacs keys
|
2020-11-26T16:37:25.807
|
# Question
Title: Understanding emacs keys
I'm vim user and I've just started using emacs with evil. But one thing I'm finding really hard to understand is when do we use `<C-x>`, `<M-x>` etc. I want to understand **when** to use `Control` or `Meta`.
For example in vim, in normal mode `d` is the delete operator and can be combined with text objects like lines and words. So I'm trying to understand if things like `C-x` is bound to say runtime operations etc.
# Answer
> 1 votes
It's all about conventions, basically `control` is used for basic/normal editing commands (like `C-k` for `kill-line`) , and `meta` for extended commands (like `M-k` for `kill-sentence`).
There are also conventions for the core features, user space/modes, etc. which are explained (mostly) in the manual here, or blog posts like this one which is more easy to follow for people coming from Vim.
---
Tags: key-bindings, modifier-key
---
|
thread-61914
|
https://emacs.stackexchange.com/questions/61914
|
ctrl-backspace behaves differently across emacs environments, though .init file is same
|
2020-11-24T11:26:38.260
|
# Question
Title: ctrl-backspace behaves differently across emacs environments, though .init file is same
I recently needed to start using another mac for work and I wanted to duplicate my spacemacs settings onto my new computer. I simply copied all files located in .emacs onto my new computer, and it seems to be working smoothly (I probably got lucky). There's just one small problem: on my old computer, ctrl-BACKSPACE removes whitespace to the point of the next indentation. For example, in json:
```
{
"name": "David",
"job": "",
}
```
Typing ctrl-BACKSPACE when the cursor is in front of "job" will result in the following (desired)
```
{
"name": "David",
"job": "",
}
```
But on my new computer (same OS), it results in the following:
```
{
"name": ""job": "",
}
```
So it looks like a whole line is being deleted.
Is there an easy fix to make sure the indentation is respected?
I believe the indentation settings are determined by flycheck. I can give my .init file if it will be helpful.
On the working computer, ctrl-backspace is bound to the following:
```
<C-backspace> runs the command clean-aindent--bsunindent (found in
clean-aindent-mode--keymap), which is an interactive compiled Lisp function in
‘clean-aindent-mode.el’.
It is bound to <C-backspace>, M-DEL.
(clean-aindent--bsunindent ARG)
Unindents.
Bound to ‘M-backspace’ key. Searches lines backward, finds the one that
is indented less than the current one. Unindents current line to
align with that smaller indentation
[back]
```
On the new computer, ctr-backspace is bound to the following:
```
<C-backspace> runs the command backward-kill-word (found in global-map), which
is an interactive compiled Lisp function in ‘simple.el’.
It is bound to <C-backspace>, M-DEL.
(backward-kill-word ARG)
Probably introduced at or before Emacs version 22.1.
Kill characters backward until encountering the beginning of a word.
With argument ARG, do this that many times.
[back]
```
# Answer
Use `C-h k` to find out what function `<C-Backspace>` is bound to on the two computers.
After troubleshooting, the solution turns out to be that `clean-aindent-mode` is not installed on the non-working machine.
> 3 votes
---
Tags: spacemacs, indentation, osx
---
|
thread-38841
|
https://emacs.stackexchange.com/questions/38841
|
Counsel M-x always shows "^"
|
2018-02-15T10:52:03.890
|
# Question
Title: Counsel M-x always shows "^"
I installed Counsel/Ivy/Swiper and so far everything works fine. But when I call counsel-M-x via key bind M-x an "^" char is always added. I have no clue why this is happening and how to get rid of it (it does not interfere with the counsel-M-x command, it is just annoying). I'm using emacs on OS X and remapped the Meta key to the Command key `(setq mac-command-modifier 'meta)`, but even with Alt as standard Meta key "^" is automatically inserted when calling counsel-M-x.
I use the basic settings provided here
```
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(global-set-key (kbd "M-x") 'counsel-M-x)
```
# Answer
> 31 votes
`ivy-initial-inputs-alist` is a variable that controls the default minibuffer contents when using ivy (which is used by counsel).
The default `"^"` string means that if you type something immediately after this string only completion candidates that begin with what you typed are shown.
You can remove this default string in `counsel-M-x` command with:
```
(setcdr (assoc 'counsel-M-x ivy-initial-inputs-alist) "")
```
Or to remove this initial input in all commands:
```
(setq ivy-initial-inputs-alist nil)
```
# Answer
> 3 votes
Setting `ivy-initial-inputs-alist` to an empty string for `counsel-M-x` specifically can be done via the `M-x customize-option RET ivy-initial-inputs-alist RET` interface.
Shown here as a lisp-expression
```
'((counsel-minor . "^+")
(counsel-package . "^+")
(counsel-org-capture . "^")
(counsel-M-x . "")
(counsel-describe-symbol . "^")
(org-refile . "^")
(org-agenda-refile . "^")
(org-capture-refile . "^")
(Man-completion-table . "^")
(woman . "^"))
```
---
Tags: search, counsel
---
|
thread-60311
|
https://emacs.stackexchange.com/questions/60311
|
How to enable opentype features in `font-spec`?
|
2020-08-26T04:59:13.603
|
# Question
Title: How to enable opentype features in `font-spec`?
I'm using Emacs 28 (HEAD) on Debian Stable, compiled with `HARFBUZZ` and `cairo` (if that's important).
I'm trying to enable opentype features on the Pragmata Pro font (as shown here).
`(font-spec :family "Iosevka Term SS10" :size 16 :otf '(latn nil nil (dlig))`
`(font-spec :family "Iosevka Term" :size 16 :otf '(latn nil nil (dlig))`
I've tried both of these, with no difference. Emacs does not show me any errors but the extra ligatures don't work.
**Documentation:**
```
font-spec is a function defined in font.c.
Signature
(font-spec ARGS...)
Documentation
Return a newly created font-spec with arguments as properties.
ARGS must come in pairs KEY VALUE of font properties. KEY must be a
valid font property name listed below:
:family, :weight, :slant, :width
They are the same as face attributes of the same name. See
set-face-attribute.
:foundry
VALUE must be a string or a symbol specifying the font foundry, e.g. misc.
:adstyle
VALUE must be a string or a symbol specifying the additional
typographic style information of a font, e.g. sans.
:registry
VALUE must be a string or a symbol specifying the charset registry and
encoding of a font, e.g. iso8859-1.
:size
VALUE must be a non-negative integer or a floating point number
specifying the font size. It specifies the font size in pixels (if
VALUE is an integer), or in points (if VALUE is a float).
:name
VALUE must be a string of XLFD-style or fontconfig-style font name.
:script
VALUE must be a symbol representing a script that the font must
support. It may be a symbol representing a subgroup of a script
listed in the variable script-representative-chars.
:lang
VALUE must be a symbol whose name is a two-letter ISO-639 language
name, e.g. ja. The value is matched against the "Additional Style"
field of the XLFD spec of a font, if it's non-empty, on X, and
against the codepages supported by the font on w32.
:otf
VALUE must be a list (SCRIPT-TAG LANGSYS-TAG GSUB [ GPOS ]) to specify
required OpenType features.
SCRIPT-TAG: OpenType script tag symbol (e.g. deva).
LANGSYS-TAG: OpenType language system tag symbol,
or nil for the default language system.
GSUB: List of OpenType GSUB feature tag symbols, or nil if none required.
GPOS: List of OpenType GPOS feature tag symbols, or nil if none required.
GSUB and GPOS may contain nil elements. In such a case, the font
must not have any of the remaining elements.
For instance, if the VALUE is (thai nil nil (mark)), the font must
be an OpenType font whose GPOS table of thai script's default
language system must contain mark feature.
```
I have tried to use GPOS / GSUB independently. Using GPOS gives me this error on startup:
`Error in private config: config.el, (error invalid font property :otf latn nil dlig (nil))`
Any help is appreciated!
# Answer
I think emacs doesn’t currently have support for controlling otf features. Here are two things though:
You can get default ligatures of the font so long as your font is the “principal” (I don’t know what the right term is here) font of the fontset. You need to convince emacs to compose characters and by default it won’t do this for Latin characters or symbols. To do this you need an appropriate entry in `composition-function-table` to cause `font-shape-gstring` to be called to shape your ligatures. `font-shape-gstring` will go to the principle font of the fontset (maybe a different font, I’m not exactly sure how emacs decides it) and ask it to shape the characters, forming a ligature if the font tells it to. This is only possible if you have emacs \>= 27 and harfbuzz for font shaping (check `features` for harfbuzz and check that your font backend is something like `cairohb` or `xfthb`).
As an extension to this there is some experimental code in emacs for turning on open type features, I think through the same mechanism. It is hidden behind a few `#if 0` blocks and some warnings in `font.c` and you could try enabling it if you’re feeling brave.
> 3 votes
# Answer
I haven't quite gotten this to work either, but one thing I noticed: You're doing `(font-spec :family "Iosevka Term" :size 16 :otf '(latn nil nil (dlig))`, but the docs you quote say that the GSUB list should come before GPOS, and `dlig` is a GSUB kind of thing. So I would expect
```
(font-spec :family "Iosevka Term" :size 16 :otf '(latn nil (dlig) nil))
```
to be more like what you need. Do you have to enable `calt` as well? Does Iosevka Term even have the ligatures, or is it Iosevka Fixed that has *no* odd-width characters (and thus would lack the ligatures).
Like I said, this, alone, has not fixed things for me, but maybe I'm doing something else wrong that you aren't. At least this is something you can improve.
> 2 votes
---
Tags: fonts
---
|
thread-61940
|
https://emacs.stackexchange.com/questions/61940
|
Elpy shell-send-region to a particular named Python buffer
|
2020-11-25T18:50:12.673
|
# Question
Title: Elpy shell-send-region to a particular named Python buffer
I often open up interactive python sessions particular to the project that I'm working on, and will use `M-x rename-buffer` to title them `*Python[Project1]*`, *Python\[Project2\]*\`, etc.
I would like to configure my `C-c C-c` to send to the correct project's buffer.
I know I can use `python-shell-buffer-name . "Python[Project1]")` to set a buffer's name, but what variable do I set to ensure that `C-c C-c` and similar will respect this, versus sending to `*Python*` or to the last used buffer, which may be `*Python[project_wrong]*` ?
I've looked at the following:
# Answer
One way to set temporarily `python-shell-buffer-name` during a function call is to call this function inside a `let` statement that sets `python-shell-buffer-name`.
```
(defun adl/elpy-shell-send-region-or-buffer ()
"Send python- region or buffer to *Python[ PY-BUFFER ]*."
(interactive)
(let ((python-shell-buffer-name (concat "Python[" (file-name-base (buffer-name)) "]")))
(elpy-shell-send-region-or-buffer)))
```
Using the function above instead of `(elpy-shell-send-region-or-buffer)`, you will send the code of `file.py` to a buffer named `*Python[file]*`.
Code from different files with the same name will run in the same buffer.
If you change `(file-name-base (buffer-name))` to `default-directory`, all files from the same directory will run in the same buffer named `*Python[path/to/directory/]*`.
If you change `(file-name-base (buffer-name))` to `(buffer-file-name)`, each file will run in a different buffer named `*Python[path/to/directory/file.py]*`. Note that unsaved buffers, e.g., `*scratch*`, will run in `*Python[]*`.
If none of the above satisfies you, choose a better string :).
You can replace `"C-c C-c"` key binding to the new function (or use other binding):
```
(add-hook 'elpy-mode-hook
(lambda ()
(define-key elpy-mode-map (kbd "C-c C-c") #'adl/elpy-shell-send-region-or-buffer)))
```
> 1 votes
---
Tags: elpy
---
|
thread-5703
|
https://emacs.stackexchange.com/questions/5703
|
Has anyone else encountered gui-get-selection: (error "Timed out...") bug?
|
2014-12-24T10:32:43.073
|
# Question
Title: Has anyone else encountered gui-get-selection: (error "Timed out...") bug?
When trying to paste into Emacs from my Linux system GUI, I'm getting a 10-15 second Emacs freeze and:
```
gui-get-selection: (error "Timed out waiting for reply from selection owner")
```
I would post a bug, except I can't pin-point the condition to reliably reproduce the bug. Has anyone else encountered this? I'm on GNU Emacs 25.0.50.1.
# Answer
The short answer: yes (also with 25.0.50.1).
This might be related to emacs bug 16737.
Try running (shell-command-to-string "xclip -o"). When I attempt this (once emacs has started misbehaving with respect to any attempt to yank), emacs hangs until I kill xclip.
> 3 votes
# Answer
The error message indeed seems to come form xclip! If running 'xclip -o' after a fresh reboot, (i.e. when the clipboard is still empty, ) then the error message appears (gui-get-selection: (error "Timed out waiting for reply from selection owner")).
Workaround: Ctrl+C anything
> 0 votes
---
Tags: linux
---
|
thread-58377
|
https://emacs.stackexchange.com/questions/58377
|
Package that links words as they are typed to existing org-files/-headers?
|
2020-05-08T19:24:16.503
|
# Question
Title: Package that links words as they are typed to existing org-files/-headers?
A silly question.
I try to link my org-files more closely together. I looked into org-roam and org-brain but i'm not convinced that these packages provide what i have in mind (haven't tested it).
As an example what i mean. When i write following sentence in org-mode:
```
I go to school every monday.
```
That as soon as i hit `SPC` after the word `school` that `school` is linked to the file `school.org` or org-header `* School`. Of course it would search in a default directory or so.
Is there a package providing such functionality in org-mode?
# Answer
Solved it be adding small customization at various places. I now use a combination of a custom-org-store-link, custom-id-completion and custom company-backend (`company-org-bookmark`) combined with a custom bookmark+ type:
```
(defvar company-org-bookmark-available 'unknown)
(defun company-org-bookmark-available ()
"When bookmarks successfully loaded will return non-nil."
(when (eq company-org-bookmark-available 'unknown)
(condition-case err
(progn
(list-bookmarks)
(setq company-org-bookmark-available (not (null bookmark-alist))))
(error
(message "Company-Org-Bookmark: %s" (error-message-string err))
(setq company-org-bookmark-available nil))))
company-org-bookmark-available)
(defun company-org-bookmark--lookup-words (word)
"Filter bookmark-alist by WORD and return candidates."
(all-completions word bookmark-alist))
;;;###autoload
(defun company-org-bookmark (command &optional arg &rest _ignored)
"`company-mode' completion backend using bookmark-alist."
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-org-bookmark))
(prefix (when (company-org-bookmark-available) (company-grab-word)))
(candidates
(let ((words (company-org-bookmark--lookup-words arg))
(completion-ignore-case t))
words))
(post-completion
(kill-backward-chars (length arg))
(insert (concat "[[" "id:" (cadr (caddr (bookmark-prop-get arg 'function))) "]" "[" arg "]]")))
(kind 'text)
(sorted t)
(ignore-case 'keep-prefix)))
(defun myfunc-bmkp-make-org-id-bookmark ()
"Used to create bookmarks to org-header identified by ID-Property."
(interactive)
(cond ((derived-mode-p 'org-mode)
(let* ((hid (org-id-get-create))
(bn (org-link-display-format (org-get-heading t t t t)))
(bm-bn (bmkp-get-bookmark bn 'NOERROR)))
(org-store-link nil t)
(when (not (null bm-bn))
(setq bn (concat bn
" (" (file-name-nondirectory buffer-file-name)
":" (number-to-string (line-number-at-pos))
")")))
(if (and bm-bn
(equal hid (cadr (caddr (bookmark-prop-get bm-bn 'function)))))
bm-bn
(bmkp-make-function-bookmark bn (backquote (lambda () (org-id-goto ,hid)))))))))
(define-key global-map (kbd "C-c l") 'myfunc-bmkp-make-org-id-bookmark))
(setq company-backends '(company-org-bookmark)) ; beaware all backend deleted, you probably need to adjust this!
```
The backend is currently case sensitive. When I want to manually link something. I have following in place:
```
(defun myfunc-org-id-complete-link (&optional arg)
"Create an id: link using completion"
(concat "id:" (org-id-get-with-outline-path-completion '((org-agenda-files . (:maxlevel . 9))))))
(defun myfunc-id-description-function (link desc)
"Generate description for links"
(interactive)
(cond (desc desc)
((region-active-p) (progn (buffer-substring (region-beginning) (region-end))))
((string-prefix-p "id:" link)
(save-window-excursion
(save-excursion
(org-id-goto (string-remove-prefix "id:" link))
(org-get-heading t t t t))))
(t (save-excursion (word-at-point)))))
(setq org-link-make-description-function 'myfunc-id-description-function)
(setq org-link-set-parameters "id" :complete 'myfunc-org-id-complete-link)
```
When calling `org-insert-id` with `C-C C-l` and choose an `id:`-link it prompts for a target with completion of all headings that exist in `org-agenda-files`. When a header hasn't already got an ID, it will be created automatically as it is chosen. Beaware, this won't add the header to the bookmarks which would be necessary for the company-backend.
Hope it helps!
> 0 votes
# Answer
You can use Radio Links for this. I use them quite a bit. Here's an excerpt with an example from the org-mode manual.
---
For example, a target `<<<My Target>>>` causes each occurrence of ‘my target’ in normal text to become activated as a link.
I found some more answers in another stack exchange answer.
In this one a glossary is included as a list definition, which pairs radio links for acronyms, with the definition being a link, possibly to another file
```
* List of Acronyms
- <<<ABI>>> :: Application Binary Interface
- <<<API>>> :: Application Programming Interface
- <<<DOR>>> :: Documentation Requirement
:PROPERTIES:
:TAGS: requirement
:END:
Anything related to documentation it self not the specific content like "documents must be in a diff-able format".
- <<<HTML>>> :: HyperText Markup Language
Almost everyone knows this nowadays :)
```
> 3 votes
---
Tags: org-mode, org-link
---
|
thread-61988
|
https://emacs.stackexchange.com/questions/61988
|
error in process filter: No email account found
|
2020-11-28T15:14:30.060
|
# Question
Title: error in process filter: No email account found
I use Emacs 27.1 (9.0) and `mu4e 1.4.13` with multiple email accounts, and those email accounts have one main username and multiple aliases. Recently I started getting this error when replying to an email sent to an alias:
```
error in process filter: if: No email account found
error in process filter: No email account found
```
Before, I used to be able to reply to an alias and the reply would come from the main username.
How can I fix it?
# Answer
I changed the name of the account from the capitalized name, which was on disk, to lowercase, and that caused the problem. Reverting it back to capitalized fixed it.
Problematic code:
```
(defvar my-mu4e-account-alist
'(
("provider" ;; lower case!
(mu4e-sent-folder "/Provider/Sent Items")
...
```
Fixed code:
```
(defvar my-mu4e-account-alist
'(
("Provider" ;; capitalized!
(mu4e-sent-folder "/Provider/Sent Items")
...
```
> 0 votes
---
Tags: mu4e
---
|
thread-19382
|
https://emacs.stackexchange.com/questions/19382
|
GMail 2-factor auth without application-specific password
|
2016-01-09T09:43:17.493
|
# Question
Title: GMail 2-factor auth without application-specific password
Is there any way I can read mail with emacs that comes from a gmail account protected with compulsory 2-factor auth? Application-specific passwords are disabled for GMail by my employer. So I can't use the usual workaround of setting an application-specific password.
Google says that Apple Mail and iOS are able to do this, but doesn't explain how. And I know that Apple Mail works because one of my colleagues uses it.
Ideally I want to use IMAP, so that I can read emails from my phone too.
BTW, this is not Google's 2 factor auth but a third-party SSO provider.
# Answer
> 6 votes
Google Mail uses a proprietary—it doesn't appear to be standardised nor used anywhere else—SASL extension named XOAUTH2 to support OAuth 2.0 tokens for SMTP/IMAP authentication. See IMAP and SMTP for more information about these extensions. These OAuth tokens are supplied by the Google Identity Platform API which—among other things—provides the familiar Google Login screen you see everywhere Google is used for authentication.
All of this is proprietary, albeit publicly accessible. As such, I doubt that any Emacs mail client has support for SASL XOAUTH2, let alone for Google Identity signin.
I am afraid that without application specific passwords you'll not be able to use an Emacs mail client for Google Mail out of the box.
You'll have to sit down, work through the API documentation, and write a significant non-trivial amount of code to hook this authentication API into Gnus or whatever other mail client and MTA you use.
# Answer
> 1 votes
For those who find this question because of:
> Warning: Opening nnimap server on gmail...failed: NO (ALERT) Application-specific password required: https://support.google.com/accounts/answer/185833 (Failure); Server nnimap+gmail previously determined to be down; not retrying
and don't try to go XOAUTH2 path (as OP wanted) following instructions in the error helps to avoid it.
So following https://myaccount.google.com/apppasswords I generated "Other" type password for Emacs IMAP/SMTP and updated my `~/.authinfo`:
```
machine imap.gmail.com login me@gmail.com password ROBO
machine smtp.gmail.com login me@gmail.com password ROBO
```
You can force Gnus to reload configs with `r` (or `M-x gnus-group-read-init-file`).
# Answer
> 0 votes
It should be possible to use offlineimap master to download the mails, and then any emacs mail client that works with offlineimap, to view them. However, this will not allow sending emails using the correct SMTP server, so it is at best a partial solution.
---
Tags: gnus, wanderlust, imap
---
|
thread-60520
|
https://emacs.stackexchange.com/questions/60520
|
How to add a new input method for Syriac script in Emacs?
|
2020-09-06T09:20:21.857
|
# Question
Title: How to add a new input method for Syriac script in Emacs?
I want to write an article in English mingled with Syriac script in emacs, when I hit `list-input-methods` the script is not shown, or at least I couldn't identify this language in the displayed list. However, I am using a machine running Linux Ubuntu and I could add that language keyboard easily and it is designated `Syriac` or `syc`. I could use the same script in LibreOffice Writer using specific fonts for this language. My question how to add a new input method for this language in my init.el file? I would be very grateful for your help and directions to achieve this goal.
In this EmacsWiki I could find input methods for ancient languages, but again I couldn't see one for Syriac. It is just hard to believe that Syriac language given its dominance in history could not get similar attention.
The Syriac language is from right-to-left language and it has the `iso 15924` designation in UTF-18 and it has the unicod range
U+0700–U+074F Syriac
U+0860-U+086F Syriac
more info here
**Update**
my `init.el` setup for Hebrew language (again Right-to-Left) input method is shown below, this way I could still use Emacs keystrokes (shortcuts) regardless of whatever language you use which is the desired outcome. Otherwise, I would switch back and forth between languages in Linux Hebrew while writing and English then to use Emacs keystrokes which otherwise won't work when Hebrew is in place so I have to I switch keyboards quite often during writing making it impractical and very annoying for writing multilingual documents. The code below will allow me write Hebrew using Emacs keystrokes seamlessly and no need to bother with switching languages back and forth to use these keystrokes:
```
(set-fontset-font "fontset-default" 'hebrew "SBL BibLit-14" nil)
(defun hebrew-input-font ()
"Change the `set-input-method` to Hebrew and select another font assigned to \\C-\\c h."
(interactive)
(set-input-method "hebrew-biblical-tiro"))
(bind-key "<f2> h" 'hebrew-input-font)
```
# Answer
> 4 votes
It should be sufficient to put the following in a `.el` file and load it upon startup:
```
(quail-define-package
"Syriac-trans" "Ar-trans" "S>" t
"Input method for Syriac transcription."
nil t nil nil nil nil nil nil nil nil t)
(quail-define-rules
("'" ?ܐ)
("b" ?ܒ)
("g" ?ܓ)
("d" ?ܕ)
("h" ?ܗ)
("w" ?ܘ)
("z" ?ܙ)
("x" ?ܚ)
("t." ?ܛ)
("y" ?ܝ)
("k" ?ܟ)
("l" ?ܠ)
("m" ?ܡ)
("n" ?ܢ)
("s" ?ܣ)
("`" ?ܥ)
("p" ?ܦ)
("s." ?ܨ)
("q" ?ܩ)
("r" ?ܪ)
("sh" ?ܫ)
("t" ?ܬ))
```
Then you can select the input method with `M-x set-input-method RET Syriac-trans RET`. This only contains the consonants, you'd need to add more rules for diacritics.
You may also want to change the actual keys you need to type for specific letters (e.g., `'` for ܐ and ``` for ܥ may not be practical). Note that you may specify sequences of two or even more keys to type a specific Syriac letter, as I've done with `t.` for ܛ, `s.` for ܨ and `sh` for ܫ.
# Answer
> 0 votes
If your system keyboard inserts unicode characters for Syriac and you have fonts that cover the required codepoints you might not need a dedicated input method in emacs.
Try defining the relevant fonts for the range in emacs...
```
(let ((syriac-1 (font-spec :family "Syriac Serto"))
(syriac-2 (font-spec :family "Estrangelo Edessa")))
(set-fontset-font t '(#x0700 . #x074F) syriac-1)
(set-fontset-font t '(#x0860 . #x086F) syriac-2))
```
And if you are mixing left-to-right and right-to-left text in the same document, the section of the manual on Bidirectional Editing is worth reading.
However, if you do want to create a new input method you could start with an existing one (e.g. Glagolitic) and change the mapping rules to fit with Syriac transliteration.
# Answer
> 0 votes
There are several issues here:
1. Detecting and setting the language: I'd search in lisp/language and probably need to add entries in lisp/international/ especially characters.el and fontset.el
2. Keyboard layout: In case your OS doesn't provide one, you can define one or more in lisp/leim/quail
3. The most challenging effort would be proper composing of initial/medial/final forms. You should follow Arabic model.
---
Tags: input-method, script
---
|
thread-60998
|
https://emacs.stackexchange.com/questions/60998
|
org mode: help!! i’ve collapsed my section and can’t get it back out
|
2020-10-05T20:23:04.773
|
# Question
Title: org mode: help!! i’ve collapsed my section and can’t get it back out
I am using `spacemacs`. This may seem like a joke, but it really is not (but it is kind of funny).
I was typing in org-mode just now, I may have hit some `god-mode key`, and the section I am typing in now ***collapsed into its header*** and **I cannot uncollapse/expand it back open**.
1. Updated typing happens invisibly, but I can’t see anything.
2. My text is still there, because I can see the diff output.
3. Re-loading my saved (spacemacs) layout does nothing.
• I know this is simple, but a google did not reveal anything.
• Hitting `tab` or `Enter` on the section header **does nothing**.
Pls help V.V
# Answer
If you toggle on `M-x visible-mode` you would be able to see all of the text, and probably fix the problem.
(Switch the mode off once you're done, to allow org's visibility rules to take effect again.)
> 3 votes
# Answer
There are 2 other quick things to try:
1. `C-q` will exit a mode you may have accidentally entered
2. `ESC-u` to undo what you were typing ... but beware if you don't save frequently with `:w`\- although you could `ESC C-r` to redo if too much is undone.
> 0 votes
---
Tags: org-mode, spacemacs
---
|
thread-61998
|
https://emacs.stackexchange.com/questions/61998
|
Deleting remote branches using Magit
|
2020-11-29T11:36:10.373
|
# Question
Title: Deleting remote branches using Magit
I want to delete a remote branch. How can I do `git push origin --delete my-branch` in magit, to delete a remote branch?
# Answer
In Magit the command for deleting a remote branch is the same as for deleting a local branch, and its key binding is `b k`.
So to delete `my-branch` on `origin` you would type `b k` `origin/my-branch` `RET`.
---
Deleting the remote branch `origin/feature` involves two steps:
1. Actually deleting the branch on the remote repository.
2. Updating the cache in the local repository, which keeps track of the state of the remote repository.
Deleting a remote branch does **not** delete the corresponding local branch, `feature`. I.e., the local ref `refs/heads/feature` is not being deleted. What is being deleted is the "remote-tracking branch", represented in the local repository by the ref `refs/remotes/origin/feature`, which is a reference to the state of the remote branch.
There likely is a relationship between the branch `feature` and the remote-tracking branch `origin/feature`, but deleting one does not cause the other to be deleted. However `refs/remotes/origin/feature` is how the local repository keeps track of "`feature` on `origin`", so deleting the former should go in hand with deleting the latter.
When you delete a remote branch In Magit, then it prompts with `Delete origin/feature on the remote (not just locally)?`. The "not just locally" was added because a user might expect that only `refs/remotes/origin/feature` is deleted but not "`feature` on `origin`".
Deleting only `refs/remotes/origin/feature` only makes sense in very rare situations. Doing so would essentially make the local cache of the remote state incorrect and later fetching from the remote again would fix that defect, i.e., `refs/remotes/origin/feature` would be recreated.
Yet, some users expected, that that is what "deleting a remote branch" would do, so the warning was added. Unfortunately that warning led other users to believe that deleting a remote branch also causes the local branch to be deleted.
> 2 votes
---
Tags: magit
---
|
thread-61993
|
https://emacs.stackexchange.com/questions/61993
|
How can I sort Org headings by value in :properties:
|
2020-11-28T23:36:37.000
|
# Question
Title: How can I sort Org headings by value in :properties:
My org file structure is this:
```
* Heading 1
:PROPERTIES:
:EVENT_CREATED: [2016-11-28]
:END:
* Heading 2
:PROPERTIES:
:EVENT_CREATED: [2016-10-27]
:END:
* Heading 3
:PROPERTIES:
:EVENT_CREATED: [2019-02-08]
:END:
```
I essentially want to sort each all headings by the `EVENT_CREATED` property, so that they are on chronological order.
# Answer
> 1 votes
Here's some code to do the sorting - it assumes the corrected version of your example, that you are using inactive timestamps for the values of the `EVENT_CREATED` property for each header and that every top-level node contains an `EVENT_CREATED` property:
```
(defun ndk/get-key ()
(org-time-string-to-seconds (substring (org-entry-get (point) "EVENT_CREATED") 1 -1)))
(defun ndk/cmp (t1 t2)
(< t1 t2))
(defun ndk/org-sort-entries ()
(interactive)
(org-sort-entries nil ?f #'ndk/get-key #'ndk/cmp))
```
You can add these function definitions to your init file, or load them from a file or evaluate them in your `*scratch*` buffer.
To use them, select the region that you want to sort in the usual way and say `M-x ndk/org-sort-entries`.
This sorts in ascending order. If you want descending order, change the `?f` to `?F` in the definition of `nkd/org-sort-entries`. For more details, see the doc string for `org-sort-entries` with `C-h f org-sort-entries RET`.
Some notes:
* the `ndk/get-key` function is called at the beginning of each entry. It retrieves the value of the property, strips the initial and final square brackets and converts the string to a UNIX time in seconds (since the "epoch", 1970-01-01 00:00:00).
* the convention of using inactive timestamps for the values of the `EVENT_CREATED` property allows the use of the already existing Org mode function `org-time-string-to-seconds` to convert to a float that can be easily used in comparisons when sorting.
* the convention also allows easy entry of the property value: `C-c C-x p` asks you for the property name (and probably already has `EVENT_CREATED` filled in, so all you have to do is press RET here) and then asks you for the property value, which you can enter with `C-c ! RET` to give it an inactive timestamp with the current date. This has nothing to do with the sorting, but it is one reason that I recommended you use inactive timestamps as values in the first place.
---
Tags: org-mode, sorting
---
|
thread-62006
|
https://emacs.stackexchange.com/questions/62006
|
How to update emacs on MS Windows?
|
2020-11-29T21:09:59.057
|
# Question
Title: How to update emacs on MS Windows?
I have installed emacs 2-3 years ago. The version I'm using now is `25.2.1`. I want to update it to the latest version, which is `27.1`. I uninstalled it and then installed again to no avail, it is the same old version. I have googled it, read a few sites, even came over StackOverflow question. None of those sources was helpful. Also, when installing it, I do it so via `MSYS`. That `MSYS` also shows `MinGW` things when it installs. I also looked at `path` in Environment variables in MS Windows Settings. I don't understand those things; neither `path` nor `MSYS` or `MinGW` is comprehensible for an amateur like me. So, can you help me and other future amateurs who will look here for help?
How can I upgrade to latest emacs on Windows?
I'm using Windows 10 64-bit. Thanks.
# Answer
You can download an MS Windows binary for the latest Emacs release (27.1) here:
https://ftp.gnu.org/gnu/emacs/windows/emacs-27/
It sounds like you probably want one of the "64" ones. I use this one:
* emacs-27-deps-mingw-w64-src.zip
But do read the README first: README-windows-binaries.
> 1 votes
---
Tags: microsoft-windows, upgrade
---
|
thread-62000
|
https://emacs.stackexchange.com/questions/62000
|
org verse blocks: indentation not preserved on export to odt
|
2020-11-29T15:32:15.693
|
# Question
Title: org verse blocks: indentation not preserved on export to odt
the org manual says "To preserve the line breaks, indentation and blank lines in a region, but otherwise use normal formatting" you can use `#+begin_verse #+end_verse` block.
if i run `emacs -Q`, open a new file, add this example:
```
#+BEGIN_VERSE
Great clouds overhead
Tiny black birds rise and fall
Snow covers Emacs
---AlexSchroeder
#+END_VERSE
```
then export to odt using the dispatch with not alternate odt styles file specified, the output in odt looks like this:
```
Great clouds overhead
Tiny black birds rise and fall
Snow covers Emacs
---AlexSchroeder
```
i.e. a space is inserted at the beginning of every new line except the first.
this problem does not appear if you have `#+options: \n:t` set, but that using option breaks indentation on export for me too (it reduces all indentations to a single space).
# Answer
> 1 votes
\[Not quite an answer, but too long for a comment - plus I can use code blocks to illustrate the problem and a suggested patch to Org mode for it.\]
It's not clear (to me at least) what Org mode should be doing differently: it does not produce the extra spaces in LaTeX or HTML output, and it does not produce any extra spaces in the XML file that it produces for ODT output either - here's what you see if you open the ODT archive and look at the `contents.xml` file inside it:
```
<text:p text:style-name="OrgVerse">Great clouds overhead<text:line-break/>
Tiny black birds rise and fall<text:line-break/>
Snow covers Emacs<text:line-break/>
<text:line-break/>
<text:s text:c="2"/>—AlexSchroeder<text:line-break/>
</text:p>
```
Why `soffice` displays this with spaces at the beginning of the second and subsequent lines is a mystery to me, but there does not seem to be anything that can be done about it on the Org mode side, other than translating it to some different XML: if you know *what* it should be translating it into, you should probably file a bug report with `org-submit-bug-report`.
(Later): By trial and error, I discovered that if you open the ODT archive in emacs and edit the `contents.xml` file to look like this:
```
<text:p text:style-name="OrgVerse">Great clouds overhead<text:line-break/>Tiny black birds rise and fall<text:line-break/>Snow covers Emacs<text:line-break/><text:line-break/> <text:s text:c="2"/>—AlexSchroeder<text:line-break/>
</text:p>
```
eliminating the explicit newlines, then it is shown without initial spaces.
I would suggest that you try the following patch to Org mode:
```
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index ef07acfed..658c5949a 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -3676,8 +3676,9 @@ contextual information."
;; Replace leading tabs and spaces.
"^[ \t]+" #'org-odt--encode-tabs-and-spaces
;; Add line breaks to each line of verse.
- (replace-regexp-in-string
- "\\(<text:line-break/>\\)?[ \t]*$" "<text:line-break/>" contents))))
+ (replace-regexp-in-string "\n" ""
+ (replace-regexp-in-string
+ "\\(<text:line-break/>\\)?[ \t]*$" "<text:line-break/>" contents)))))
```
It's just a rough approximation at the moment, but it should take care of the initial spaces on the haiku lines, although it mangles the spaces in front of the em-dash.
---
Tags: org-mode, org-export, exporting
---
|
thread-62001
|
https://emacs.stackexchange.com/questions/62001
|
How can we get input using emacs?
|
2020-11-29T16:22:53.497
|
# Question
Title: How can we get input using emacs?
In order to compile my lua code i use this config
```
(defun lua-main-compile ()
"use lua to compile my lua code"
(interactive)
(compile "lua main.lua"))
```
In my lua code when i type
```
x = 10
io.write("Enter the name of the variable you want to be printed: ")
index = io.read()
f = loadstring("return " .. index)
print(f())
```
when I use this the `*compilation*` buffer opens and I get `Enter the name of the variable you want to be printed:` which is good. But I can not input there (as I understand I only type `q` there). What must I do?
# Answer
One thing you can try is to use `async-shell-command`.
Tested with the following and works:
```
(async-shell-command "python3 -c 'print(input(\"Test: \"))'")
```
> 0 votes
---
Tags: key-bindings, buffers, debugging, regular-expressions
---
|
thread-61987
|
https://emacs.stackexchange.com/questions/61987
|
Leave evil's insert state with Control + c
|
2020-11-28T14:11:33.777
|
# Question
Title: Leave evil's insert state with Control + c
I would like to be able to leave the insert state (I think that's what it's called in emacs?) using the Ctrl+c combination I know from vim. I'm using doom-emacs in case that's important, and I'm completely new to emacs.
# Answer
Ex-vimmer also. As Dan pointed out in the comment of OP, binding to `C-c` is too devastating in emacs. What I do is instead binding to `C-c C-c` so I can hit `C-c` like a crazy person to get back to normal. (Just like hitting `C-s` 10 times is the proper way to save MS Word documents, I do this a lot: `C-c C-c C-c ... C-c C-g C-g ... C-g` to make sure I'm in normal state)
```
(define-key evil-insert-state-map (kbd "C-c C-c") 'evil-normal-state)
(define-key evil-normal-state-map (kbd "C-c C-c") 'evil-normal-state)
```
Note, this has a downside though (not very serious or often encounterd), is that you would override some useful `C-c C-c` bindings from famous packages, like `org-ctrl-c-ctrl-c` in org-mode, as well as several cases for magit. It's not serious in the sense that I use Spacemacs which also binds these common `C-c C-c` cases to `, ,` for `evil-normal-state`, so I'm not really missing anything important. In your case you are using doom-emacs, which is somewhat influenced by Spacemacs, it might also have provided a nice keybinding alternative already. If not, nothing can stop you from rebinding some `C-c C-c` cases yourself.
> 2 votes
---
Tags: key-bindings, evil, doom
---
|
thread-62012
|
https://emacs.stackexchange.com/questions/62012
|
Log Tramp traces to a file
|
2020-11-30T06:24:07.837
|
# Question
Title: Log Tramp traces to a file
I am experiencing some Emacs Tramp connection problems and want to ask for help. However in my case Emacs hangs completely because of Tramp and there is no way I can access Tramp **debug** files. (it is not responsive to Ctrl-g)
Is there a way to log those trace to a file?
PS I am aware of this question. However the answer accepted there completely ignores the request to log to a file and suggests to interrupt the process with Ctrl-g.
Thanks,
# Answer
> 3 votes
Very good question. Currently it is not supported by Tramp, but I take it as feature request, and I will work on it next days. Shouldn't be too hard to implement.
---
Tags: debugging, tramp
---
|
thread-55255
|
https://emacs.stackexchange.com/questions/55255
|
Remove multiple elements from a list
|
2020-02-02T19:24:18.113
|
# Question
Title: Remove multiple elements from a list
Given `'(a b c d)`, how would I remove `b` and `c` to end up with `'(a d)`? Is there a "right" way to remove multiple, distinct elements from a list?
Obviously, one could do `(delete 'c (delete 'b '(a b c d)))`. But this doesn't generalize or scale well<sup>1</sup>.
Other possibilities include:
* Create a predicate function and map it over the list with something like `delete-if-not`.
* Perform a set difference (if that's even different from the list mapping)
I am getting lost in all the different implementations which accomplish, so it seems, the same thing (i.e. `delete`, `dash`, `seq`, `cl-delete`, etc.).
I would prefer to only use whatever ships with vanilla Emacs (26.3), unless there is a compelling reason to introduce an external dependency.
---
<sup>1</sup> I understand the distinction between `remove` and `delete` in that one preserves the original list while the other does not. It's my impression that the two are more or less interchangeable otherwise.
# Answer
What about `seq-remove` from `seq.el`, which shipped with Emacs 25?
```
(require 'seq)
(let ((l '(a b c d)))
(seq-remove (lambda (x) (memq x '(b c)))
l)) ; (a d)
```
Or, if you just have a list of elements to exclude, `seq-difference` from the same package?
```
(let ((l '(a b c d)))
(seq-difference l '(b c))) ; (a d)
```
See `(info "(elisp) Sequence Functions")` for more information.
> 5 votes
# Answer
See cl-set difference.
```
(cl-set-difference '(a b c d e f) '(b d))
```
It might help.
https://www.gnu.org/software/emacs/manual/html\_node/cl/Lists-as-Sets.html
> 3 votes
# Answer
You can also use `cl-remove-if` or `cl-delete-if`, with a predicate such as
```
(lambda (x) (memq x '(b c))
```
Or whatever other test you want (e.g. `member`). There are also functions `cl-remove-if-not` and `cl-delete-if-not`.
> 2 votes
# Answer
We can reduce over the list of elements you want to remove, and each time through, remove that element from the seq.
```
ELISP> (cl-reduce (lambda (seq elt) (delete elt seq))
'(b c)
:initial-value '(a b c d))
(a d)
```
Using a helper function from dash, which reduces the code somewhat:
```
ELISP> (cl-reduce (-flip #'delete)
'(b c)
:initial-value '(a b c d))
(a d)
```
> 1 votes
# Answer
Withouth loading any library
```
(setq mylist '(a b c d))
(let ((shorter (copy-sequence mylist)))
(dolist (elt '(b c) shorter)
(setq shorter (delete elt shorter))))
```
returns
```
(a d)
```
> 1 votes
---
Tags: list
---
|
thread-62014
|
https://emacs.stackexchange.com/questions/62014
|
command run in docker-tramp running on the host rather than remote
|
2020-11-30T12:45:15.163
|
# Question
Title: command run in docker-tramp running on the host rather than remote
The setup:
I have a docker container connected with a mounted volume containing an org file. The docker container has both texlive and emacs (configured exactly the way it is on my host) installed. I can open the org file and run `org-latex-preview` on the math components without any problems.
The problem:
I recently installed docker-tramp and figured I wouldn't need a separate installation of emacs in my docker containers. However, when I opened the same org file and ran `org-latex-preview` I got the following message in the `*Org Preview LaTeX Output*` buffer:
```
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
! I can't find file `/tmp/orgtextfP6YZ.tex'.
<*> /tmp/orgtextfP6YZ.tex
(Press Enter to retry, or Control-D to exit)
Please type another input file name
! Emergency stop.
<*> /tmp/orgtextfP6YZ.tex
No pages of output.
Transcript written on /tmp//texput.log
```
Now the `orgtextfP6YZ.tex` file is not in the docker container's `/tmp` folder; however, it has been generated in the *host's* `/tmp` folder. So the command that `org-latex-preview` uses (`dvipng`) accesses the host's `/tmp` folder, which means that `dvipng` was run on the host rather than the remote (docker container).
When I'm using a buffer I accessed through docker-tramp, any command I call using `M-!` runs in the remote. So how do I configure it (or TRAMP in general) so that commands used indirectly (called by a function in emacs) are also run in the remote?
# Answer
> 0 votes
See the function `org--latex-preview-region`. There's the comment
```
;; Emacs cannot overlay images from remote hosts. Create it in
;; `temporary-file-directory' instead.
```
Running on a remote host is disabled by intention.
OTOH, everything you start with `M-!` (or `M-&`) is given to a shell, which can run also remotely.
---
Tags: org-mode, tramp, preview-latex, docker
---
|
thread-62018
|
https://emacs.stackexchange.com/questions/62018
|
Why can't I type a dollar sign in this latex equation?
|
2020-11-30T18:58:19.637
|
# Question
Title: Why can't I type a dollar sign in this latex equation?
Consider the following `latex` document.
```
\documentclass{article}
\usepackage{tikz}
\begin{document}
Consider the following picture.
\[
\begin{tikzpicture}
\node (X) {X}; % this X should be enclosed in a dollar sign to be in math mode
\node[right of= X] (Y) {Y}; % this Y should be enclosed in a dollar sign to be in math mode
\draw[->] (X.east) -- (Y.west);
\end{tikzpicture}
\]
\end{document}
```
I want to enclose the `X` and `Y` in the `tikzpicture` environment with dollar signs (because I want them typeset in math mode). However, when I attempt to do so, emacs throws an error in the minibuffer reading `Math mode started with '\[' cannot be closed with dollar`.
What's wrong here?
I'm using `GNU Emacs 27.1` with `AUCTeX-version 12.3.1`.
Note that this is *not* a latex question since my desired code (below) compiles fine in latex.
```
\documentclass{article}
\usepackage{tikz}
\begin{document}
Consider the following picture.
\[
\begin{tikzpicture}
\node (X) {$X$};
\node[right of= X] (Y) {$Y$};
\draw[->] (X.east) -- (Y.west);
\end{tikzpicture}
\]
\end{document}
```
# Answer
> 2 votes
AucTeX redefines the binding for `$` to be the command `TeX-insert-dollar`. That command checks whether you are in a math environment already and complains if you try to close it the "wrong" way. Doing `C-h f TeX-insert-dollar` shows you the doc string of the function:
```
Insert dollar sign.
If current math mode was not entered with a dollar, refuse to
insert one. Show matching dollar sign if this dollar sign ends
the TeX math mode and ‘blink-matching-paren’ is non-nil.
When outside math mode, the behavior is controlled by the variable
‘TeX-electric-math’.
With raw C-u prefix, insert exactly one dollar
sign. With optional ARG, insert that many dollar signs.
```
Note the part that says: **If current math mode was not entered with a dollar, refuse to insert one.**
BTW, it's not clear to me what the `\[ ... \]` delimiters are buying you. If you get rid of them, then AucTeX will not complain about the `$` signs, and you still have a centered display. CORRECTION: It's not centered but you can do that with `\begin{center}...\end{center}` and you'll have to add some space before and after it perhaps.
Alternatively, keep the display but change the font of the text of the nodes:
```
\[
\begin{tikzpicture}[every text node part/.style={font=\itshape}]
\node (X) {X};
\node[right of= X] (Y) {Y};
\draw[->] (X.east) -- (Y.west);
\end{tikzpicture}
\]
```
And yet another way, closer in spirit to the `$...$` method but without resorting to `$` signs:
```
\[
\begin{tikzpicture}
\node (X) {\ensuremath{X}};
\node[right of= X] (Y) {\ensuremath{Y}};
\draw[->] (X.east) -- (Y.west);
\end{tikzpicture}
\]
```
---
Tags: latex, auctex
---
|
thread-62023
|
https://emacs.stackexchange.com/questions/62023
|
How to get the real line number of a selection?
|
2020-11-30T23:50:10.170
|
# Question
Title: How to get the real line number of a selection?
I am trying to figure out the line numbers referring to the actual selection. What I came up with is something like this
```
(let ((start (line-number-at-pos (region-beginning)))
(end (line-number-at-pos (region-end))))
(ignore))
```
But if I select whole lines then `(region-end)` returns the position of the beginning of the next line instead of the end of the currently selected line.
If I am selecting anything but complete lines then the `(region-end)` function works correctly. Is there a way to get the real line number or to figure out whether the user is selecting complete lines or not?
I would like to differentiate between these those:
### Selecting lines
Expected output `1` and `2`.
### Selecting blocks
Expected output `1` and `3`.
# Answer
> 1 votes
Maybe check if region-end and the beginning of the line at region-end are the same position, and if so, subtract one from the end line number? Something like this perhaps:
```
(defun test-linenos ()
(interactive)
(let* ((rend (region-end))
(startl (line-number-at-pos (region-beginning)))
(endl (line-number-at-pos rend))
(real-endl (if (= rend (save-excursion (goto-char rend) (beginning-of-line) (point)))
(- endl 1)
endl)))
(message (format "%d %d" startl real-endl))))
```
You can mark a region and call the function with `M-x test-linenos` to check what line numbers it produces. Of course, only the calculation is important: the function is just scaffolding for testing.
Note that I used a `let*` form, since I wanted to calculate the region end once, but use its value later when binding the following variables. That is explained in Local variables in the Emacs Lisp manual.
BTW, your `let` is badly formed: see the reference above for the proper format:
```
(let ((var val)
(var val)
...
(var val))
...use the variables...)
```
---
Tags: region, line-numbers, doom
---
|
thread-34809
|
https://emacs.stackexchange.com/questions/34809
|
elisp - print result not found after eval-buffer
|
2017-08-10T20:45:38.613
|
# Question
Title: elisp - print result not found after eval-buffer
Create a `test.el` file as below:
```
(print "hello world!")
```
Then run `M-x eval-buffer`. No output can be seen even in `*Messages*` buffer. where is the print output for this case?
# Answer
> 3 votes
Nowhere. See the docstring (`C-h f eval-buffer`):
> (eval-buffer &optional BUFFER PRINTFLAG FILENAME UNIBYTE DO-ALLOW-PRINT)
>
> Execute the accessible portion of current buffer as Lisp code. ...
>
> PRINTFLAG controls printing of output by any output functions in the evaluated code, such as ‘print’, ‘princ’, and ‘prin1’: a value of nil means discard it; anything else is the stream to print to. See Info node ‘(elisp)Output Streams’ for details on streams.
>
> ...
>
> DO-ALLOW-PRINT, if non-nil, specifies that output functions in the evaluated code should work normally even if PRINTFLAG is nil, in which case the output is displayed in the echo area.
# Answer
> 1 votes
```
(message "hello world!")
```
will print `hello world!` to the echo area. That's the same space that's used by the minibuffer: echo area for output, minibuffer for input.
---
Tags: eval, print
---
|
thread-62026
|
https://emacs.stackexchange.com/questions/62026
|
Prevent dired recenter buffer when reverting buffer
|
2020-12-01T04:33:42.300
|
# Question
Title: Prevent dired recenter buffer when reverting buffer
When a directory contains many files, more than the visible lines of the window, use `end-of-buffer` to go to end of buffer, then press `g` to revert-buffer, one can see the last line is recentered to the middle of the window.
How I can prevent this?
# Answer
`g` reverts the Dired buffer. It invokes function `revert-buffer`, which uses the function bound to variable `revert-buffer-function`. In a Dired buffer, that function is `dired-revert`.
Following what `dired-revert` does (e.g. using `debug-on-entry`) you find that it is `dired-goto-file` that scrolls the listing, to put the file where the cursor was when you hit `g` in the middle of the window vertically. It does this because the last thing it does is call `search-forward`, and that function does the recentering.
You can't prevent it from doing that - `search-forward` is coded in C, and there's no parameter to modify this part of its behavior (and I don't know of any global variable that will do so).
But you can make the buffer/window scroll, when `dired-revert` is done, that is, after `search-forward` centers the cursor vertically, to put the cursor's file where you want it in the window. You can do that by advising `dired-revert` with an `:after` function that scrolls the window the way you want.
The function you want, to scroll the window, is `recenter`. Its doc (`C-h f recenter`) tells you that you can pass it a numeric arg *ARG*, to put "putting point on screen line `ARG` relative to the selected window." And if `ARG` is negative then it does so relative to the bottom of the window. So an `ARG` value of `-1` puts the line you want at the bottom of the window - which is where I guess you're asking to put it.
```
;; Function to use at end of `dired-revert'.
(defun foo (_arg _noconfirm)
"Put cursor line at bottom of window."
(recenter -1))
;; Do `foo' at the end of `dired-revert'.
(advice-add 'dired-goto-file :after 'foo)
```
---
Of course, maybe you don't *always* want the current line (where the cursor is) to end up at the bottom of the window. In that case, you'll have to do something else.
You can, for example, find out where in the window, vertically, the cursor is before you hit `g`, and then have a function such as `foo` recenter to that vertical window position, instead of always using `-1` as the arg to `recenter`.
I don't think there's a function that gives you the window line, that is, the current line number relative to the window beginning. You can do that this way:
```
(defun window-line-at-point ()
(let ((bow (save-excursion (move-to-window-line 0) (point))))
(count-screen-lines bow (point))))
```
And then you can move to that window line using function `recenter`.
But you need to use `window-line-at-point` at the outset, when `dired-revert` is called, so you need to advise that function (with `:around`) to get the window line, bind it to a variable, and then call `recenter` to move to that window line at the end. This does that:
```
(defun foo (old-fn _a _b)
(let ((curr-line (window-line-at-point)))
(funcall old-fn)
(recenter (1- curr-line))))
(advice-add 'dired-revert :around 'foo)
```
(Alternatively, you could define your own revert function, and bind that to `revert-function` in Dired buffers, instead of it being bound to `dired-revert`.)
> 1 votes
---
Tags: dired, advice, nadvice
---
|
thread-61990
|
https://emacs.stackexchange.com/questions/61990
|
How can I prevent empty files from showing up on the Ibuffer list?
|
2020-11-28T15:15:01.130
|
# Question
Title: How can I prevent empty files from showing up on the Ibuffer list?
On my IBuffer I always see a `*.py` file that is actually empty.
Is it possible to prevent this file to be hidden in the `Ibuffer` or basically remove it.
```
[ Default ]
*.py 0 Python ~/*.py
```
---
On my configuration, I have folliwng line `(find-file "*.py" t)`, which actually help to speed up the opening time of any Python file on my end (honestly not sure why).
I wasn't able to exclude it as well:
```
(setq recentf-exclude '("__init__.py\\"
"__init__.py"
"\\*.py\\'"
))
```
More general question should be as: how can I prevent empty files show up on the `Ibuffer list` that will cover `*.py` as well since its empty.
# Answer
You're looking for ibuffer's filters. Probably this one `/ > 0` which filters for buffers bigger than 0.
If you want to make it "default" from the init file, something like this will do it.
```
(add-hook 'ibuffer-hook (lambda ()(ibuffer-filter-by-size-gt 0)))
```
Although, note two things:
* there are a bunch of `ibuffer-filter` functions, and also a ton of customizable options, in some cases custom defaults may clash with your init file content.
* There are plenty of options and customizations to filter, also for saving, stacking, grouping filters, etc. Probably it'll be a good idea to dig into them.
Type `C-h m` while in `ibuffer` for more info about usage.
> 2 votes
---
Tags: ibuffer
---
|
thread-62020
|
https://emacs.stackexchange.com/questions/62020
|
shell-mode `alias` keyword is not recognized as font-lock-builtin-face type
|
2020-11-30T20:18:05.447
|
# Question
Title: shell-mode `alias` keyword is not recognized as font-lock-builtin-face type
In shell-mode; `alias` keyword is not recognized as `font-lock-builtin-face` type and remain as white color (with the current theme I am using it should be in different color)
=\> Is it possible to add `alias` keyword into `font-lock-builtin-face` class?
---
This issue occurs in Ubuntu machine; with the same configuration it does not occur in a mac machine.
# Answer
Adding this to your config should work the way you want, which BTW is the normal way to add font-lock keywords.
```
(font-lock-add-keywords 'shell-mode
'(("alias" . font-lock-builtin-face)))
```
> 2 votes
---
Tags: shell-mode, customize-face
---
|
thread-13713
|
https://emacs.stackexchange.com/questions/13713
|
How to disable IDO in ‘dired-create-directory’
|
2015-07-04T18:16:58.847
|
# Question
Title: How to disable IDO in ‘dired-create-directory’
I have this setup:
```
(setq ido-everywhere t)
(ido-mode 1)
```
Well, of course there is more, but I believe that this is relevant portion.
Some time ago I wanted to have IDO for `dired-do-copy` and `dired-do-rename` and someone on IRC `#emacs` channel told me to add this to my config:
```
(put 'dired-do-copy 'ido nil) ; use ido there
(put 'dired-do-rename 'ido nil) ; ^
```
…it worked!
Now I would like to do the opposite: I need to completely disable IDO for `dired-create-directory`, because it doesn't make any sense there (but `ido-everywhere` activates it there).
Of course I have some other stuff like `ido-ubiquitous`, and `ido-hacks`, but I don't know if I should try to mess with these packages to do what I want to do.
**Q**: how to disable IDO for `dired-create-directory`?
---
**Attention of future readers**: @Drew's answer doesn't work, although it has been upvoted by people who didn't care to try it (including me). There are better (and more general) ways to do it, see below.
# Answer
OK, if we have to resort to advising, here is how I would do it:
```
(defun mk-anti-ido-advice (func &rest args)
"Temporarily disable IDO and call function FUNC with arguments ARGS."
(interactive)
(let ((read-file-name-function #'read-file-name-default))
(if (called-interactively-p 'any)
(call-interactively func)
(apply func args))))
(defun mk-disable-ido (command)
"Disable IDO when command COMMAND is called."
(advice-add command :around #'mk-anti-ido-advice))
```
…and then we can just:
```
(mk-disable-ido 'dired-create-directory)
```
Thanks to @npostavs comment about let-binding of `read-file-name-function`.
> 2 votes
# Answer
```
(defadvice dired-create-directory (around inhibit-ido activate)
"Turn off Ido mode for the duration, then turn it on."
(unwind-protect
(progn (ido-everywhere -1) ad-do-it)
(ido-everywhere 1)))
```
If you aren't sure you always want `ido-everywhere` mode turned on at the end, then you can do this instead - it keeps it on or off, as it was before using `dired-create-directory`:
```
(defadvice dired-create-directory (around inhibit-ido activate)
"Inhibit Ido for the duration."
(let ((orig-ido-everywhere ido-everywhere))
(unwind-protect
(progn (ido-everywhere -1) ad-do-it)
(when orig-ido-everywhere (ido-everywhere 1)))))
```
> 3 votes
# Answer
For files (and directories, not buffers) `C-f` makes it fall back to non-ido behavior.
> C-f runs the command ido-magic-forward-char (found in ido-completion-map), which is an interactive compiled Lisp function in ‘ido.el’.
>
> It is bound to C-f.
>
> (ido-magic-forward-char ARG)
>
> Move forward in user input or perform magic action.
> If no user input is present, or at end of input, perform magic actions:
> C-x C-b ... C-f switch to ‘ido-find-file’.
> C-x C-f ... C-f fallback to non-Ido ‘find-file’.
> C-x C-d ... C-f fallback to non-Ido brief ‘dired’.
> C-x d ... C-f fallback to non-Ido ‘dired’.
You also might want to check out Introduction to Ido Mode.
> 2 votes
# Answer
I don't know if this was possible 5 years ago, anyway, you can do
```
(add-to-list 'ido-read-file-name-non-ido 'dired-create-directory)
```
By itself this only works for commands that don't use Ido completion unless `ido-everywhere` is enabled. I think commands that use Ido even when `ido-everywhere` is turned off do so because Ido remaps their key bindings to the `ido-` version of the original command. In that case you have to disable Ido completion for the original command by adding it to the `ido-read-file-name-non-ido` list and undo Ido's remapping. For example, disabling Ido for `C-x w` requires
```
(ido-mode) ; The unmapping must be done after Ido is initialized.
(add-to-list 'ido-read-file-name-non-ido 'write-file)
(define-key (cdr ido-minor-mode-map-entry) [remap write-file] nil)
```
> 1 votes
---
Tags: dired, ido
---
|
thread-53127
|
https://emacs.stackexchange.com/questions/53127
|
How to execute a org-babel source block within the working directory?
|
2019-10-13T12:33:39.080
|
# Question
Title: How to execute a org-babel source block within the working directory?
Say you have the following org-babel source block:
```
#+BEGIN_SRC latex :results raw :file test.pdf
\LaTeX
#+END_SRC
```
When executing it, org-babel will do the actual compilation in a temporary directory and move the resulting PDF back to your working directory afterwards. The problem with this is that I cannot include my local LaTeX commands and configuration with `\input{myMacros}`, since it won't be found in the temporary directory.
How can I tell org-babel to execute a source block in the folder of the org-mode file (hence in the `default-directory`)?
# Answer
I've checked `:dir` again and it seems to work now (with org-mode v9.4). Here is a minimal example:
```
#+BEGIN_SRC latex :tangle ./workingdir/inputfile.tex
Content from input file
#+END_SRC
#+BEGIN_SRC latex :results raw :file test.pdf :dir ./workingdir
\input{inputfile}
\LaTeX
#+END_SRC
```
Thanks to @Hubisan for the pointer!
> 4 votes
---
Tags: org-mode, latex, org-babel
---
|
thread-61920
|
https://emacs.stackexchange.com/questions/61920
|
org-capture to a heading within a date-tree
|
2020-11-24T15:18:24.940
|
# Question
Title: org-capture to a heading within a date-tree
been using org-mode for a little over a year, but still have a ton to learn. Here's the setup and question: i've got a straightforward date-tree daily notes / tasks setup, and i'm trying to figure out how to append to a sub-heading within that structure. At the top-level, my main file is structured like this:
```
* 2020
** 2020-11 November
*** 2020-11 November
**** 2020-11-24 Tuesday
***** tasks
***** log
***** meetings
***** notes
```
And I want to create a capture template that appends a note under today's "\* log". I'm currently using a capture template like this:
```
("y" "Work Task" entry (file+olp+datetree "~/org/journal/work.org")
"* TODO %?\n%U" :empty-lines 1)
```
Which is fine, but it adds the task to the date correctly, but not the TASKS sub-heading. Any idea how I'd set that up?
# Answer
> 2 votes
One way is to search the subtree for the log heading and, if it finds one, set the point to that location.
```
(setq org-capture-templates
'(("y" "Work Task" entry (file+function
"~/org/journal/work.org"
(lambda ()
(org-datetree-find-date-create
(org-date-to-gregorian (org-today)) t)
(re-search-forward "^\\*.+ log" nil t)))
"* TODO %?\n%U" :empty-lines 1)))
```
---
Tags: org-mode, org-capture
---
|
thread-62037
|
https://emacs.stackexchange.com/questions/62037
|
is there a shortcut to re-type the original filename and then edit it, when at the dired copy (C) minibuffer prompt
|
2020-12-01T13:40:57.690
|
# Question
Title: is there a shortcut to re-type the original filename and then edit it, when at the dired copy (C) minibuffer prompt
While in a dired buffer, after pressing `C` to copy a file, often the new filename you want is actually a variation of the original file name. Is there a easy way to get original file name in to the minibuffer prompt?
# Answer
> 1 votes
The dired section of the Emacs manual says:
> The usual history and completion commands can be used in the minibuffer; in particular, ‘M-n’ puts the name of the visited file (if any) in the minibuffer (\*note Minibuffer History::).
So, typing `M-n` at the minibuffer prompt will fill out the name and allow you to change it.
---
Tags: dired, default
---
|
thread-61391
|
https://emacs.stackexchange.com/questions/61391
|
org mode sum time from remote table with org-lookup-all
|
2020-10-23T07:41:54.723
|
# Question
Title: org mode sum time from remote table with org-lookup-all
I have two tables
```
#+NAME: tasks
| name | spent |
|--------+--------|
| task 1 | |
| task 2 | |
| task 3 | |
| task 4 | |
| task 5 | |
```
```
#+NAME: works
| date | task | time |
|------------------+--------+----------|
| <2020-10-17 Sat> | task 1 | 0:05 |
| <2020-10-18 Sun> | task 1 | 0:10 |
| <2020-10-19 Mon> | task 2 | 1:00 |
| <2020-10-20 Tue> | task 3 | 1:25 |
| <2020-10-21 Wed> | task 4 | 0:10 |
| <2020-10-22 Thu> | task 4 | 2:30 |
```
How to calculate total time spent to task in table `tasks` column `spent` using `org-lookup-all`?
# Answer
The code works for me:
```
(org-table-time-seconds-to-string
(apply '+
(mapcar 'string-to-number
(mapcar 'org-table-time-string-to-seconds
(org-lookup-all
$1
'(remote(works,@2$2..@>$2))
'(remote(works,@2$3..@>$3))))))
'hh:mm)
```
`org-lookup-all` returns something like `("0:05" "0:10")`.
---
```
#+NAME: works
| date | task | time |
|------------------+--------+----------|
| <2020-10-17 Sat> | task 1 | 0:05 |
| <2020-10-18 Sun> | task 1 | 0:10 |
| <2020-10-19 Mon> | task 2 | 1:00 |
| <2020-10-20 Tue> | task 3 | 1:25 |
| <2020-10-21 Wed> | task 4 | 0:10 |
| <2020-10-22 Thu> | task 4 | 2:30 |
#+NAME: tasks
| name | spent |
|--------+-------|
| task 1 | 00:15 |
| task 2 | 01:00 |
| task 3 | 01:25 |
| task 4 | 02:40 |
| task 5 | 00:00 |
#+TBLFM: $2='(org-table-time-seconds-to-string (apply '+ (mapcar 'string-to-number (mapcar 'org-table-time-string-to-seconds (org-lookup-all $1 '(remote(works,@2$2..@>$2)) '(remote(works,@2$3..@>$3)))))) 'hh:mm)
```
I learnt how to use the function via https://orgmode.org/worg/org-tutorials/org-lookups.html, the webpage contains some examples.
> 1 votes
# Answer
In Calc (the Emacs embedded calculator) there is a format for hours-minutes-seconds that you may leverage. For instance, 1 hour, 25 minutes, 17 seconds is written `1@ 25' 17"`. Here is a variation of xuchunyang's answer with this format:
The input table:
```
#+NAME: works
| date | task | time |
|------------------+--------+-----------|
| <2020-10-17 Sat> | task 1 | 0@ 05' 0" |
| <2020-10-18 Sun> | task 1 | 0@ 10' 0" |
| <2020-10-19 Mon> | task 2 | 1@ 00' 0" |
| <2020-10-20 Tue> | task 3 | 1@ 25' 0" |
| <2020-10-21 Wed> | task 4 | 0@ 10' 0" |
| <2020-10-22 Thu> | task 4 | 2@ 30' 0" |
```
The sums:
```
#+NAME: tasks
| name | spent |
|--------+-----------|
| task 1 | 0@ 15' 0" |
| task 2 | 1@ 0' 0" |
| task 3 | 1@ 25' 0" |
| task 4 | 2@ 40' 0" |
| task 5 | 0 |
#+TBLFM: $2='(math-format-value (calcFunc-vsum (cons 'vec (mapcar #'math-read-expr (org-lookup-all $1 '(remote(works,@2$2..@>$2)) '(remote(works,@2$3..@>$3)) )))))
```
Note that Org Mode tables understand this `@ ' "` format. Therefore you may use it in other ways.
> 0 votes
# Answer
Alternately, you may want to look at the `OrgAggregate` package available on `Melpa`. It does all kinds of aggregations. In your example with the `@ ' "` format, it will use the `task` column as a key, and sum up the `time` column values. You don't have to create the receiving table, `OrgAggregate` takes care of it.
```
#+BEGIN: aggregate :table "works" :cols "task vsum(time)"
| task | vsum(time) |
|--------+------------|
| task 1 | 0@ 15' 0" |
| task 2 | 1@ 0' 0" |
| task 3 | 1@ 25' 0" |
| task 4 | 2@ 40' 0" |
#+END:
```
Documentation here: https://github.com/tbanel/orgaggregate
> 0 votes
---
Tags: org-mode, org-table, calc
---
|
thread-35524
|
https://emacs.stackexchange.com/questions/35524
|
How to remap backward-delete and help command while using Emacs from a terminal emulator?
|
2017-09-14T09:29:20.770
|
# Question
Title: How to remap backward-delete and help command while using Emacs from a terminal emulator?
I was using Emacs on CentOS 7 from the MobaXterm terminal on Windows 7, but the backspace key instead of backward-deleting a character invokes the prefix command `C-h`. According to EmacsWiki, I tried to put the following lines in `~/.emacs.d/init.el`:
```
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "C-?") 'help-command)
```
It does make the backspace act normally, but I couldn't invoke `C-h` by typing either `Ctrl-Shift-/` or `Ctrl-h`, or find anywhere to invoke it. Did I miss anything? Is it possible to let both backspace and `Ctrl-h` act as usual, that is, backspace doing backward-delete and `Ctrl-h` doing `C-h` help command?
# Answer
> 12 votes
From the Emacs manual, node DEL Does Not Delete:
> On a text terminal, if you find that `<BACKSPACE>` prompts for a Help command, like `Control-h`, instead of deleting a character, it means that key is actually sending the `BS` character. Emacs ought to be treating `<BS>` as `<DEL>`, but it isn’t.
>
> In all of those cases, the immediate remedy is the same: use the command `M-x normal-erase-is-backspace-mode`. This toggles between the two modes that Emacs supports for handling `<DEL>`, so if Emacs starts in the wrong mode, this should switch to the right mode. On a text terminal, if you want to ask for help when `<BS>` is treated as `<DEL>`, use `<F1>`; `C-?` may also work, if it sends character code 127.
>
> To fix the problem in every Emacs session, put one of the following lines into your initialization file. For the first case above, where `<BACKSPACE>` deletes forwards instead of backwards, use this line to make `<BACKSPACE>` act as `<DEL>`:
>
> ```
> (normal-erase-is-backspace-mode 0)
>
> ```
>
> For the other two cases, use this line:
>
> ```
> (normal-erase-is-backspace-mode 1)
>
> ```
>
> Another way to fix the problem for every Emacs session is to customize the variable `normal-erase-is-backspace`: the value `t` specifies the mode where `<BS>` or `<BACKSPACE>` is `<DEL>`, and `nil` specifies the other mode.
I found this information in the Emacs manual using `i backspace S-TAB`, with Icicles. In Icicles, `S-TAB` does "apropos"-style completion, which means that it checks here for `backspace` as a substring, not just as a prefix, of the completion candidates.
If you try `i backspace TAB` then you won't find any completion candidates, because the actual candidates you need to match are these, none of which begin with `backspace`:
```
<BACKSPACE> vs <DEL>
<DEL> vs <BACKSPACE>
c-electric-backspace
C-S-backspace
normal-erase-is-backspace
normal-erase-is-backspace-mode
```
# Answer
> 2 votes
You can also uncheck the 'Backspace sends ^H' Terminal setting in MobaXterm Configuration page.
---
Tags: key-bindings, microsoft-windows, term
---
|
thread-2501
|
https://emacs.stackexchange.com/questions/2501
|
How can I set default font in Emacs?
|
2014-10-23T15:47:06.780
|
# Question
Title: How can I set default font in Emacs?
I can't set Inconsolata as default font in Emacs 24.4 Linux.
* I changed the font in the menu -\> Save options. The font changed but after a restart the font is the same as it was by default.
* Added this to `~/.Xresources`: `Emacs.font: Inconsolata LGC`
Then in `init.el`: `(set-default-font "Inconsolata LGC")`. Same story.
What I'm doing wrong?
# Answer
I have the following in my .emacs using Emacs for OSX:
```
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 130 :width normal :family "Inconsolata")))))
```
## Setting the font
It's easiest to set the font using the menus if you're running Emacs in a graphical environment. Use "Options -\> Set Default Font..." from the menus.
Now, you're not done because you've only changed the font temporarily. The easiest method that I know of is to use the customization mode.
```
M-x customize-face RET default RET
```
Now change the options you wish to change, if any. If you've already changed the font using the menus, you should see your changes here.
## Saving to your init file
*Save For Future Sessions* by either:
* Click on the *State* button and choose *Save For Future Sessions*
or
* `C-x C-s` while in the Customization buffer which ~~will~~ *should* do the same thing *but doesn't always work, e.g. after `(set-default-font "Inconsolata")`*
## If all else fails...
You may have luck with the Set Fonts page.
> 40 votes
# Answer
I use this in my init.el:
```
;; Set default font
(set-face-attribute 'default nil
:family "Source Code Pro"
:height 110
:weight 'normal
:width 'normal)
```
You could try the same using Inconsolata instead of Source Code Pro.
> 32 votes
# Answer
If you changed something in *.Xresources* file then you need to **reread** it to see any changes in current session.
* To **keep** your old resources settings and apply new one:
```
xrdb -merge ~/.Xresources
```
* To **throw away** your old resources and apply only settings from *.Xresources*:
```
xrdb ~/.Xresources
```
Adjustments in *.Xresources* file are better, because they are applied before mapping emacs' X11 window. Customizations in init files (.emacs, .emacs.d/) are re-applied to already created window. You can for example avoid toolbars "flickering" during startup when you add
```
! UI elements
Emacs.menuBar: 0
Emacs.toolBar: 0
Emacs.verticalScrollBars: off
! Font settings
Emacs.FontBackend: xft,x
Emacs.font: Inconsolata LGC:size=16
```
to your *.Xresources* file.
You can check what else is available at https://www.gnu.org/software/emacs/manual/html\_node/emacs/X-Resources.html
> 14 votes
# Answer
From: https://www.gnu.org/software/emacs/manual/html\_node/emacs/Fonts.html#Fonts
Add a line to your init file:
```
(add-to-list 'default-frame-alist
'(font . "DejaVu Sans Mono-10"))
```
> 8 votes
# Answer
This always works whenever I want to try other fonts (put it in your init.el or .emacs file):
```
(push '(font . "Inconsolata") default-frame-alist)
```
or
```
(add-to-list 'default-frame-alist '(font . "Inconsolata"))
```
In this case both expressions are equivalent.
In short, these forms set the font for the current and all future Emacs frames. Since these are saved in your configuration file, the setup is not lost on restart.
> 7 votes
# Answer
All I did after setting my font with `Options/Set Default Font...` was `Options/Save Options` and it saved it to my `.emacs`, and it worked.
> 1 votes
---
Tags: fonts, linux
---
|
thread-62046
|
https://emacs.stackexchange.com/questions/62046
|
How to get ":size" from font-spec
|
2020-12-01T21:24:12.910
|
# Question
Title: How to get ":size" from font-spec
How can I get `:size` from `font-spec` using Elisp?
# Answer
> 4 votes
What about the function `font-get`? For example:
```
(font-get (font-spec :size 10) :size) ; => 10
```
Quoth its docstring:
```
font-get is a built-in function in `C source code'.
(font-get FONT KEY)
Probably introduced at or before Emacs version 23.1.
Return the value of FONT's property KEY.
FONT is a font-spec, a font-entity, or a font-object.
KEY is any symbol, but these are reserved for specific meanings:
:family, :weight, :slant, :width, :foundry, :adstyle, :registry,
:size, :name, :script, :otf
See the documentation of `font-spec' for their meanings.
In addition, if FONT is a font-entity or a font-object, values of
:script and :otf are different from those of a font-spec as below:
The value of :script may be a list of scripts that are supported by the font.
The value of :otf is a cons (GSUB . GPOS) where GSUB and GPOS are lists
representing the OpenType features supported by the font by this form:
((SCRIPT (LANGSYS FEATURE ...) ...) ...)
SCRIPT, LANGSYS, and FEATURE are all symbols representing OpenType
Layout tags.
In addition to the keys listed abobe, the following keys are reserved
for the specific meanings as below:
The value of :combining-capability is non-nil if the font-backend of
FONT supports rendering of combining characters for non-OTF fonts.
```
Quoth `(info "(elisp) Low-Level Font")`:
```
The following functions can be used to obtain information about a
font. For these functions, the FONT argument can be a font object, a
font entity, or a font spec.
-- Function: font-get font property
This function returns the value of the font property PROPERTY for
FONT.
If FONT is a font spec and the font spec does not specify PROPERTY,
the return value is ‘nil’. If FONT is a font object or font
entity, the value for the :SCRIPT property may be a list of scripts
supported by the font.
```
---
Tags: fonts
---
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.