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-52720
|
https://emacs.stackexchange.com/questions/52720
|
magit commit does not permit adding a gpg signature
|
2019-09-18T15:48:46.243
|
# Question
Title: magit commit does not permit adding a gpg signature
I am **failing to run gpg to sign commits**, after doing so successfully before an upgrade to Mojave and an upgrade to Emacs. (I am not sure when I lost the ability to sign files in the past year.)
When I attempt to sign commits now this happens:
```
GitError! failed to write commit object [Type `$' for details]
```
When I expand the '$' for details, I get this:
```
0 git … commit --amend --only
hint: Waiting for your editor to close the file...
Waiting for Emacs...
[master e61729b] Master SQLite DB in ~/ingest.
Date: Tue Sep 17 17:35:07 2019 -0500
2 files changed, 70 insertions(+), 8 deletions(-)
128 git … commit --amend --only
hint: Waiting for your editor to close the file...
Waiting for Emacs...
error: cannot run gpg: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object
```
My searches for fixes related to GNU gpg and the new Transient library and suggestions for that switchover in the Magit source have not led to a solution.
## **What I am looking for**
I am interested in determining
* How Emacs finds the paths to use gpg in Magit to run this command so that I can debug the configuration. **Answered** in the comment, incorporated below:
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin")) (setq exec-path (append exec-path '("/usr/local/bin")))
* How can I see where the paths are that Emacs and GPG can use internally when running any command?
I am interested in the solutions that others have had to this issue.
## Versions of software and OS.
```
magit-version returns the following string
Magit 2.90.1 Git 2.20.1 (Apple Git-117), Emacs 26.1, darwin
on an iMac Pro (2017) running OS X 10.14.6
Version of Emacs: Emacs 26.1 (9.0)
https://www.gnu.org/software/emacs
```
**Additional information - Added 2019-09-20 Friday**
I solved the above issue with this correction:
Emacs EPA and Gnupg2 no usable configuration
```
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
```
# Answer
> 0 votes
> `error: cannot run gpg: No such file or directory`
This means "I cannot find gpg and therefore cannot run it", i.e. that `gpg` either isn't installed at all (which is unlikely) or that it is not located on the `PATH` where processes look for executables they intend to run as subprocesses.
Based on what you have posted above that directory happens to be `/usr/local/bin`, which is a directory that should really be placed on `PATH`; it isn't obscure at all.
To teach `emacs` about that directory the `exec-path` lisp variable has to be used, to teach other processes (including `git`) to do so the environment variable `PATH` has to be set. Something like:
```
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
```
---
Tags: magit, osx, gpg, debug
---
|
thread-52829
|
https://emacs.stackexchange.com/questions/52829
|
Fringe indicators very tiny
|
2019-09-25T14:14:49.277
|
# Question
Title: Fringe indicators very tiny
My fringe indicators have become extremely tiny. Left side is flycheck, right side is git-gutter-fringe. So different packages, both extremely tiny.
My font might look huge, but it's not; it's 12. Doesn't matter if I change my font, or font size (the fringe doesn't scale).
I've tried `(fringe-mode 20)` and `(set-font-face 'fringe nil :height 100)`. Linum is fine.
My emacs config is pretty simple and it works fine on my Mac. Did a straight copy over to Windows 10.
This is official Emacs build for Windows 10 (installed via choco).
# Answer
> 2 votes
It is a scaling issue (or lack thereof).
Example: on Windows 4k resolution with 200% scaling, the fringe is tiny. But with 100% scaling they appear ok.
The official bug report is at https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31203
# Answer
> 0 votes
Would it help if you set different values? For example,
```
(set-fringe-mode '(2 . 4)) ;; Left: 2px; Right: 4px
```
---
Tags: fringe
---
|
thread-52833
|
https://emacs.stackexchange.com/questions/52833
|
Next buffer command change when in the terminal window
|
2019-09-25T17:02:30.723
|
# Question
Title: Next buffer command change when in the terminal window
I am totally new to Emacs and on this first day I am trying to do very basic stuff in emacs. I am stuck at switching buffers when there is a terminal window open (by using `M-x term`). The next buffer command changes from `<XF86Forward>` to `C-c C-<right>`. I tried to type `Ctrl + c + Ctrl + ->` on the keyboard, but it still doesn't work. What is the problem here?
P.S. I am using macOS Mojave and Emacs 26.1.
# Answer
`C-<right>` (sometimes written `<C-right>`) means press and hold the Control key while hitting the `<right>` key. The `<right>` key is the right-arrow key.
Emacs key notation is described here: (emacs) User Input.
You can get to that doc within Emacs, by doing this: `C-h r i keyboard input`.
That is:
1. Use `C-h` (Control + h) followed by `r` to visit the Emacs manual.
2. Use `i` followed by inputting the text `keyboard input`.
In a manual, `i` looks things up in the Index. Looking up `keyboard input` it puts you in the manual node **User Input**.
> 1 votes
---
Tags: buffers, help
---
|
thread-52588
|
https://emacs.stackexchange.com/questions/52588
|
Dynamically hide lines indented more than current line
|
2019-09-09T17:23:41.740
|
# Question
Title: Dynamically hide lines indented more than current line
Is there a way to dynamically hide lines that are indented more than the current line?
For example, if I am looking at this file
```
{
"a": 1
"b": {
"c": {
"d": 2
}
}
}
```
and I am on the line with `"b"`, I would see something like
```
{
"a": 1
"b": {
}
}
```
and if I move down one real line, I then see
```
{
"a": 1
"b": {
"c": {
}
}
}
```
I suspect that a minor mode that does `(set-selective-display (indentation-of-current-line))` after each movement of the point is what I want. Although I would also want a simple what to go to the first line of the hidden region. Which is probably simple to do, but I'm not immediately seeing it.
# Answer
It sounded good, so I made a quick implementation of the idea.
If the indentation of the current line only is used, navigation becomes difficult, so I chose to consider also the indentation of the next line.
Implementation wise:
* `(current-indentation)` gives the indentation of the line at point.
* `post-command-hook` is a suitable place for executing the command. I haven't tested, if `set-selective-display` avoids the overhead of repeatedly applying the same value.
---
```
;; -*- lexical-binding: t; coding: utf-8; -*-
(define-minor-mode auto-set-selective-display-mode
"Automatically apply `set-selective-display' at all times based on current indentation."
nil "$" nil
(if auto-set-selective-display-mode
(add-hook 'post-command-hook #'auto-set-selective-display nil t)
(remove-hook 'post-command-hook #'auto-set-selective-display t)
(with-temp-message ""
(set-selective-display nil))))
(defun auto-set-selective-display ()
"Apply `set-selective-display' such that current and next line are visible.
Scroll events are excluded in order to prevent wild flickering while navigating."
(unless (eq last-command #'mwheel-scroll)
(let*((this-line-indent (current-indentation))
(next-line-indent (save-excursion (forward-line) (current-indentation))))
(with-temp-message "" ; Suppress messages.
(set-selective-display (1+ (max this-line-indent next-line-indent)))))))
```
---
**Edit** (Troy Daniels) Add an option to not look at the next line.
As promised in the comments, `M-x auto-set-selective-display-toggle-neighboring-lines` will toggle whether it looks at the next line to get the indentation.
```
;; -*- lexical-binding: t; coding: utf-8; -*-
(define-minor-mode auto-set-selective-display-mode
"Automatically apply `set-selective-display' at all times based on current indentation."
nil "$" nil
(if auto-set-selective-display-mode
(add-hook 'post-command-hook #'auto-set-selective-display nil t)
(remove-hook 'post-command-hook #'auto-set-selective-display t)
(with-temp-message ""
(set-selective-display nil))))
(defcustom auto-set-selective-display-neighboring-lines t
"Should neighboring lines be considered when looking at the selective display depth."
:type 'boolean
:safe t)
(defun auto-set-selective-display-toggle-neighboring-lines ()
"Toggle whether neighboring lines should be show."
(interactive)
(setq auto-set-selective-display-neighboring-lines (not auto-set-selective-display-neighboring-lines)))
(defun auto-set-selective-display ()
"Apply `set-selective-display' such that current and next line are visible.
Scroll events are excluded in order to prevent wild flickering while navigating."
(unless (eq last-command #'mwheel-scroll)
(let*((this-line-indent (current-indentation))
(next-line-indent (if auto-set-selective-display-neighboring-lines
(save-excursion (forward-line) (current-indentation))
-1)))
(with-temp-message "" ; Suppress messages.
(set-selective-display (1+ (max this-line-indent next-line-indent)))))))
```
> 1 votes
---
Tags: visibility
---
|
thread-41336
|
https://emacs.stackexchange.com/questions/41336
|
src python in org-mode: IndentationError: unexpected indent
|
2018-05-04T19:16:30.497
|
# Question
Title: src python in org-mode: IndentationError: unexpected indent
mac 10.13.4 / emacs 25.3 (9.0) / org-version 9.1.12 / python 3.5.2
I am trying to understand why C-c C-c generate an `IndentationError: unexpected indent` when executing a simple code like the example below as a code block:
```
#+BEGIN_SRC python :session :exports results
def spam():
try:
a, b = 1, 2
except:
a, b = 11, 12
finally:
a = 'voila'
#+END_SRC
```
my init.el is as follows:
```
;; Set org mode
(eval-after-load "org"
'(org-babel-do-load-languages
'org-babel-load-languages
'((sh . t)
(python . t)
(emacs-lisp . t)
(ditaa . t)
))
)
(setq org-src-tab-acts-natively t)
```
I have actually written this python code in a python buffer (C-c') and it works everywhere else except in the org-mode. I would really appreciate any lead
# Answer
What's happening is that `org-babel-python-evaluate-session` sends an extra newline when the indentation level goes down, this causes the interpreter to close out the top-level block.
What I've done is just commented out that bit (forgive the wonky indentation, my file as received from elpa mixes tabs and spaces)
**ob-python.el**
```
(defun org-babel-python-evaluate-session
(session body &optional result-type result-params)
"Pass BODY to the Python process in SESSION.
If RESULT-TYPE equals `output' then return standard output as a
string. If RESULT-TYPE equals `value' then return the value of the
last statement in BODY, as elisp."
(let* ((send-wait (lambda () (comint-send-input nil t) (sleep-for 0 5)))
...
(input-body (lambda (body)
(dolist (line (split-string body "[\r\n]"))
;; Insert a blank line to end an indent
;; block.
(let ((curr-indent (string-match "\\S-" line)))
(if curr-indent
(progn
(when (< curr-indent last-indent)
(insert "")
;(funcall send-wait) <- comment this out
) ; move the closing paren to the next line
...
```
The result is that top-level blocks are sent as one unit which may have implications if you're evaluating a large block (e.g. a god class). I haven't tested it extensively but it's been working for me.
Hope that helps.
> 4 votes
---
Tags: org-mode, python
---
|
thread-52786
|
https://emacs.stackexchange.com/questions/52786
|
Howto cache completing-read inputs
|
2019-09-22T18:18:35.907
|
# Question
Title: Howto cache completing-read inputs
Is there a simple framework for making previous inputs of `completing-read` **persistent** *across emacs restarts*? For instance if I start with: `(completing-read "test:" '("a" "b") nil nil)` and enter "c" the next time I start emacs and execute I want the collection to be `(completing-read "test:" '("a" "b" "c") nil nil)` instead. Is there a simple way to achieve this?
# Answer
> 0 votes
It seems there is no history for single minibuffer instances so I'm using this approach where `magit-gerrit-reviewers` is the `'("a" "b" "c")` list:
Saving history
```
(defun magit-gerrit-write-review (file)
(with-temp-file file
(insert "(setq magit-gerrit-reviewers '")
(prin1 magit-gerrit-reviewers (current-buffer))
(insert ")" )))
```
Loading history:
```
(if (file-exists-p "~/.gerrit.reviewers")
(load "~/.gerrit.reviewers"))
```
And using it:
```
(completing-read "Reviewer Name/Email:" magit-gerrit-reviewers nil nil)
```
# Answer
> 1 votes
Yes: just put `(savehist-mode 1)` in your `~/.emacs` and that should do the trick.
\[ Tho not quite in the way you describe: `c` will still not be among the completion candidates. But it will be in your *history* and hence accessible via `M-p`, `M-s`, ... \]
# Answer
> 0 votes
1. You can persist any global variable, by adding it to the value of option `savehist-additional-variables`. This includes any minibuffer history variable.
2. Minibuffer history variables are used (typically) by `completing-read`. You can use `M-p` and `M-r` to retrieve previously used minibuffer inputs when you are prompted by `completing-read`. See (emacs) Minibuffer History.
3. However, there are many different minibuffer history variables. The most common, catch-all variable is `minibuffer-history`. You can try persisting all of the minibuffer history variables you can find ;-), but be aware that any code can add a new such variable.
4. None of what I've said puts minibuffer history entries into the default set of **completion candidates** for any `completing-read` call. Input history and completion candidates are two different things.
5. If you use Icicles then during minibuffer *completion* (including `completing-read`):
* You can use **`M-h`** to match your current input against the minibuffer history directly.
* Use **`M-<pause>`** to restrict the current set of completion candidates to those you've used previously. If you use `C-u M-pause`, then the previously used candidates are ordered chronologically, most recent first.
6. If you use Icicles then you can use **`M-o`** to complete against the history list during ***any*** minibuffer inputting, even without completion (i.e., whether the minibuffer is being used by `completing-read` or some other function).
---
Tags: completion, persistence
---
|
thread-28157
|
https://emacs.stackexchange.com/questions/28157
|
vc-git doesn't recognize that file is under version control
|
2016-10-27T04:18:55.407
|
# Question
Title: vc-git doesn't recognize that file is under version control
I initialized a Git repository outside emacs, added and committed the files.
Now if I a file in emacs that is under version control by Git and run `C-x v =` emacs tells me `This file is not under version control`.
It seems emacs missed that I added this file to Git already. How can I tell emacs that this file (and the whole directory) is already in Git, so that I can use the `vc-git-*` commands?
# Answer
> 2 votes
Emacs caches version control information for each buffer.
If you visit a file first, and then `git add` it in a terminal, Emacs doesn't know this. You can `M-x revert-buffer` to force it to refresh the cache, or kill the buffer and visit the file again.
In the future, you can register such files from within Emacs, using `vc-next-action`, by default bound to `C-x v v`. Though if the file is already registered this command will do something else.
# Answer
> 1 votes
After update of MacOS (10.14.6) I had the same "This file is not under version control" - turns out that I needed to accept xcode license to run git commands.
In terminal just do a `sudo xcodebuild -license`\- that fixed my problem.
---
Tags: git, vc
---
|
thread-46817
|
https://emacs.stackexchange.com/questions/46817
|
orgmode table time string delta with formula
|
2018-12-30T04:10:12.107
|
# Question
Title: orgmode table time string delta with formula
I wish to calculate time string delta as below:
```
| date | delta |
|------------+-------|
| 2018/12/28 | 0 |
| 2018/12/31 | -1 |
#+TBLFM: $2=if(2==@#, 0, ($1 - @-1$1); %.0f
```
The expected answer should be 3 but now it's -1. I do not wish to change the time string format in table.
How can I modify the formula to covert timestring to datetime correctly?
# Answer
> 1 votes
Just do the conversion into standard iso format and `calc-eval` in Elisp:
```
| date | delta |
|------------+-------|
| 2018/12/28 | 0 |
| 2018/12/31 | 3 |
#+TBLFM: $2='(if (= @# 2) 0 (calc-eval (concat "<" (substitute ?- ?/ $1) ">-<" (substitute ?- ?/ @-1$1) ">") )); %.0f
```
You can cleanup the code by defining the following lisp function at an appropriate place (e.g., a source block in your org-file or your init files):
```
(defun my-orgtbl-time-diff (date1 date2)
"Compute the day difference of two dates given in a format like 2019-09-23."
(let* ((date-map (lambda (str)
(and (string-match "\\([0-9]\\{4\\}\\)/\\([0-9]\\{2\\}\\)/\\([0-9]\\{2\\}\\)" str)
(concat "<" (match-string 1 str) "-" (match-string 2 str) "-" (match-string 3 str) ">"))))
(date1 (funcall date-map date1))
(date2 (funcall date-map date2)))
(if (and date1 date2)
(calc-eval (concat date1 "-" date2))
0)))
```
Employing that function your table formula has the following form.
```
| date | delta |
|------------+-------|
| 2018/12/28 | 0 |
| 2018/12/31 | 3 |
#+TBLFM: $2='(my-orgtbl-time-diff $1 @-1$1)
```
# Answer
> 1 votes
Although you said you do not want to change the date format that is what you have to do to use the $1 syntax in the formula. For that to work, org mode functions will need to know that you are dealing with dates.
The first prerequisite is the brackets around the dates. Secondly, I had to go to full ISO format date for org to recognize the date. That might depend on my settings.
```
| date | delta |
|--------------+-------|
| [2018-12-28] | 0 |
| [2018-12-31] | 3 |
#+TBLFM: $2=if(2==@#, 0, ($1 - @-1$1); %.0f
```
The alternative is to put together a very long formula using custom elisp to do the same thing.
---
Tags: org-mode, org-table
---
|
thread-52837
|
https://emacs.stackexchange.com/questions/52837
|
How to force Emacs or pinentry to forget wrong GPG password?
|
2019-09-25T22:25:47.633
|
# Question
Title: How to force Emacs or pinentry to forget wrong GPG password?
I use `mu4e`, `mu4e-send-delay` to send emails with a delay, GPG to store my SMTP authentication, and `pinentry` to access GPG files. When I am prompted for the GPG encryption password in the mini-buffer but am typing in another buffer and don't notice it, Emacs remembers that entry and keeps trying to open the GPG file with that wrong password. I then get the `*Error*` buffer next to my other buffer:
```
Error while decrypting with "/usr/local/bin/gpg":
gpg: AES encrypted data
gpg: gcry_kdf_derive failed: Invalid data
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key
```
and a user dialog `Emacs-x86_64-10_14`, `Buffer *temp* modified; kill anyway?`, and buttons with `Yes` and `No`.
Emacs has the same behavior if I restart it, probably because `pinentry` remembers the password for the session.
How can I force Emacs or `pinentry` to prompt for a new password? And could I force that prompt to happen in a user dialog, which is more noticeable than the mini-buffer?
# Answer
Pinentry is only an interface, it doesn't keep any passphrase or permission, and neither does Emacs. It's GPG-agent that manages the ropes. For example, if the time expires or the process dies, you'll have to authenticate again. So just kill the agent:
```
gpgconf --kill gpg-agent
```
More info at the gnupg manual.
> 11 votes
---
Tags: mu4e, gpg
---
|
thread-52836
|
https://emacs.stackexchange.com/questions/52836
|
Org Mode Babel: Is there a way to assert the expected results of evaluation?
|
2019-09-25T21:40:46.240
|
# Question
Title: Org Mode Babel: Is there a way to assert the expected results of evaluation?
Is there a way to assert that the results of evaluating a code block with Babel are equal to an expected text? Ideally, I would use this to stop an export to PDF if one of the assertions does not hold.
```
This is an example on how to use the Unix command =touch=.
#+begin_src sh :exports code
touch main.c
touch lib.c
#+end_src
#+RESULTS:
After you execute those commands, you should see in your working directory the
following files:
#+begin_src sh :results raw :exports results
tree .
#+end_src
#+RESULTS:
.
|-- example.org
|-- lib.c
`-- main.c
0 directories, 3 files
#+EXPECTED:
.
├── lib.c
└── main.c
```
The first code block does not have any results nor any expected results; only its side effects are useful. (Incidentally, it *has* been evaluated, as you can see because there is an empty RESULTS section underneath).
The second code block is what I would like to have: when it is evaluated, it returns a result that can be compared with the EXPECTED block. As you can see, the results do not match because I forgot to include the org file itself and the summary line returned by `tree`. An export to PDF should be stopped with a message that points out the difference. If RESULTS and EXPECTED did match, then the EXPECTED block is not exported, but the rest of the file is.
Is there a way to do this with the currently available features of Org and Babel?
# Answer
Here are a few approaches.
```
* testing conditional execution
This is an example on how to use the Unix command =touch=.
#+begin_src sh :exports code
touch main.c
touch lib.c
#+end_src
#+RESULTS:
After you execute those commands, you should see in your working directory the
following files:
#+name: tree-results
#+begin_src sh :results output :exports results
tree .
#+end_src
#+RESULTS: tree-results
: .
: ├── example.org
: ├── lib.c
: └── main.c
:
: 0 directories, 3 files
** run block with assertion block
Here we blocks that return a string yes or no, and we use that to do conditional execution in this block.
#+BEGIN_SRC emacs-lisp :var execute=assert-tree-results-nil()
(if (string= execute "no")
(message "Not executed: %S" execute)
(message "%S so executing" execute)
;;(org-open-file (org-latex-export-to-pdf)
)
#+END_SRC
#+RESULTS:
: Not executed: "no"
#+BEGIN_SRC emacs-lisp :var execute=assert-tree-results-t()
(if (string= execute "no")
(message "Not executed: %S" execute)
(message "%S so executing" execute)
;;(org-open-file (org-latex-export-to-pdf))
)
#+END_SRC
#+RESULTS:
: "\"yes\"" so executing
This will raise an error if the block assert fails.
#+BEGIN_SRC emacs-lisp :var execute=assert-assert-tree-results
(message "Doing it")
;;(org-open-file (org-latex-export-to-pdf))
#+END_SRC
#+RESULTS:
: Doing it
** using eval to do this.
Here we use elisp to execute a named block and get the results. Here if the block returns "no" the block will not be able to execute.
#+BEGIN_SRC emacs-lisp :eval (org-babel-execute-src-block nil (org-babel-lob--src-info "assert-tree-results-t"))
;(org-open-file (org-latex-export-to-pdf))
(message "doing it")
#+END_SRC
#+RESULTS:
: doing it
** Assert blocks
#+name: assert-tree-results-nil
#+BEGIN_SRC emacs-lisp :var result=tree-results :results silent
(if (string= result ".
├── lib.c
└── main.c")
"yes"
"no")
#+END_SRC
#+name: assert-tree-results-t
#+BEGIN_SRC emacs-lisp :var result=tree-results :results code
(if (string= result ".
├── example.org
├── lib.c
└── main.c
0 directories, 3 files
")
"yes"
"no")
#+END_SRC
This raises an error if the results are not right.
#+name: assert-assert-tree-results
#+BEGIN_SRC emacs-lisp :var result=tree-results :results code
(assert (string= result ".
├── example.org
├── lib.c
└── main.c
0 directories, 3 files
")))
#+END_SRC
```
> 3 votes
---
Tags: org-mode, org-export, org-babel
---
|
thread-52842
|
https://emacs.stackexchange.com/questions/52842
|
Can't change company coq mode map
|
2019-09-26T09:12:48.970
|
# Question
Title: Can't change company coq mode map
I installed a minor mode for coq-mode, called company coq. It binds the `<menu>` key to `company-coq-toggle-definition-overlay` here:
```
(defconst company-coq--core-map
(let ((cc-map (make-sparse-keymap)))
(define-key cc-map [remap proof-goto-point] #'company-coq-proof-goto-point)
cc-map)
"Keymap for core company-coq keybindings.
Do not edit this keymap: instead, edit `company-coq-map'.")
(defvar company-coq-map
(let ((cc-map (make-sparse-keymap)))
;...
(define-key cc-map (kbd "<menu>") #'company-coq-toggle-definition-overlay)
cc-map)
"Keymap of company-coq keybindings.
These keybindings are activated by `company-coq--keybindings-minor-mode'.")
(define-minor-mode company-coq--keybindings-minor-mode
"Minor mode providing convenient company-coq keybindings."
:lighter nil
:keymap company-coq-map)
```
It says: Do not edit this keymap: instead, edit \`company-coq-map'
But no matter how I try to edit `company-coq-map`, I still can't change it. I tried this:
```
(defun my-company-coq ()
(local-set-key (kbd "<menu>") 'kill-ring-save)
)
(eval-after-load 'company-coq-mode
'(define-key company-coq-map [(menu)] 'kill-ring-save))
(add-hook 'cc-mode-hook 'my-company-coq)
```
How to reset this key to kill-ring-save?
# Answer
Fixed by this:
```
(defun my-company-coq ()
(define-key company-coq-map (kbd "<menu>") #'kill-ring-save)
)
(add-hook 'company-coq-mode-hook 'my-company-coq)
```
> 1 votes
---
Tags: key-bindings, keymap
---
|
thread-52851
|
https://emacs.stackexchange.com/questions/52851
|
emacs ruby mode: can I reorder methods in file (alphabetical order)
|
2019-09-27T00:25:19.857
|
# Question
Title: emacs ruby mode: can I reorder methods in file (alphabetical order)
After opening the file
```
app/controllers/pages_controller.rb
```
Which has
```
class PagesController < ApplicationController
def foo
puts "foo"
end
def baa
puts "baa"
end
end
```
I want to add a function/method to this file, but before that I would like to tell emacs to reorder things so that `def foo` comes *after* `def baa` because of alphabetical order.
# Answer
Marking the region and calling `M-x` `sort-paragraphs` `RET` should do it
sort-paragraphs is an interactive autoloaded compiled Lisp function in ‘sort.el’.
(sort-paragraphs REVERSE BEG END)
Sort paragraphs in region alphabetically; argument means descending order. Called from a program, there are three arguments: REVERSE (non-nil means reverse order), BEG and END (region to sort). The variable ‘sort-fold-case’ determines whether alphabetic case affects the sort order.
> 1 votes
---
Tags: sorting, ruby-mode
---
|
thread-52855
|
https://emacs.stackexchange.com/questions/52855
|
How to delay an item in org mode?
|
2019-09-27T07:51:44.117
|
# Question
Title: How to delay an item in org mode?
I have repeating items that I would like to do every day but sometimes miss, e.g.:
```
** TODO That nasty habit
SCHEDULED: <2019-09-28 Sat 06:00 ++1d>
:PROPERTIES:...
:LOGBOOK:...
```
I can move point to the timestamp after `SCHEDULED` and do `S-RIGHT`, which shifts to the next day.
I could not find a relevant function `M-x org-*delay`, nor `M-x org-*schedule`.
How can I delay the item, while keeping the time and the repetition cookie, ideally with a key binding?
# Answer
## Delaying by one or multiple days
Here is a function inspired by `org-shiftright`, the function bound to the key `S-RIGHT` (find it with `C-h k S-RIGHT`), which on a timestamp calls `org-timestamp-up-day`, which itself calls `org-timestamp-change`. It binds the function to `C-c d`. Place this in your init file, such as `~/.emacs`:
```
(defun org-delay-scheduled (&optional n)
"Delay the headline at point by the number of days, keeping the time and repetition cookie."
(interactive)
;; Raise error if entry lacks SCHEDULED, or whatever the value of org-scheduled-string
;; except for the colon
(let ((scheduled-string (car (split-string org-scheduled-string ":"))))
(unless (org-entry-get nil scheduled-string)
(user-error (concat "This entry lacks a '" scheduled-string "' property")))
(save-excursion
(search-forward (concat org-scheduled-string " ")) ; move point to the scheduled entry
(search-forward " ") ; move point inside the timestamp
(org-timestamp-change (if n n 1) 'day nil))))
(define-key org-mode-map (kbd "C-c d") 'org-delay-scheduled)
```
The result is:
```
** TODO That nasty habit
SCHEDULED: <2019-09-29 Sun 06:00 ++1d>
:PROPERTIES:...
:LOGBOOK:...
```
You can then call this function from another, e.g. if you want another key binding to delay by two weeks:
```
(defun org-delay-scheduled-sprint ()
"Delay the headline at point by the default of a sprint, 2 weeks."
(interactive)
(org-delay-scheduled 14))
(define-key org-mode-map (kbd "C-c w") 'org-delay-scheduled-sprint)
```
## Delaying to present day first
The function above will delay by a fixed number of days. If you have an item far in the past the result may still be in the past, unlike the behavior of `S-RIGHT` on an entry with a repeating cookie, which first moves it to present. Here is a revision that first delays the entry to today, and then increments the fixed number of days. It uses a function that gets a slice of a list (from this thread), and does some juggling to get the number of days from the timestamp to today.
```
(defun get-n-items (lst num)
"Get the first num items from the list."
(if (> num 0)
(cons (car lst) (get-n-items (cdr lst) (- num 1)))
'()))
(defun slice (lst start count)
"Gets count elements from list starting at start."
(if (> start 1)
(slice (cdr lst) (- start 1) count)
(get-n-items lst count)))
(defun org-delay-scheduled (&optional n)
"Delay the headline at point by the number of days, keeping the time and repetition cookie."
(interactive)
;; Raise error if entry lacks SCHEDULED, or whatever the value of org-scheduled-string
;; except for the colon
(let ((scheduled-string (car (split-string org-scheduled-string ":"))))
(unless (org-entry-get nil scheduled-string)
(user-error (concat "This entry lacks a '" scheduled-string "' property")))
(save-excursion
(search-forward (concat org-scheduled-string " ")) ; move point to the scheduled entry
(let* ((timestamp-string (buffer-substring (point) (line-end-position)))
(timestamp-list (org-parse-time-string timestamp-string))
(timestamp-start-of-day (append '(0 0 0) (slice timestamp-list 4 3)))
(timestamp-internal (apply #'encode-time timestamp-start-of-day))
(day-in-seconds (* 24 (* 60 60)))
(days-to-present (truncate (/ (float-time (time-subtract (current-time) timestamp-internal)) day-in-seconds)))
(days-to-delay (+ days-to-present (if n n 1))))
(search-forward " ") ; move point inside the timestamp
(org-timestamp-change days-to-delay 'day nil)))))
(defun org-delay-scheduled-sprint ()
"Delay the headline at point by the default of a sprint, 2 weeks."
(interactive)
(org-delay-scheduled 14))
```
> 1 votes
---
Tags: org-mode
---
|
thread-52847
|
https://emacs.stackexchange.com/questions/52847
|
Cannot get Magit to show the commit signatures in the log
|
2019-09-26T17:57:49.610
|
# Question
Title: Cannot get Magit to show the commit signatures in the log
In order to prove that I had a signature on a commit I needed to use a this command line command:
```
$ git log --show-signature -1
```
I **could not get Magit to display the signature** I tried to use the Magit Key (l) and the -S switch.
But could not see the signature details.
---
# Addressing questions to the answer from the magit author
I ran out of space in my comment so I edited my question to reply.
So I validated that each commit was signed using `git log --show-signature| cat` in my shell in Emacs. Then I redid the command above and looked at individual rows to see the signature - but even when I hit `RET` as you say above, the signature still did not show up. I could also not see any evidence when all of the signatures were applied that any of them were signed.
**How do I configure the expanded view of the signature** so that the `RET` key will cause the details of the signature as the `--show-signature` flag requires? I most want to be able to drill in with `RET` and see exactly the text that is needed. I am concerned that I am missing details in magit that the shell shows properly.
# Update 2020-06-29
magit-20200617.2306 is installed in the ~/.emacs.d/elpa/. directory
**The signature now shows up in magit as a bright green color on the subject line of the commit message text**
What remains is to add the details of the signature when a long form of the log message is used.
@tarsius I am fine with the signature details being omitted in the normal case when just one line is shown.
The bright green color is very useful to show that the commit is signed.
# Answer
The `--show-signature` argument can be selected in the log popup but it is not actually passed to `git log`. Instead `%G?` is added to the value of the `--format=` argument.
That (`%G?`) causes some letter to be printed for each commit and the code that parses the log output detects that letter and uses it to determine what face should be used to display the commit message summary. The faces are named `magit-signature-...`. By default commits with "unproblematic" signatures are displayed the same way as regular text (i.e. like the `default` face), while other commits are displayed using some flashy color and therefore easily detected.
The reason the signatures are not shown in the log buffer is that Magit usually displays each commit on a single line. Displaying each commits signature on multiple lines would mess that up.
---
To actually find out what is wrong about the signature you will have to visit the commit itself by pressing `RET` while point is on that commit in the log.
By default the revision buffer also does not show the signature. To show the signature you have to enable the `--show-signature` argument for the *revision* buffer also. To do so visit the revision buffer as usual. Then type `D` to change the diff arguments used in the current buffer. Then enable the respective argument using `= g` and finally save that as the default while also refreshing the current buffer using `w`.
> 6 votes
---
Tags: magit, git, command-line-arguments
---
|
thread-52738
|
https://emacs.stackexchange.com/questions/52738
|
gnus viewer for attachments
|
2019-09-19T18:53:32.207
|
# Question
Title: gnus viewer for attachments
I recently started using gnus to view my emails. Opening attachments is still the most annoying part for me and I am trying to address that.
The behaviour I would like is: If the attachment is text-based then open in an emacs buffer in the same instance I am using, otherwise open using the system's `xdg-open`.
According to emacswiki, I created a file `~/.mailcap` with the single line
```
application/*; xdg-open %s
```
But then this line is just added to the application list in `/etc/mailcap`, which I have no control over, and I have to select `xdg-open` in the list that is shown to me every time I try to open an attachment. How can I prevent gnus from reading that file and instead directly open an attachment with `xdg-open`?
Also, how do I get text files to open in a buffer?
Finally, is there a way to open the attachment without going all the way to the file name in the email? Perhaps by showing a list of attachment and letting me choose one of them?
# Answer
> 3 votes
So many questions at once.
* emacs-27 will prefer ~/.mailcap entries to the system ones. See Mailcap precedence for details. You can build the emacs master branch from source to pick up those changes.
* The answer to your third question is: Check out the `K-` bindings in the Summary buffer:
```
K C gnus-article-view-part-as-charset
K E gnus-article-encrypt-body
K H gnus-article-browse-html-article
K O gnus-article-save-part-and-strip
K b gnus-summary-display-buttonized
K c gnus-article-copy-part
K d gnus-article-delete-part
K e gnus-article-view-part-externally
K i gnus-article-inline-part
K j gnus-article-jump-to-part
K m gnus-summary-repair-multipart
K o gnus-article-save-part
K r gnus-article-replace-part
K t gnus-article-view-part-as-type
K v gnus-article-view-part
K | gnus-article-pipe-part
```
(they all take numerical prefix arguments to specify which part you're talking about)
* For youre second question, you're looking for the unfortunately-named `gnus-article-copy-part`, which will create a buffer containing that part.
---
Tags: gnus
---
|
thread-52861
|
https://emacs.stackexchange.com/questions/52861
|
Exporting Org to PDF while displaying Regex literal strings
|
2019-09-27T15:27:02.833
|
# Question
Title: Exporting Org to PDF while displaying Regex literal strings
I've been searching for the past couple of days to a solution to an issue I'm having. Hoping somebody who is more apt with emacs/exporting could provide some insight.
Upon exporting an .org file (`C-c``C-e``l``o/p`) to LaTeX followed by PDF, my Regex text within the PDF document is handled (assuming) as a math equation. E.g. instead of displaying \[^ABC\] within the PDF, it is displayed as \[<sup>ABC</sup>\].
I have attempted to use \usepackage{verbatim}, with something like \verb/\[^ABC\]/, but I get different results. E.g. \[(^{\text{ABC}})\].
Is there a specific reason I'm missing that could be causing this? Or, something that I have not included within my init.el? For reference, here is the section of my init.el that is handling org-latex-classes:
```
(add-to-list 'org-latex-classes
'("adarticle"
"\\documentclass{article}
\\usepackage[utf8]{inputenc}
\\usepackage{verbatim}
\\usepackage[T1]{fontenc}
\\usepackage{graphicx}
\\usepackage{longtable}
\\usepackage{hyperref}
\\usepackage{natbib}
\\usepackage{amssymb}
\\usepackage{amsmath}
\\usepackage{geometry}
\\geometry{a4paper,left=2.5cm,top=2cm,right=2.5cm,bottom=2cm,marginparsep=7pt, marginparwidth=.6in}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
```
Edit: As suggested, wrapping expressions with '=' seems to do the trick for cases such as \[^ABC\] and \u{FFFF}.
# Answer
Org can be told to treat text as verbatim either by wrapping it in '=' markup (for words), or in a `#+BEGIN_EXAMPLE`/`#+END_EXAMPLE` block. See Emphasis-and-Monospace and Literal-Examples for details.
> 1 votes
---
Tags: org-export, latex, pdf
---
|
thread-52863
|
https://emacs.stackexchange.com/questions/52863
|
Remove occurrences in occur mode?
|
2019-09-27T16:00:18.960
|
# Question
Title: Remove occurrences in occur mode?
Is there a way to remove occurrences in Occur mode? In particular, this piece of functionality would allow you to remove occurrences in case you are interested in editing only some out of all occurrences in Occur mode.
Example: say I have this piece of code:
```
import os
import time
print("Just an example")
john.age = 44
anna.age = 55
print("Something")
bob.age = 83
```
If I run occur searching for "age", I get:
```
3 matches for "age" in buffer: untitled
6:john.age = 44
7:anna.age = 55
9:bob.age = 83
```
And after that I would like to have a function that allows me to, with the cursor in the desired line, remove that occurrence from the buffer so that any following edit will not have any effect into the removed occurrences. In the given example, if I did not want to edit line 7, I could run the desired function to get the occur buffer in the following new state:
```
3 matches for "age" in buffer: untitled
6:john.age = 44
9:bob.age = 83
```
I know that it is possible to use Narrowing commands inside an occur buffer, but that would not cover the case where my lines of interest are scattered around other occurrences and it would also not be as simple as selecting the lines I do not want to mess with. Also, having this functionality would save time from having to write complex regular expressions even in the case where we could get the specific occurrences we are interested in from a single search.
# Answer
An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.
Something as straightforward like this can help you:
```
(defun occur-kill-line()
"Quick and dirty discard line from occur resultset.
from https://emacs.stackexchange.com/a/52865/13589"
(interactive)
(let ((inhibit-read-only t))
(kill-whole-line)
(delete-blank-lines)))
```
invoking this function will kill the current line in occur buffer. Pressing `g` will revert the buffer.
Adding this:
```
(define-key occur-mode-map (kbd "k") 'occur-kill-line)
```
will bind `k` to `occur-kill-line` to `occur-mode-map` making it available as occur command just pressing `k`.
> 1 votes
# Answer
If you delete the entire line from the occur buffer, it will not touch the original buffer.
So press `e` to run `#'occur-edit-mode`, then delete the entire line (`C-k`).
> 5 votes
---
Tags: occur
---
|
thread-52852
|
https://emacs.stackexchange.com/questions/52852
|
Remapping global keybindings to a prefix command
|
2019-09-27T02:46:48.927
|
# Question
Title: Remapping global keybindings to a prefix command
The following works:
```
(define-prefix-command 'my-map)
(global-set-key (kbd "C-@") 'my-map) ;; MacOS
(global-set-key (kbd "C-SPC") 'my-map) ;; Windows 10
```
The following does not:
```
(global-set-key [remap set-mark-command] 'my-map)
```
It fails with the error that `my-map` is not a command (`commandp` returns nil).
The emacs manual states that "putting a remapping in a prefix keymap like `ctl-x-map` typically has no effect, as such keymaps are not themselves active;" however, I am remapping a command in the active global map to a prefix map. So why does this fail?
# Answer
> 1 votes
Unfortunately, the use of `[remap COMMMAND]` syntax in a key-binding definition seems to require `COMMAND` to be a symbol that is a command (`commandp`). It doesn't seem to allow a prefix-key keymap or a prefix-key variable whose value is a keymap.
I just sent a mail to `emacs-devel@gnu.org` about this. Maybe I'm missing something (probably). But it seems like (1) the doc string of `define-key` says that it should work, but (2) it doesn't.
---
If you want, you can do almost the same thing this way:
```
(substitute-key-definition 'set-mark-command 'my-map global-map)
```
That's almost the same thing as what you tried:
```
(global-set-key [remap set-mark-command] 'my-map)
```
It does, in effect, what you ended up doing manually by binding each key individually.
The difference from remapping is that, well the command `set-mark-command` is not remapped. Instead, you've just rebound each of its global keys to keymap (prefix command) `my-map`.
---
Tags: key-bindings, commands, prefix-keys
---
|
thread-52875
|
https://emacs.stackexchange.com/questions/52875
|
Org: adding category to non-top headers
|
2019-09-28T09:17:36.757
|
# Question
Title: Org: adding category to non-top headers
I use one unique `diary.org` file for my Org Agenda.
My file is structured as `:tree-type week`, hence is every entry like:
```
* 2019
** 2019-W21
*** 2019-05-26
**** entry
```
I would like to add category to any entry captured to this file, which I could do by editing my `org-capture` template.
However, categories don't show up in Org Agenda unless they're marking a file or a top-level item.
Do you know how to make categories work for non-top headers?
# Answer
I do the following and it seems to work for headings that are not the top-level:
```
** not a top heading
:PROPERTIES:
:CATEGORY: category_name
:END:
*** TODO this will be in agenda with category_name
```
> 0 votes
---
Tags: org-mode, org-agenda
---
|
thread-2740
|
https://emacs.stackexchange.com/questions/2740
|
Trouble sorting customized priorities in org-mode
|
2014-10-28T00:42:03.203
|
# Question
Title: Trouble sorting customized priorities in org-mode
I'm trying to setup priorities other than A, B, C. (I want to do U, I, O; short for Urgent, Important, Other). Previously, I had set up custom agenda commands that sorted `priority-down`.
I configured my priorities like this:
```
(setq org-highest-priority ?U)
(setq org-default-priority ?I)
(setq org-lowest-priority ?O)
```
Then when I viewed my agendas I noticed that rather than sorting in priority order, it seems to be using alphabetical order.
What am I doing wrong here?
# Answer
Just looked at the source for org.el, and found this frustrating snippet:
```
(defcustom org-highest-priority ?A
"The highest priority of TODO items. A character like ?A, ?B etc.
Must have a smaller ASCII number than `org-lowest-priority'."
:group 'org-priorities
:type 'character)
```
It would appear that org-mode wants the custom priorities to also be alphabetically ordered.
I thought you might've been able to use `org-get-priority-function` to work around this, but the source code appears to be simply calling the priority fn with no args, instead of taking the string as an arg.
My attempted work-around was to use these priorities:
```
(setq org-highest-priority ?U)
(setq org-default-priority ?i)
(setq org-lowest-priority ?o)
```
But this didn't work because of this pesky regex in org.el:
```
(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
"Regular expression matching the priority indicator.")
```
So what I've finally come up with is to use these priorities:
```
(setq org-highest-priority ?G) ;; UrGent
(setq org-default-priority ?I) ;; Important
(setq org-lowest-priority ?O) ;; Other
```
> 3 votes
# Answer
I have also been trying to get org-mode to integrate properly with the idea of urgent vs important tasks. Considering that they are actually supposed to be independent dimensions, I think the more natural way to represent these concepts is to map level of importance to Org's priority, and to map level of urgency to the amount of time remaining before an Org deadline arrives.
I'm still figuring out how to make use of such a setup by creating a custom use of Org's mapping API (http://orgmode.org/manual/Using-the-mapping-API.html) which collects tasks tagged in an appropriate way, and represents them in a table sorted first by TODO status, then by PRIORITY, then by DEADLINE.
(Quite possibly Org's agenda functionality is capable of doing what i'm trying to do manually, but I've always been a bit leery of agenda seeming to "lose" tasks whose deadline has passed, where i actually still want to see them.)
> 1 votes
# Answer
The docs tell you to
> please make sure that the highest priority is earlier in the alphabet than the lowest priority
Apart from that, @Roger Mateer's suggestion to use deadlines and scheduling for urgency and priorities for importance seems to ring a bell. That is how Stephen Covey differentiates it, for example: with two scales; one from important to unimportant. One from urgent to non-urgent.
A possibility would be to expand to
#+PRIORITIES: A F D
at the top of your file, with `A-C` as important and `D-F` as unimportant.
> 0 votes
# Answer
Please tend a close attention to what docs say:
```
org-get-priority-function is a variable defined in ‘org.el’.
Its value is nil
Documentation:
Function to extract the priority from a string.
The string is normally the headline. If this is nil Org computes the
priority from the priority cookie like [#A] in the headline. It returns
an integer, increasing by 1000 for each priority level.
The user can set a different function here, which should take a string
as an argument and return the numeric priority.
```
So, this is the ***variable*** that should contain the ***name*** of a ***function***. This ***function*** should get a ***string*** (headline) as an argument, and return a ***number***.
In other words - it is what you, & I, are searching for. Just write the global function any way you like and provide the name for it.
In **Org-mode the source code** block that processes a priority:
`org.el`:
```
(defun org-get-priority (s)
"Find priority cookie and return priority."
(save-match-data
(if (functionp org-get-priority-function)
(funcall org-get-priority-function)
(if (not (string-match org-priority-regexp s))
(* 1000 (- org-lowest-priority org-default-priority))
(* 1000 (- org-lowest-priority
(string-to-char (match-string 2 s))))))))
```
So first `if` separates the `true` case - usage of custom function, and in `else` \- provides the default implementation.
So we have default implementation and the *regex* that selects the priority from the header:
```
(defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]\\)\\] ?\\)"
"Regular expression matching the priority indicator.")
```
So now you have everything to create your implementation.
You are also right that function call does not gives the headline as arg.
You can just overload `org-get-priority` with your definition.
Thou that does not fully works (faces, modify functions) since there is some hard-code processing priorities as chars, and a magic `(* 1000 ...)` numbering around.
I've send a patch fixing the call for function in `org-get-priority-function` and some other patches around that.
Since you gone already so far - you can also get in, there is a lot of easy fixes to do regarding priorities.
> 0 votes
---
Tags: org-mode
---
|
thread-52882
|
https://emacs.stackexchange.com/questions/52882
|
Display time of "You can run the command ... with ..." minibuffer hints
|
2019-09-28T20:53:27.947
|
# Question
Title: Display time of "You can run the command ... with ..." minibuffer hints
I type in, for example, `M-x occur` and it says `You can run the command occur with M-s o`.
How can I make that last hint display for more than one second?
# Answer
It defaults to 2 seconds, so you shouldn't need to do anything for it stay for more than one second ;-)
But if 2 isn't enough, just customize `suggest-key-bindings`.
> 3 votes
---
Tags: key-bindings, minibuffer
---
|
thread-52858
|
https://emacs.stackexchange.com/questions/52858
|
How can Markdown mode follow links?
|
2019-09-27T08:02:18.783
|
# Question
Title: How can Markdown mode follow links?
I found this today by chance: I visited the help file on `split-string` with `C-h f split-strings`:
> split-string is a compiled Lisp function in ‘subr.el’.
>
> (split-string STRING &optional SEPARATORS OMIT-NULLS TRIM)
except that `subr.el` is underlined like a hyperlink and doing `RET` with point on it opens the source code.
I copied it this section to a Markdown file and the text was still underlined. I did `RET` with point on it and it also opened the source code!
I have these modes active in the document: `[(Markdown ElDoc Wrap Fill)]`. If I type the same characters as in `‘subr.el’` (copy-pasting the quotes, which I don't have in my keyboard), it is not highlighted and `RET` does not follow the link.
Including hyperlinks like this one in Markdown is the one thing where I see org mode as superior to markdown mode.
Is it possible to add my own links to other files in markdown mode?
**Update**: The ability to follow the link with `RET` is lost when killing and yanking the text that contains `‘subr.el’.`, or closing and opening the buffer for the file, so I believe this is some special ability in Emacs that comes from copying text from a documentation file and not a feature of Markdown mode.
# Answer
> 7 votes
`markdown-follow-thing-at-point` (`C-c C-o`) and also `markdown-follow-link-at-point` will follow links. If you have a link like `[filelink](/path/to/file.md)` then calling one of the above functions while cursor is on the markdown link will take you to the file.
---
Tags: markdown, hyperlinks, markdown-mode
---
|
thread-52881
|
https://emacs.stackexchange.com/questions/52881
|
How can I make emacs monochrome in no-window-system mode?
|
2019-09-28T20:22:57.157
|
# Question
Title: How can I make emacs monochrome in no-window-system mode?
I prefer to run emacs as a console application, and I would prefer that it be monochrome. I currently have `(global-font-lock-mode 0)` set in my init file, which works as I want it to on my mac. However, on my new debian laptop, I find that this (correctly) disables syntax highlighting in the body of files, but text in the echo area is showing in blue, which is hard to read on a black background.
Is there a way to ask emacs to be entirely monochrome?
# Answer
> 1 votes
The "hard to read echo area messages on dark background" is because under ttys, the colors are set by default under the assumption of a light background (and because there's no way for Emacs to query the terminal to know whether the background is dark or not).
You can fix this problem by customizing `frame-background-mode`.
It won't make Emacs fully monochrome, tho. Maybe you can get this result with a crude hack like the one below (guaranteed 100% untested), but please don't say it comes from me:
```
(advice-add 'face-spec-set-2 :around
(lambda (f face frame attrs)
(funcall f face frame (plist-put attrs :foreground nil))))
```
# Answer
> 1 votes
I set the colors directly on the xterm window using ~/.Xresources, or ~/.Xdefaults (whichever works for your system) according to
```
XTerm*termName: xterm-256color ! This forces 256 colors
XTerm*background: black
XTerm*foreground: white
XTerm*faceName: DejaVu Sans Mono Book ! This is a truetype font
XTerm*faceName: Monospace
XTerm*faceSize: 10
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48
```
This way `emacs -nw -q` gives me a black-and-white emacs.
---
Tags: fonts
---
|
thread-52867
|
https://emacs.stackexchange.com/questions/52867
|
Can Emacs render family emojis? (Emoji ZWJ Sequences)
|
2019-09-27T18:47:31.983
|
# Question
Title: Can Emacs render family emojis? (Emoji ZWJ Sequences)
For example (explained on Emojipedia):
# Answer
> 2 votes
Have a look at the emojify package.
# Answer
> 1 votes
Yes, if you have the Symbola font installed, it will make use of it to render emojis:
---
Tags: fonts, unicode
---
|
thread-24105
|
https://emacs.stackexchange.com/questions/24105
|
How to list keybinding for a particular keymap (evil-mode)?
|
2016-06-22T08:30:25.837
|
# Question
Title: How to list keybinding for a particular keymap (evil-mode)?
I am trying out `evil-mode`, and it seems promising. Now I would like to get an overview of the keybindings introduced in `evil-normal-state-map`. If I type `C-h v RET evil-normal-state-map` I get:
```
Value: (keymap
(164 . evil-end-of-line)
(mouse-2 . mouse-yank-primary)
(18 . redo)
(117 . undo)
(remap keymap
(yank-pop . evil-paste-pop)
(cua-paste-pop . evil-paste-pop))
(escape . evil-force-normal-state)
(127 . evil-backward-char)
(90 keymap
(81 . evil-quit)
(90 . evil-save-modified-and-close))
(62 . evil-shift-right)
(60 . evil-shift-left)
(61 . evil-indent)
(126 . evil-invert-char)
(34 . evil-use-register)
(64 . evil-execute-macro)
(46 . evil-repeat)
(27 keymap
(46 . evil-repeat-pop-next))
(67108910 . evil-repeat-pop)
(20 . pop-tag-mark)
(16 . evil-paste-pop)
(14 . evil-paste-pop-next)
(122 keymap
(61 . ispell-word)
(109 . evil-close-folds)
(114 . evil-open-folds)
(97 . evil-toggle-fold)
(99 . evil-close-fold)
(79 . evil-open-fold-rec)
(111 . evil-open-fold))
(103 keymap
(44 . goto-last-change-reverse)
(59 . goto-last-change)
(126 . evil-invert-case)
(63 . evil-rot13)
(70 . evil-find-file-at-point-with-line)
(102 . find-file-at-point)
(85 . evil-upcase)
(117 . evil-downcase)
(119 . evil-fill)
(113 . evil-fill-and-move)
(74 . evil-join-whitespace)
(105 . evil-insert-resume)
(97 . what-cursor-position)
(56 . what-cursor-position)
(38 . evil-ex-repeat-global-substitute))
(38 . evil-ex-repeat-substitute)
(89 . evil-yank-line)
(121 . evil-yank)
(deletechar . evil-delete-char)
(88 . evil-delete-backward-char)
(120 . evil-delete-char)
(83 . evil-change-whole-line)
(115 . evil-substitute)
(82 . evil-replace-state)
(114 . evil-replace)
(113 . evil-record-macro)
(80 . evil-paste-before)
(112 . evil-paste-after)
(79 . evil-open-above)
(111 . evil-open-below)
(109 . evil-set-marker)
(74 . evil-join)
(73 . evil-insert-line)
(insertchar . evil-insert)
(insert . evil-insert)
(105 . evil-insert)
(68 . evil-delete-line)
(100 . evil-delete)
(67 . evil-change-line)
(99 . evil-change)
(65 . evil-append-line)
(97 . evil-append))
```
How can I transform this into human-readable form? It would be nice if I could have the table in the format given by `describe-mode`, e.g.:
```
key binding
--- -------
C-c Prefix Command
C-d elisp-edebug
(that binding is currently shadowed by another mode)
ESC Prefix Command
DEL backward-delete-char-untabify
....
```
# Answer
> 4 votes
I don't know of any way to do this in vanilla Emacs without effective writing your own code, but the function `describe-keymap` (`C-h M-k`) in the help-fns+.el package does exactly this.
> `describe-keymap` (`C-h M-k`) – Describe the bindings in a keymap. Enter the keymap variable (e.g., `ctl-x-map`) using completion. (Non-interactively, the argument can be a keymap itself or a keymap variable.)
# Answer
> 1 votes
Beside `describe-keymap` function `which-key-dump-bindings` can be useful what key-bindings my modes provides.
`which-key-dump-bindings` answers the question **Which key bindings I can use in this buffer?**. Function will allow you understand which `minor`, `major` modes keys and global key bindings are active and can be used.
Usage: Function will ask for prefix:
If you provide:
`Directly pressing enter` will show you every possible keys in this buffer.
`C-x` it's same as `ctl-x-map`
`C-x 4` is equal to `ctl-x-4-map`
---
Tags: evil, keymap
---
|
thread-52808
|
https://emacs.stackexchange.com/questions/52808
|
org mode: Can't add deadline to headline (wrong number or arguments)
|
2019-09-24T11:19:28.300
|
# Question
Title: org mode: Can't add deadline to headline (wrong number or arguments)
I have been having the following issue for a whilst now. I try to add a deadline to a headline and I receive the following error:
`Wrong number of arguments: (1 . 2), 0`. Here is the corresponding backtrace:
```
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 0)
#f(compiled-function (arg &optional time) "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.\nWith one universal prefix argument, remove any deadline from the item.\nWith two universal prefix arguments, prompt for a warning delay.\nWith argument TIME, set the deadline at the corresponding date. TIME\ncan either be an Org date like \"2011-07-24\" or a delta like \"+2d\"." (interactive "P") #<bytecode 0x1e5d005>)()
apply(#f(compiled-function (arg &optional time) "Insert the \"DEADLINE:\" string with a timestamp to make a deadline.\nWith one universal prefix argument, remove any deadline from the item.\nWith two universal prefix arguments, prompt for a warning delay.\nWith argument TIME, set the deadline at the corresponding date. TIME\ncan either be an Org date like \"2011-07-24\" or a delta like \"+2d\"." (interactive "P") #<bytecode 0x1e5d005>) nil)
org-deadline()
funcall-interactively(org-deadline)
call-interactively(org-deadline record nil)
command-execute(org-deadline record)
helm-M-x(nil #("org-deadline" 0 12 (match-part "org-deadline")))
funcall-interactively(helm-M-x nil #("org-deadline" 0 12 (match-part "org-deadline")))
call-interactively(helm-M-x nil nil)
command-execute(helm-M-x)
```
I receive this error **before** I am given the option to select a date from the calendar for the deadline.
I also receive a similar error (`Wrong number of arguments (0 . 0), 2`) when trying to set a deadline in the agenda view, however I am able to select a date from the calendar and weirdly the deadline actually gets created. `toggle-debug-on-error` doesn't present a backtrace upon doing this, yet the error message above is displayed nonetheless. I provide this agenda issue in case it contains useful information, but the issue at hand is that I cannot add deadlines to headlines.
I have tried updating org-mode and the problem persists.
I am using Emacs 26.2, Spacemacs v.0.200.13 and Org Mode 9.2.6.
Please let me know if I am missing any other key information and thank you for your help.
**Additional information:**
Result of calling `C-h f org-deadline`:
```
org-deadline is an interactive compiled Lisp function in ‘org.el’.
It is bound to M-RET d, M-m m d, C-c C-d, and many ordinary text characters.
(org-deadline ARG &optional TIME)
:after advice: ‘org-save-all-org-buffers’
Insert the "DEADLINE:" string with a timestamp to make a deadline.
With one universal prefix argument, remove any deadline from the item.
With two universal prefix arguments, prompt for a warning delay.
With argument TIME, set the deadline at the corresponding date. TIME
can either be an Org date like "2011-07-24" or a delta like "+2d".
[back]
```
# Answer
> 2 votes
You added `org-save-all-org-buffers` as `:after` advice of `org-deadline`. The documentation of `org-save-all-org-buffers` says that it is an *interactive* function *without* arguments. But `org-deadline` has one obligatory argument which is deduced from the prefix-arg in interactive calls.
So you advise an interactive function with an interactive function.
The documentation of `add-function`, which is also valid for `advice-add`, says:
> If one of FUNCTION or OLDFUN is interactive, then the resulting function is also interactive. There are 3 cases:
>
> * FUNCTION is not interactive: the interactive spec of OLDFUN is used.
> * The interactive spec of FUNCTION is itself a function: it should take one argument (the interactive spec of OLDFUN, which it can pass to ‘advice-eval-interactive-spec’) and return the list of arguments to use.
> * Else, use the interactive spec of FUNCTION and ignore the one of OLDFUN.
The third case is relevant for you. The interactive spec of the advising function `org-save-all-org-buffers` is used for `org-deadline` which is wrong since it does not supply the required argument.
If you want an `:after`-advice working for all interactive functions you can use the `&rest` keyword in the definition of the advising function to ignore all arguments:
```
(defun my-org-save-all-org-buffers (&rest _ignore)
"Apply `org-save-all-org-buffers' ignoring all arguments."
(org-save-all-org-buffers))
(advice-add 'org-deadline :after #'my-org-save-all-org-buffers)
```
---
User quantum285 found the error himself after some help from me.
The following comment from me was a full hit:
> call-interactively uses interactive-form to determine how the user should be queried for the arguments of the command. That fails in the above backtrace. funcall-interactively is called with the command name as its only argument. Please, call M-: (interactive-form 'org-deadline) and report the result. It should be (interactive "P") but I assume that it is just (interactive) in your case which is wrong.
When quantum285 acknowledged that, I asked him to add the full help string of `org-deadline` to his question since I knew that the advice system adds advice information to that doc string.
After reading the doc string of `org-deadline` user quantum285 identified the advice with `org-save-all-org-buffers` as the culprit.
He asked me add an answer with the root cause of the problem. There we are...
---
Tags: org-mode, spacemacs
---
|
thread-52898
|
https://emacs.stackexchange.com/questions/52898
|
Selecting next occurrence of word incrementally
|
2019-09-29T22:13:03.360
|
# Question
Title: Selecting next occurrence of word incrementally
I want to make changes inside a paragraph of a large text file.
If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.
I'm looking to replace "foo" with "bar" in a paragraph.
This is similar to Sublime Text's `Ctrl-D`
# Answer
> 2 votes
1. With point at the beginning of the word you want to replace, e.g., `foo`:
**`C-s C-w M-%`**
2. Then type the replacement word, e.g. `bar`, then `RET`.
3. Then follow the prompts to query-replace subsequent occurrences of `foo`. (You can use **`!`** to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (`C-x n n`). Alternatively, just quit query-replace after that paragraph (using **`q`**), or quit it at the last replacement (**`.`**).
Explanation:
`C-s` starts Isearch (incremental search). An immediate `C-w` yanks the text from point to the end of the word at point (e.g. `foo`) to the search string, so `C-s C-w` searches for that word.
`M-%` while searching switches to `query-replace`, using the search-string as the text to replace.
---
A minor shortcut for this question: you can use `M-% M-n` instead of `C-s C-w M-%` if you use library Replace+ (`replace+.el`)
With Replace+, `query-replace` and similar commands provide this behavior out of the box. Just use `M-n` to insert the word at point - it's the default `FROM` pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options `search/replace-region-as-default-flag`, `search/replace-2nd-sel-as-default-flag`, and `search/replace-default-fn`.)
And option `replace-w-completion-flag`, if non-`nil`, provides for minibuffer completion while you type the arguments. In that case, to insert a `SPC` or `TAB` character, you will need to precede it by `C-q`.
# Answer
> 2 votes
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command `mc/mark-next-like-this-work` should do what you want. Then you can bind it to some custom keybinding like `C-d`:
```
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
```
---
Tags: search, replace
---
|
thread-52900
|
https://emacs.stackexchange.com/questions/52900
|
Is there a way to connect to a REPL without comint?
|
2019-09-30T00:18:20.723
|
# Question
Title: Is there a way to connect to a REPL without comint?
The performance of comint is not good when handling outputs of some REPL. Is there a way to connect to some REPL outside Emacs and let result display there, like in a terminal/browser/something else?
(I also tried to eval Python code in vscode, their REPL 'running inside the editor' is handling outputs much more efficiently. Maybe they use something like comint in `vscode` or maybe not.)
# Answer
> 1 votes
There is `start-process`, which internally calls `make-process`.
start-process is a compiled Lisp function in ‘subr.el’.
(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
Start a program in a subprocess. Return the process object for it. NAME is name for process. It is modified if necessary to make it unique. BUFFER is the buffer (or buffer name) to associate with the process.
---
WRT large output python-mode.el provides commands like py-execute-block-fast:
(py-execute-block-fast &optional SHELL DEDICATED SWITCH BEG END FILE)
Process block at point by a Python interpreter.
Output buffer not in comint-mode, displays "Fast" by default.
---
Tags: comint, repl
---
|
thread-52905
|
https://emacs.stackexchange.com/questions/52905
|
Why does emacs not apply some config settings when editing tex files?
|
2019-09-30T10:56:33.103
|
# Question
Title: Why does emacs not apply some config settings when editing tex files?
I'm facing a rather peculiar situation where my emacs settings seem to be lost every time that I open a `.tex` file. That's doesn't happen when I'm editing `.el` or `.py` files. Heres some examples with normal setting editing `.el` file
And here when I try to edit `.tex` file
Any ideas what have gone wrong here?
Thanks! Original post posted here initially.
# Answer
The answer to my problem was a comment from `The_Blackbeard` user at reddit. `Have you taken into account that while emacs-lisp-mode derives from prog-mode, tex-mode derives from text-mode?`
Once I had that information the rest was easy to fix.
The solution was to add a hook: `(add-hook 'text-mode-hook '(fci-mode linum-mode))`
> 2 votes
---
Tags: auctex, text-editing
---
|
thread-52722
|
https://emacs.stackexchange.com/questions/52722
|
ein login error due to curl version not support compressed
|
2019-09-18T18:51:40.940
|
# Question
Title: ein login error due to curl version not support compressed
I am using win10, emacs version is GNU Emacs 26.3. python version is Python3.6.8. After install EIN (EIN version is 20190813.2156) package and try to run M-x ein:login, I got below error message:
```
ein: [error] Login to http://127.0.0.1:8888/?token=b804af75f6744bf1b247909945a875ba1056143bca05a330 failed,
error-thrown (error . exited abnormally with code 2 ),
raw-header curl: option --compressed:
the installed libcurl version doesn't support this
curl: try 'curl --help' for more information
```
Mark set \[3 times\]
How should I fix this curl issue?
# Answer
I was able to bypass the issue (at least connects) by commenting the --compressed line in request.el ~/.emacs.d/elpa/.../request-20190923.1502/request.el
line 909 inside (cl-defun request--curl-command)
```
;; FIXME: test automatic decompression
;; "--compressed" ;; this line originally was not commented
```
Maybe the automatic decompression in windows was not tested? its strange because curl (from anaconda or cygwin) have the compressed flag
```
curl --help
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
-E, --cert <certificate[:password]> Client certificate file and password
--cert-status Verify the status of the server certificate
--cert-type <type> Certificate file type (DER/PEM/ENG)
--ciphers <list of ciphers> SSL ciphers to use
--compressed Request compressed response
--compressed-ssh Enable SSH compression
...
```
I know it's a hack and not a solution, so use at your own discretion.
> 0 votes
# Answer
Check if you have curl package installed in python/conda library. I was getting the same error when starting jupyter notebook, where curl installation from win32 library was being picked up. Also make sure your PATH precedence picks up the correct curl installation.
To check for curl installation on Windows, start cmd prompt:
`where curl`
which returns all instances of curl (in order). Make sure Python/Conda install takes precedence.
> 0 votes
---
Tags: ein, jupyter
---
|
thread-52895
|
https://emacs.stackexchange.com/questions/52895
|
emacs org bullets not working
|
2019-09-29T18:01:07.263
|
# Question
Title: emacs org bullets not working
I'm using emacs on ubuntu 19.04. This is my init file
```
(use-package org
:ensure t
:pin org)
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
```
bullets are not supported in the terminal mode as well as GUI mode
What am I doing wrong?
I tried `M-x RET revert-buffer-with-coding-system` and tried different UTF encodings available such as `utf-8`, `utf-8-unix`, `utf-8-dos`, `utf-8-mac`, `prefer-utf-8`, `prefer-utf-8-unix` and so on.. but no sulution
`M-x RET describe-current-coding` output
```
Coding system for saving this buffer:
U -- utf-8-dos (alias: mule-utf-8-dos cp65001-dos)
Default coding system (for new files):
U -- utf-8 (alias: mule-utf-8 cp65001)
Coding system for keyboard input:
U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)
Coding system for terminal output:
U -- utf-8 (alias: mule-utf-8 cp65001)
Coding system for inter-client cut and paste:
nil
Defaults for subprocess I/O:
decoding: U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)
encoding: U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix)
Priority order for recognizing coding systems when reading files:
1. utf-8 (alias: mule-utf-8 cp65001)
2. iso-2022-7bit
3. iso-latin-1 (alias: iso-8859-1 latin-1)
4. iso-2022-7bit-lock (alias: iso-2022-int-1)
5. iso-2022-8bit-ss2
6. emacs-mule
7. raw-text
8. iso-2022-jp (alias: junet)
9. in-is13194-devanagari (alias: devanagari)
10. chinese-iso-8bit (alias: cn-gb-2312 euc-china euc-cn cn-gb gb2312)
11. utf-8-auto
12. utf-8-with-signature
13. utf-16
14. utf-16be-with-signature (alias: utf-16-be)
15. utf-16le-with-signature (alias: utf-16-le)
16. utf-16be
17. utf-16le
18. japanese-shift-jis (alias: shift_jis sjis)
19. chinese-big5 (alias: big5 cn-big5 cp950)
20. undecided
Other coding systems cannot be distinguished automatically
from these, and therefore cannot be recognized automatically
with the present coding system priorities.
Particular coding systems specified for certain file names:
OPERATION TARGET PATTERN CODING SYSTEM(s)
--------- -------------- ----------------
File I/O "\\.tzst\\'" (no-conversion . no-conversion)
"\\.zst\\'" (no-conversion . no-conversion)
"\\.dz\\'" (no-conversion . no-conversion)
"\\.txz\\'" (no-conversion . no-conversion)
"\\.xz\\'" (no-conversion . no-conversion)
"\\.lzma\\'" (no-conversion . no-conversion)
"\\.lz\\'" (no-conversion . no-conversion)
"\\.g?z\\'" (no-conversion . no-conversion)
"\\.\\(?:tgz\\|svgz\\|sifz\\)\\'"
(no-conversion . no-conversion)
"\\.tbz2?\\'" (no-conversion . no-conversion)
"\\.bz2\\'" (no-conversion . no-conversion)
"\\.Z\\'" (no-conversion . no-conversion)
"\\.elc\\'" utf-8-emacs
"\\.el\\'" prefer-utf-8
"\\.utf\\(-8\\)?\\'" utf-8
"\\.xml\\'" xml-find-file-coding-system
"\\(\\`\\|/\\)loaddefs.el\\'"
(raw-text . raw-text-unix)
"\\.tar\\'" (no-conversion . no-conversion)
"\\.po[tx]?\\'\\|\\.po\\."
po-find-file-coding-system
"\\.\\(tex\\|ltx\\|dtx\\|drv\\)\\'"
latexenc-find-file-coding-system
"" (undecided)
Process I/O nothing specified
Network I/O nothing specified
```
# Answer
adding the following into my init file solved the issue
```
(set-language-environment 'utf-8)
(setq locale-coding-system 'utf-8)
;; set the default encoding system
(prefer-coding-system 'utf-8)
(setq default-file-name-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; Treat clipboard input as UTF-8 string first; compound text next, etc.
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
```
> 0 votes
# Answer
You should make sure that your terminal font supports UTF, or whatever you've decided to use for your bullet. This works for me in terminal with Inconsolata. You might want to check out nerd fonts in case you're having trouble finding something that will properly display
```
(use-package org-bullets
:hook (org-mode . org-bullets-mode)
:config
(setq org-bullets-bullet-list '("◉" "⁑" "⁂" "❖" "✮" "✱" "✸")))
```
> 0 votes
---
Tags: org-mode, terminal-emacs, ubuntu
---
|
thread-38865
|
https://emacs.stackexchange.com/questions/38865
|
Painfully slow encoding popup with "temp file" when creating new file
|
2018-02-16T15:24:44.947
|
# Question
Title: Painfully slow encoding popup with "temp file" when creating new file
Around half the time (and I haven't established a solid repro that triggers it), opening a new file in emacs will trigger a big pause, then two windows appear: one showing `*temp file*` and one asking me to choose encoding for the temp file. This is on a beefy windows 10 machine with windows 25.1.1.
I'm running on prelude and mostly use projectile, but it happens outside of projectile and I've cleared projectile's file list. Emacs has been rebooted multiple times.
Anyone know how I can stop this? Maybe I need to manually clear this temp file, but where does it live?
# Answer
> 0 votes
This continued, with variations, for years. It didn't happen on my other machines that sync'd the same dotfiles.
I finally fixed it by deleting a bunch of the files under ~.emacs.d\savefile. Will update if the problem comes back.
# Answer
> 0 votes
My guess is:
* You're calling `find-file` or similar.
* You have some kind of custom completion framework installed which is kicking in automatically at this point in order to present you with a selection of files to choose from. (Based on the screenshot, this is presumably `helm`).
* The framework is using this `*temp*` buffer to process its data.
* One or more of your files contains one or more funky characters in its filename.
The warning buffer gives you an interface for inspecting the characters with encoding issues, which will surely take you to the filenames in question, which will give you some more information/context about why and when this issue occurs, and allow you to provide a recipe to reproduce the issue.
Armed with that recipe, you could then pose the question upstream to the maintainer of the framework in question.
---
Tags: character-encoding
---
|
thread-52916
|
https://emacs.stackexchange.com/questions/52916
|
Unrecognisable code set by Customize
|
2019-09-30T21:38:55.190
|
# Question
Title: Unrecognisable code set by Customize
I was looking through my *.emacs.el* file and saw that *Customize* has put the following in it:
```
'(org-mode-hook
(quote
(#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-show-block-all append local]
5]
#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-babel-show-result-all append local]
5]
org-babel-result-hide-spec org-babel-hide-all-hashes org-bullets-mode org-sticky-header-mode org-ac org-autolist-mode)))
```
What do the first two lines between `(quote` and `org-babel-result-hide-spec...` do?
# Answer
Someone (possibly you; but maybe org-mode itself -- I've seen it in the past) is adding lambda forms to a hook variable.
What you're seeing is the byte-code for the compiled function. This makes the hook var horrible to read, which is one of the many reasons why you shouldn't put lambdas in hooks (and should instead create named functions and add the function symbol to the hook).
In this case I believe the offending code would be along the lines of:
```
(add-hook 'org-mode-hook (lambda () (add-hook 'change-major-mode-hook 'org-babel-show-result-all 'append 'local)))
```
and:
```
(add-hook 'org-mode-hook (lambda () (add-hook 'change-major-mode-hook 'org-show-block-all 'append 'local)))
```
If it's your code, then don't do that.
If it's not you, then I would raise a bug report for whichever code is doing it.
---
*Edit:* Looks like org's fault to me.
`org.el`:
```
;; Remove overlays when changing major mode
(add-hook 'org-mode-hook
(lambda () (add-hook 'change-major-mode-hook
'org-show-block-all 'append 'local)))
```
`ob-core.el`:
```
;; Remove overlays when changing major mode
(add-hook 'org-mode-hook
(lambda () (add-hook 'change-major-mode-hook
'org-babel-show-result-all 'append 'local)))
```
I think there might be an existing bug report for this, and so it might have been fixed upstream already, but have a hunt and see what you can find.
> 2 votes
---
Tags: customize, bytecode
---
|
thread-30344
|
https://emacs.stackexchange.com/questions/30344
|
How to link and open a PDF file to a specific page -- skim / adobe?
|
2017-02-01T04:05:46.543
|
# Question
Title: How to link and open a PDF file to a specific page -- skim / adobe?
**Q**: How can I create a link in `org-mode` to a specific page of a PDF file, which can be opened (in either Skim or Adobe) with a mouse-click?
```
* My example heading. :tag:
[[pdf:/path/to/file.pdf#105][My description.]]
```
# Answer
The following answer is for `Skim` on OSX, and it utilizes `applescript`. Skim does not have any command-line options to open a PDF file to a specific page, unless it is a forward-search situation dealing with a TeX file and the built-in Skim `displayline` utility.
Example heading in `org-mode`:
```
* My example heading. :tag:
[[pdf:/path/to/file.pdf#105][My description.]]
```
The code:
```
(require 'org)
(org-add-link-type "pdf" 'org-pdf-open nil)
(defun org-pdf-open (link)
"Where page number is 105, the link should look like:
[[pdf:/path/to/file.pdf#105][My description.]]"
(let* ((path+line (split-string link "#"))
(pdf-file (car path+line))
(base-filename (file-name-nondirectory pdf-file))
(page (car (cdr path+line)))
(script
(format
"tell document \"%s\" of application \"Skim\" to go to page %s"
base-filename page))
(skim-program "/Applications/Skim.app/Contents/MacOS/Skim"))
(set-process-sentinel
(start-process "skim-process" nil "open" "-a" skim-program pdf-file)
`(lambda (p e) (when (= 0 (process-exit-status p))
(when ,page ;; just in case user wants to omit the page number from the link
(start-process "goto-page" nil "osascript" "-e" ,script)))))))
```
> 2 votes
# Answer
On OSX (now macOS), you can simply use `org-mac-link.el`, it supports Skim and Adobe Acrobat Pro. To use, open pdf file in Skim and go to the page you want to link, then type `M-x org-mac-grab-link` from Emacs, it should insert an org link (like the following) at point.
```
[[skim:///Users/xcy/Downloads/calccard.pdf::2][calccard.pdf, p. 2]]
```
then when you click the link, the pdf file will be opened in Skim and goto page 2, no matter if Skim is running.
---
You can get `org-mac-link.el` from
* `org-mac-link` on Melpa
* `org-plus-contrib` on Org Elpa
* Org Mode's git repo
unless you install `org-mac-link` on Melpa via `package.el`, you have to autoload `org-mac-grab-link` etc or require `org-mac-link.el` somewhere by yourself.
> 3 votes
# Answer
This is what I use for **evince** on **Linux** (a modified version of lawlist's answer):
```
(org-add-link-type "pdf" 'org-pdf-open nil)
(defun org-pdf-open (link)
"Where page number is 105, the link should look like:
[[pdf:/path/to/file.pdf#page=105][My description.]]"
(let* ((path+page (split-string link "#page="))
(pdf-file (car path+page))
(page (car (cdr path+page))))
(start-process "view-pdf" nil "evince" "--page-index" page pdf-file)))
```
> 2 votes
---
Tags: org-mode
---
|
thread-52911
|
https://emacs.stackexchange.com/questions/52911
|
How do I disable a flymake backend?
|
2019-09-30T16:54:03.863
|
# Question
Title: How do I disable a flymake backend?
I'm looking to follow this other answer regarding linting inside org-mode source code block but I'm not able to figure out how to tell flymake to disable certain backends.
I'm using Emacs 27.x
# Answer
> 3 votes
See `flymake-diagnostic-functions`:
> The functions in this hook diagnose problems in a buffer’s contents and provide information to the Flymake user interface about where and how to annotate problems diagnosed in a buffer.
Just remove function that you don't need like this:
```
(remove-hook 'flymake-diagnostic-functions 'flymake-function-that-you-dont-need)
```
---
Tags: flymake
---
|
thread-52913
|
https://emacs.stackexchange.com/questions/52913
|
Magit-todos warning: File is too long, consider excluding it from scans
|
2019-09-30T20:47:49.903
|
# Question
Title: Magit-todos warning: File is too long, consider excluding it from scans
Whenever I do something in Magit buffer I get this warning:
```
Warning (magit-todos): File has lines too long for Emacs to search. Consider excluding it from scans: path/to/file
```
In particular it complains about socket.io.js.map
I tried excluding the file from projectile - no effect. I don't understand which scans the warning is talking about.
# Answer
Set `magit-todos-exclude-globs` variable.
It can be set globally:
```
(setq magit-todos-exclude-globs '(patterns))
```
in config or locally, per-repository.
To set it locally, run `add-dir-local-variable`, choose `magit-status-mode`, choose `magit-todos-exclude-globs`, add patterns you would like to exclude as a list.
Example: `("*.map" "*.html")`
That will generate `.dir-locals.el` with the appropriate configuration.
> 5 votes
---
Tags: magit
---
|
thread-9530
|
https://emacs.stackexchange.com/questions/9530
|
How can I get an org-mode outline in a 2nd buffer as a dynamic table of contents?
|
2015-02-24T15:45:53.200
|
# Question
Title: How can I get an org-mode outline in a 2nd buffer as a dynamic table of contents?
When I edit large documents, I would like to see where I'm at by seeing the outline (with no-content) in a separate buffer. Like when you read a PDF file there is a TOC on the left. (see below)
In org-mode it's possible to expand/collapse outline. But is it possible to have a static outline in the left(or right) in a separate buffer so that when you click on the headings, the other buffer moves to that position?
Kinda like this but for org-mode?
**\[Edit\]**
The `clone-indirect-buffer` is very close to what I want. The missing piece of the puzzle is to jump to the same location when clicking a heading/(or any point really).
For this I have tried to write some code: Move to other cloned buffer to same point? (sync position of indirect buffers) (org-mode)
But it doesn't function if content is collapsed. If that can be made to work, then the clone-inderect-buffer is a complete solution to this.
**\[Edit2 Solution\]**
The code in the link above and in the answer below combine niceley to solve the jumping back and forth.
```
;first call 'clone-indirect-buffer'. Then...
;This function works between buffer and it's clone.
(defun my/goto-same-spot-in-other-buffer ()
"Go to the same location in the other buffer. Useful for when you have cloned indirect buffers"
(interactive)
(let ((my/goto-current-point (point)))
(other-window 1)
(goto-char my/goto-current-point)
(when (invisible-p (point))
(org-reveal)))
)
;This function is a clone-to-buffer jump only:
; It does find the other buffer first thou instead of just jumping to the other
; window as does the function above.
(defun my/jump-to-point-and-show ()
"Switch to a cloned buffer's base buffer and move point to the
cursor position in the clone."
(interactive)
(let ((buf (buffer-base-buffer)))
(unless buf
(error "You need to be in a cloned buffer!"))
(let ((pos (point))
(win (car (get-buffer-window-list buf))))
(if win
(select-window win)
(other-window 1)
(switch-to-buffer buf))
(goto-char pos)
(when (invisible-p (point))
(show-branches)))))
(global-set-key (kbd "<s-mouse-1>") 'my/goto-same-spot-in-other-buffer)
(global-set-key (kbd "s-m") 'my/goto-same-spot-in-other-buffer)
(global-set-key (kbd "<C-s-mouse-1>") 'my/jump-to-point-and-show)
(global-set-key (kbd "C-s-m") 'my/jump-to-point-and-show)
```
# Answer
> 10 votes
A few options come to mind. The first two are `speedbar`, which allegedly plays well with `org-mode`, and `minimap`, although I've not used them so can't vouch for them personally.
What might be the simplest option (and also the most flexible), would be to use an indirect buffer.
In practice, you would go to the `org` buffer for which you'd like an outline, hit `M-x clone-indirect-buffer` (use `C-u M-x clone-indirect-buffer` if you'd like to control what the clone is called), and then boom, there's another copy of the buffer for you to use. Put that clone in a window or frame side-by-side with the original buffer and, in the clone, adjust the outline to your tastes.
It doesn't get you the "click on heading in outline" functionality you mentioned, but gets you the spirit of the sidebar.
**Edit:** in response to your comment, here's a simple command that, when invoked from the *buffer clone*, will switch to the *base buffer* and move point to wherever the cursor was in the buffer clone:
```
(defun jump-to-point-and-show ()
"Switch to a cloned buffer's base buffer and move point to the
cursor position in the clone."
(interactive)
(let ((buf (buffer-base-buffer)))
(unless buf
(error "You need to be in a cloned buffer!"))
(let ((pos (point))
(win (car (get-buffer-window-list buf))))
(if win
(select-window win)
(other-window 1)
(switch-to-buffer buf))
(goto-char pos)
(when (invisible-p (point))
(show-branches)))))
```
# Answer
> 19 votes
How about: `M-x` `occur` `RET` `^*+` `RET` (note that there's a space at the end of the regexp).
# Answer
> 8 votes
After reading Dan's answer and your solution based on it, I put this together. It opens a new, narrow, read-only clone to the left of the current buffer, and it binds `<mouse-1>` and `RET` locally in the clone to jump to that position in the base buffer.
```
(defun my/open-tree-view ()
"Open a clone of the current buffer to the left, resize it to 30 columns, and bind <mouse-1> to jump to the same position in the base buffer."
(interactive)
(let ((new-buffer-name (concat "<tree>" (buffer-name))))
;; Create tree buffer
(split-window-right 30)
(if (get-buffer new-buffer-name)
(switch-to-buffer new-buffer-name) ; Use existing tree buffer
;; Make new tree buffer
(progn (clone-indirect-buffer new-buffer-name nil t)
(switch-to-buffer new-buffer-name)
(read-only-mode)
(hide-body)
(toggle-truncate-lines)
;; Do this twice in case the point is in a hidden line
(dotimes (_ 2 (forward-line 0)))
;; Map keys
(use-local-map (copy-keymap outline-mode-map))
(local-set-key (kbd "q") 'delete-window)
(mapc (lambda (key) (local-set-key (kbd key) 'my/jump-to-point-and-show))
'("<mouse-1>" "RET"))))))
(defun my/jump-to-point-and-show ()
"Switch to a cloned buffer's base buffer and move point to the cursor position in the clone."
(interactive)
(let ((buf (buffer-base-buffer)))
(unless buf
(error "You need to be in a cloned buffer!"))
(let ((pos (point))
(win (car (get-buffer-window-list buf))))
(if win
(select-window win)
(other-window 1)
(switch-to-buffer buf))
(goto-char pos)
(when (invisible-p (point))
(show-branches)))))
```
This will work with `outline-mode` and `outline-minor-mode`, as well as modes that build on them, such as `org-mode`. I found some info about getting the local key maps, but I don't know how to choose which one to copy. There's also this page which has a function to automatically make buffer-specific minor modes for setting buffer-local keys, but that seems out-of-scope for this issue.
# Answer
> 7 votes
Finally, this has been implemented in the package `org-sidebar`:
# Answer
> 1 votes
I needed something similar, so I put together `outline-toc` mode. It should work for org-mode docs.
# Answer
> 0 votes
two low rent suggestions (what i do) from a non-programmer who likes to use aquamacs for text editor:
1. toggle back and forth with in-buffer commands:
# STARTUP: indent (to show the waterfall type outline easier to see as whole)
this is for tab-driven viewing of buffer
and
# +OPTIONS: H:N, where N = =the number of levels you wish to see in html export, which is suggestion #2
see: https://emacsclub.github.io/html/org\_tutorial.html
2. export as html (C-C C-E h h) to see TOC. i can find no one who can easily get the text output of html or text (C-C C-E t a) to indent
---
Tags: org-mode, elisp, indirect-buffers
---
|
thread-52928
|
https://emacs.stackexchange.com/questions/52928
|
Add date to mu4e email when forwarding or replying
|
2019-10-01T17:09:19.837
|
# Question
Title: Add date to mu4e email when forwarding or replying
I use Emacs and `mu4e` for email. If I forward an email, the body defaults to this:
```
From: me <>
To:
Subject: Fwd: ...
--text follows this line--
Sender <> writes:
...
```
I would like `mu4e` to add the date of the email forwarded, such as:
```
On 1 October 2019, at 18:07, sender <> wrote:
...
```
I looked at the source code of `mu4e-forward`, `mu4e-compose`, and `mu4e~proc-compose` without seeing where the text is added. I think it's in:
```
(mu4e~proc-send-command
"cmd:compose type:%s docid:%d extract-encrypted:%s use-agent:true"
(symbol-name type) docid (if decrypt "true" "false")))
```
but I don't know how to hack `"cmd:compose ..."`
Has anyone tweaked the default message when forwarding or replying?
# Answer
`mu4e` uses `message.el` to edit the messages. The documentation for `message-citation-line-function` in that package shows:
> Function called to insert the "Whomever writes:" line.
>
> Predefined functions include ‘message-insert-citation-line’ and ‘message-insert-formatted-citation-line’ (see the variable ‘message-citation-line-format’).
The definition of `message-insert-citation-line` has:
```
(insert (mail-header-from message-reply-headers) " writes:")
```
But this one has no formatting to customize with date and time. The definition of `message-citation-line-format` shows a value of:
> On %a, %b %d %Y, %N wrote:
So you'll have to set both `message-citation-line-function` and `message-citation-line-format`:
```
(setq message-citation-line-function 'message-insert-formatted-citation-line)
(setq message-citation-line-format "On %Y-%m-%d at %R %Z, %f wrote:\n")
```
The FAQs mention this customization to avoid a bug in Outlook:
```
(setq message-citation-line-format "On %Y-%m-%d at %R %Z, %f wrote...")`
```
> 5 votes
---
Tags: mu4e, email
---
|
thread-42318
|
https://emacs.stackexchange.com/questions/42318
|
Why are code blocks and code literals displaying with large face in markdown
|
2018-06-29T00:23:54.580
|
# Question
Title: Why are code blocks and code literals displaying with large face in markdown
In markdown mode, all of the fenced code blocks and inline code literal strings are displaying with this very large font. The size is large, and also I'm pretty sure it isn't the same font as the default surrounding text (which is *Classic Console*).
---
This is Emacs 25.3 on a Mac, using the standalone app (the one from https://emacsformacosx.com/).
My .emacs file is here.
# Answer
This can be fixed by calling `M-x customize-group RET markdown-faces` while in Markdown mode. It opens a menu of various font face settings. Under `Markdown Code Face`, uncheck/delete everything and then save. This will make the code face the same as the default face.
> 4 votes
# Answer
In addition to `Adam Michael Wood` and `lawlist`:
`C-u C-x =` \- good way to get information about font symbol
In appered buffer you should follow that paragraph: `There are text properties here:` and visit highlighted link. This way can help you look through font inheritance.
You can get clear that `Mardown Code Face` inherits Emacs system `fixed-pitch` root-font.
`(customize this face)` \- Opens Emacs font editor
Or you can change this settings in your `.emacs` file
```
(custom-set-faces
'(default ((t (:family "Ubuntu Mono" :foundry "DAMA" :slant normal :weight normal :height 107 :width normal))))
)
```
Append next line after `default font`:
```
'(fixed-pitch ((t (:family "Ubuntu Mono"))))
```
> 2 votes
---
Tags: faces, fonts, font-lock, markdown, markdown-mode
---
|
thread-50929
|
https://emacs.stackexchange.com/questions/50929
|
Emacs displays Hebrew text incorrectly
|
2019-06-10T05:12:18.903
|
# Question
Title: Emacs displays Hebrew text incorrectly
I have a number of org-mode/text documents that contain English and Hebrew text. They are scholarly papers. However, the Hebrew text in Emacs is not displayed correctly. I am using Dejavu Sans Mono as my font. The problem is that vowels are displayed next to the consonants rather than beneath them. There are a few other anomalies too. If I export the documents in org mode to html or odf then the Hebrew is displayed correctly. I have tried changing the font, installing "unicode-fonts" and a host of other solutions. I have tried using different versions of Emacs. I use utf-8 as my default encoding system. Nothing seems to work. If I open the same text document in LibreOffice, again, the text is displayed correctly. If I strip the Hebrew text of vowels, using an online program (like https://www.miniwebtool.com/) then the consonants appear correctly in Emacs when pasted back. The problem is that I need the vowels too. I also have other academic papers with Greek, and these display correctly without any problems. I would appreciate any help with this problem.
# Answer
This issue has now been fixed in the latest git version of Emacs thanks to help from Eli Zaretskii.
> 1 votes
---
Tags: org-mode, unicode, utf-8
---
|
thread-52936
|
https://emacs.stackexchange.com/questions/52936
|
Searching Greek and Hebrew texts in Emacs with isearch while ignoring accents and diacritics
|
2019-10-02T08:19:27.917
|
# Question
Title: Searching Greek and Hebrew texts in Emacs with isearch while ignoring accents and diacritics
I have a number of text and org documents that contain Greek and Hebrew text. I want to be able to search these in Emacs using isearch but I also want Emacs to ignore all accents and diacritics. I found a solution to this problem years ago but forgot what it is. Any help would be appreciated.
# Answer
> To toggle whether or not the search will consider similar and equivalent characters as a match, type M-s '.
Source : https://www.gnu.org/software/emacs/manual/html\_node/emacs/Special-Isearch.html
> 3 votes
---
Tags: org-mode, isearch
---
|
thread-52938
|
https://emacs.stackexchange.com/questions/52938
|
How to understand paragraph-start variable regex
|
2019-10-02T10:00:41.233
|
# Question
Title: How to understand paragraph-start variable regex
# Problem
When i evaluate the *paragraph-start* variable in the major mode *lisp-mode*, it has the following value
```
"^L\\|[ ]*$"
```
In emacs the `^L` is displayed in red color so I'm not sure if there is some character in between that I could not be displayed properly.
According to the elisp manual *paragraph-start* is a buffer local variable and is set "to specify that only blank lines separate paragrap" in *Lisp mode*. However, I don't see how the regex above matches blank line. I would parse the regex above in the following way:
1. `^L\\`: This matches lines that begin with `L\`, since the anchor `^` indicates start of string or line and `\\` indicates an escaped `\`.
2. `|` indicates an or joining the regex before (1) and after (3).
3. `[ ]*$`: The first part `[ ]` is a character class containing just the space character (why are there multiple space characters in it?). The quantifier `*` indicates that the preceding character class, which is only space, shall be matched zero or more times at the End which is indicated by the anchor `$`.
Furthermore, the emacs (25.2.1) documentation `C-h``v` `paragraph-start` states that:
> This regexp should match lines that separate paragraphs and should also match lines that start a paragraph
# Question
The regular expression (3) should either match the end of a **any** line, if no white spaces were found, or a string of spaces at the end of each line.
1. *Does (3) match "lines that separate paragraphs"?* If yes, why? If not, what does it mean?
Regular expression (1) should only match a line beginning with `L\` as far as I can see.
2. *Does (1) match "lines that start a paragraph"* If yes, why? If not, what does it mean?
I probably messed up somewhere by misunderstanding either the documentation or the regex. However, a small explanation where I went wrong would be greatly appreciated.
As a reference for the regex matching i used the online emacs documentation.
# Answer
> 1 votes
Your main confusion lies in that `^L` isn't a two-characters regexp, it's an ASCII control character (page-break/ FORM FEED), that's why it appears in red in your system.
on #3, if you iterate over the blanks and using `M-x describe-char` you'll notice that it should match either space or tab. Reasons are described in the documentation string:
> Regexp for beginning of a line that starts OR separates paragraphs. This regexp should match lines that separate paragraphs and should also match lines that start a paragraph (and are part of that paragraph).
>
> This is matched against the text at the left margin, which is not necessarily the beginning of the line, so it should never use "^" as an anchor. This ensures that the paragraph functions will work equally well within a region of text indented by a margin setting.
---
Tags: regular-expressions, characters
---
|
thread-52942
|
https://emacs.stackexchange.com/questions/52942
|
how to tell a Custom Theme vs Color Theme?
|
2019-10-02T19:55:22.953
|
# Question
Title: how to tell a Custom Theme vs Color Theme?
I am considering changing the look of my emacs (just default state right now). I've read that Color Theme is an older approach but has its own advantages compared to Custom Theme (newer approach). One of the benefits of Color Theme seems to be the ability to completely turn it off and revert back to default state. Apparently, Custom Theme cannot be switched off in this manner.
Because Color Themes are undo-able, I want to install a few Color Themes to try out. But, when I start looking around, I see that a lot of Color Themes also have a Custom Theme version(?). How can I tell whether I'm installing a Color Theme vs a Custom Theme? Is there something in the `.el` file OR the way in which I have to alter my `.emacs` file that will tell me definitively?
# Answer
(Variable `color-themes` is a list of your color themes. A given color theme is a function.)
You can use command **`color-theme-analyze-defun`** to check whether a function definition (`defun`) at point defines a color theme. It's defined in `color-theme.el`.
Here is its doc string:
> Once you have a color-theme printed, check for missing faces.
>
> This is used by maintainers who receive a color-theme submission and want to make sure it follows the guidelines by the color-theme author.
> 1 votes
---
Tags: themes, colors
---
|
thread-52944
|
https://emacs.stackexchange.com/questions/52944
|
Evaluating `org-babel-clojure` blocks returns nill & result
|
2019-10-03T08:14:33.470
|
# Question
Title: Evaluating `org-babel-clojure` blocks returns nill & result
Why the results is 'nil5'? Can't be just 5?
```
#+begin_src clojure :results
(+ 1 4)
#+end_src
#+RESULTS:
: nil5
```
Also:
```
#+begin_src clojure
(print "Hello World!")
#+end_src
#+RESULTS:
: nilnil
```
I was expected just to print "Hello World!" in RESULTS.
# Answer
> 4 votes
```
#+begin_src clojure :results pp
(+ 1 4)
#+end_src
#+RESULTS:
: 5
```
```
#+begin_src clojure :results output
(print "Hello World!")
#+end_src
#+RESULTS:
: Hello World!
```
So we have to specify the output.
---
Tags: org-mode, clojure, babel
---
|
thread-52951
|
https://emacs.stackexchange.com/questions/52951
|
Magit status Recent commits foreground color
|
2019-10-03T18:19:20.003
|
# Question
Title: Magit status Recent commits foreground color
I have a terminal with a dark background color. Magit shows recent commits and uses a dark color for the commit hashes so I can't see them. I tried customizing frame-background-mode to be dark but the hashes are still not visible. Any way to fix this? Thanks!
# Answer
> 1 votes
If you type `M-x describe-char` with point on a commit hash, you can see various informations about the character, including its *face*:
> There are text properties here:
>
> face magit-hash
Now you can move the point (using the TAB key) to the face name and type the RETURN key (or click on the words `magit-hash`) to get the face's documentation. This shows that the only *attribute* of the face is the foreground color, that happens to be `grey60`. This also includes a link `customize this face` that will allow you to change this color.
Use `Choose` then `Apply` or `Apply and Save` to make the change apply to future sessions (it will be saved in your init file).
For more information about faces, see the manual.
---
Tags: magit
---
|
thread-52947
|
https://emacs.stackexchange.com/questions/52947
|
Jump to a string in a PDF document
|
2019-10-03T13:49:26.380
|
# Question
Title: Jump to a string in a PDF document
I want to write a function that jumps to a given string in a pdf document. I am using `pdf-tools`. Naively, I thought this would work:
```
(defun goto-string-in-pdf (pdffile)
"Jump to string 999 in pdffile"
(let ((win (get-buffer-window pdffile)))
(with-selected-window win
(pdf-view-goto-page 1)
(search-forward "999"))))
```
But it seems `search-forward` doesn't work in PDFView-mode. So how do I make this work?
# Answer
> 2 votes
Apart from choosing the right buffer, this function suggests the necessary steps.
```
(defun pdf-search-forward (string)
(interactive "sString: ")
;; Expect a pdf-window, else the highlighting won't work.
(pdf-util-assert-pdf-window)
;; Get a list of matches, discarding all but the first.
(let-alist (car (pdf-info-search-string
"Number"
(cons (pdf-view-current-page) 0)))
(unless .page
(error "Not found: %s" string))
(pdf-view-goto-page .page)
;; Scale the edges of the match according to the displayed
;; page-size.
(let ((pixel-edges
(pdf-util-scale-relative-to-pixel .edges))
(pdf-isearch-batch-mode t))
;; Highlight and focus the match.
(pdf-isearch-hl-matches pixel-edges nil t)
(pdf-isearch-focus-match-batch pixel-edges))))
```
---
Tags: pdf-tools
---
|
thread-52956
|
https://emacs.stackexchange.com/questions/52956
|
How can I back up my init file with Git?
|
2019-10-03T20:50:13.227
|
# Question
Title: How can I back up my init file with Git?
The docs say to keep the `.emacs` file in the `HOME` directory.
I'd like to share the file between multiple computers using a git repo. What is the best way to structure the repo without including everything else that's in `HOME`.
Do I have to turn `HOME` itself into a repo and include everything else in the directory in the .gitignore?
# Answer
> 4 votes
There is no need to to turn your whole home into a repo. `.emacs.d` will be enough, and cloning it whatever you go will do it too.
Supposing that your `.emacs.d` is a repo, to do that your `.gitignore` should look like:
```
/*
!init.el
!.gitignore
```
First line tells git to ignore everything, second line tells git that init.el shouldn't be ignored. Third line prevents git from ignoring the `.gitignore`. More info here.
Notice that if you ignore a subdirectory you won't be able to "unignore" files under it this way. Instead, use a `.gitignore` file specific to that subdirectory.
---
Tags: init-file, git, backup
---
|
thread-52434
|
https://emacs.stackexchange.com/questions/52434
|
How to access the directory of the init.el file from elisp?
|
2019-08-31T08:05:16.887
|
# Question
Title: How to access the directory of the init.el file from elisp?
Is there a function/variable to access the directory the init file is in?
This could be: `~/.config/emacs/` or `~/.emacs.d/`, for e.g.
# Answer
If you want to access the directory from within the init.el file, this bit of code will give you the name of directory that init.el is in while it is being executed.
`(file-name-directory (or load-file-name (buffer-file-name)))`
If you want to access that directory in another file, then just save that in a variable.
> 4 votes
---
Tags: init-file
---
|
thread-33697
|
https://emacs.stackexchange.com/questions/33697
|
Org-mode link to function definition
|
2017-06-21T18:51:15.300
|
# Question
Title: Org-mode link to function definition
Is it possible to link to a function definition in a source code file, rather than a fixed line number?
# Answer
Using the suggested global binding `C-c l` for storing a link when you are visiting *any* file (not just an org-mode file) and the one for inserting a link into an org file, `C-c C-l`, should work fine. It does not do the elisp `find-function` bit that John Kitchin describes in his answer, but it should be adequate for almost all situations. But you need `org-context-in-file-links` to be set to `t`: AFAICT that has been the default since 2008, but if you get line numbers instead of context in file links, check the setting of that variable.
> 5 votes
# Answer
For elisp that is certainly possible. The general strategy might be something like:
```
[[elisp:(find-function 'describe-function)]]
```
You could add a description if you wanted to also, e.g.
```
[[elisp:(find-function 'describe-function)][describe-function]]
```
For other languages it wouldn't be that easy. You can make a link like this:
```
[[file:~/vc/projects/neural-network/aenet-1.0.0/src/aenet.f90::subroutine%20aenet_init(atom_types,%20stat)]]
```
which will open that file and search for the contents after the ::. Those contents are escaped.
> 9 votes
# Answer
Yes, it is in fact possible to link directly to a help page, which should serve the purpose of linking to a function. Although it's not yet documented on https://orgmode.org/org.html#External-Links, the `help:` link type works, at least since 2016. For example, `[[help:org-link-parameters]]` links to the function where the `help:` link (and many of the other built-in ones) are defined. Furthermore, running `org-store-link` (`C-c l`) on a Help page will store a link to the Help page.
> 1 votes
---
Tags: org-mode, functions, org-link
---
|
thread-52969
|
https://emacs.stackexchange.com/questions/52969
|
Magit set upstream origin
|
2019-10-04T20:20:43.857
|
# Question
Title: Magit set upstream origin
I'm having trouble understanding how Magit handles pushing local branches to remote
I create and checkout a new branch with `b c`.
I make some arbitrary change, and save returning to magit with `C-x g`
I stage and commit the change adding a commit message.
Now I want to push.
In a terminal I would use `git push --set-upstream origin <new_branch_name>`
In magit, I use `P` and either `u` or `p`.
Reading the docs and this question it sounds like `u` is the right choice.
when i hit `u` the status buffer reads
```
Set upstream of third_test_branch and push there (default origin/master):
```
looking for another input. When I enter `master` it then pushes to the master branch.
any other input at this point seems to return `match not found`
what am I missing? Thanks
# Answer
> 4 votes
When you use `p` to set the value of `branch.<name>.pushRemote` "the value has to be the name of an existing remote", and so you can only enter one of those.
It's quite common for there to only be `origin`, in which case that is the only valid value. If you wish to add *new remotes*, use the Remotes popup bound to `M`.
Note that the remote branch for your `pushRemote` has the same name as the local branch, and so you are not prompted for that. (i.e. `P``p` on a local branch `foo` with a pushRemote of `origin` pushes it to `origin/foo`).
If you use `u` to specify the 'upstream' then you are defining *both* a remote (`branch.<name>.remote`) and a branch (`branch.<name>.merge`); so there you could enter, say, `origin/bar` as an upstream for local branch `foo`.
---
The approach I tend to use is:
* Local `master` has upstream of `origin/master`.
* Local feature branch `foo` has pushRemote of `origin` and upstream of local `master` (an upstream of `origin/master` is more dangerous if you accidentally push to upstream<sup>1</sup>).
* My WIP on this feature is very regularly pushed to `origin/foo` (partly for backup purposes), using `P p`.
* At all times the status buffer shows me what I've added to `foo` since it was cut from `master` (being foo's upstream). This is one of the nice benefits of having both an upstream and a pushRemote, and is the other reason why you might choose not to use `origin/master` as the feature branch upstream: You may not wish to be bothered by seeing newer upstream additions until it's time to merge, and `origin/master` would be updated if you do a general fetch from origin, whereas local `master` won't be updated unless you tell it to.
* Once the feature is ready to be merged into and pushed to `origin/master`...
+ Pull any upstream changes to `origin/master` into the local `master` branch.
+ If necessary, rebase the `foo` branch onto the updated `master`.
+ Merge `foo` into local `master`.
+ If happy, push the new `master` upstream to `origin/master`.
<sup>1</sup> I also use this for added protection.
---
Tags: magit
---
|
thread-52971
|
https://emacs.stackexchange.com/questions/52971
|
Command that does different things based on whether something is selected
|
2019-10-04T21:19:02.220
|
# Question
Title: Command that does different things based on whether something is selected
I am trying to make emacs function somewhat like sublime text, where `C-x` cuts text that is selected and cuts the whole line when nothing is selected. I got the full-line cut to work using
```
(global-set-key (kbd "C-x") 'kill-whole-line)
```
but I'm not sure how to get `C-w`'s functionality (`kill-region`) to happen when text is selected and then use `C-x`. Is there a way to say something like
```
(if region-selected
('kill-region)
('kill-whole-line))
```
(And yes, I know I'm rebinding `C-x`, but I'm sick of trying to switch mental muscle memory modes from sublime text to terminal editing.)
# Answer
> 1 votes
1. To invoke a function, don't quote it: **`(kill-whole-line)`**, not `('kill-whole-line)`.
2. You're looking for function `use-region-p`, so **`(use-region-p)`**, not `region-selected`. (There is no predefined variable `region-selected`.)
3. You need to pass functions the arguments they require. So **`(kill-region (region-beginning) (region-end)`**.
4. If you want it to be a function then define it, giving it a name, with `defun`.
5. If you want it to be a command, so you can bind it to a key, then give it an `interactive` spec: **`(interactive)`**.
```
(defun my-kill-cmd ()
(interactive)
"Kill region if it's active and nonempty. Else kill whole line."
(if (use-region-p)
(kill-region (region-beginning) (region-end))
(kill-whole-line)))
```
---
To learn more:
* Use `C-h f kill-region` to see what it does and what args it expects. Likewise, `region-beginning`, `region-end`, `interactive` (a special form), and `defun` (a macro).
* Spend some time with the manual *"An Introduction to Programming in Emacs Lisp"*. Use `C-h i`, then choose `Emacs Lisp Intro`. When in the manual, you can use `i` to look things up in the Index, using completion. E.g., `i interactive RET`.
---
You probably don't want to bind your command to `C-x`, as that's a prefix key in vanilla Emacs. Better to choose another key. For example:
```
(global-set-key (kbd "C-x C-j") 'my-kill-cmd)
```
---
Tags: key-bindings, region, commands, interactive, kill-text
---
|
thread-52974
|
https://emacs.stackexchange.com/questions/52974
|
Does Emacs 26.3 require older version of ImageMagick?
|
2019-10-05T04:25:47.617
|
# Question
Title: Does Emacs 26.3 require older version of ImageMagick?
I've just upograded Ubuntu 19.04, which installs imagemagick 7. When trying to start my Emacs install, I see the following error:
```
emacs: error while loading shared libraries: libMagickWand-6.Q16.so.3: cannot open shared object file: No such file or directory
```
However, I already have imagemagick installed:
```
imagemagick is already the newest version (8:6.9.10.14+dfsg-7ubuntu2.2).
```
I'm still fairly new to Emacs. I'm guessing this means Emacs depends on an older version of this thing called imagemagick?
How do I fix this problem?
# Answer
> 1 votes
### Explanations
The problem is not a dependency of Emacs 26.3, but a dependency of this specific compiled executable. The compiled executable that you have needs `libMagickWand-6.Q16.so.3`, which is provided by the package `libmagickwand-6.q16-3` in Ubuntu 18.04 bionic. Ubuntu 19.04 disco comes with `libmagickwand-6.q16-6`, which contains `libMagickWand-6.Q16.so.6`.
The number after `.so.` in the name of the shared library is the ABI version. The ABI version reflects the exact format of the data structures that the library uses to communicate with the application. If the format of these data structures change, for example to support new functionality, the application needs to be recompiled.
You can install multiple versions of the same library with a different ABI. That's why the library file name contains the ABI version and the Ubuntu package name also contains the ABI version. Ubuntu only lets you install a single version of the ImageMagick application, because they'd all compete for who gets to be `/usr/bin/display-im6` and the like. But you can have both `libmagickwand-6.q16-3` and `libmagickwand-6.q16-6` installed. This capability is why shared libraries always come in a separate package from other types of files.
Note that you can search which package contains a file on the Ubuntu website. (There's also a local tool, `apt-file`, but it won't let you query versions of the distribution other than the one you have installed.)
### Solutions
If you don't mind using Emacs 26.1 instead of 26.3, use the version provided by Ubuntu. Using the applications provided by your distribution is always the simplest solution.
If you want Emacs 26.3 and you compiled it Emacs yourself, just recompile it with the development packages from your current version of Ubuntu.
If you got Emacs 26.3 from a third party, see if they have compiled binaries for disco.
If you just download `libmagickwand-6.q16-3` and any other library that it may require and install them manually, you'll be able to run your existing Emacs executable. However beware that this way you won't get security updates.
You can add Ubuntu bionic as a package source in apt (make sure to include the security updates from `bionic-security`). This way you can install packages from either bionic or disco; when the same package name is present in both, you'll always get the most recent version.
---
Tags: linux, ubuntu
---
|
thread-774
|
https://emacs.stackexchange.com/questions/774
|
Preview fields in org table
|
2014-10-07T17:44:06.803
|
# Question
Title: Preview fields in org table
Sometimes it is convenient to set a manual column width when creating a table in org-mode. This makes it so that columns do not have to grow to the size of their longest entry. When an entry in and org-mode table is longer than the column it is found in, the entry gets visually truncated with a `=>` symbol at the end.
I know that I can do `C-c `` to use `org-table-edit-field`, but this requires pressing `C-c C-c` to close the preview window and get back to the org-mode buffer. Calling the same command with a prefix argument `C-u C-c `` makes the full field visible so that it can be edited in place, but it is still tedious if I want to quickly preview 5-10 fields in quick succession.
LibreOffice Calc has a preview field at the top of a spreadsheet (so does MS Excel) which shows the value of the currently selected field:
**Is it possible to get a similar preview when editing an org-mode table?** The minibuffer seems like one good place for it, although it might have the side effect of filling up the `*Messages*` buffer quickly. A dedicated mini window at the top or bottom of the buffer would also work.
# Answer
Inspired by Juancho's answer, I decided to use the header line to display the value of the current field. While I was at it, I decided it would be nice to show the location of the field in the header as well:
This is the code I used to achieve it:
```
(defun my-trim-string (arg)
"Simple function for trimming the whitespace from the ends of
a string. Also removes any string properties such as font faces."
(let ((str (substring-no-properties arg)))
(when (string-match "^[ \t]+" str)
(setq str (replace-match "" nil nil str)))
(when (string-match "[ \t]+$" str)
(setq str (replace-match "" nil nil str)))
str))
(defun my-org-table-location (&optional arg)
"Get the location of the current field in the table"
(interactive "P")
(when (eq 'org-mode major-mode)
(org-table-get-specials)
(let* ((row (org-table-current-dline))
(col (org-table-current-column))
(loc (if arg
(format "%c%02d" (+ 64 col) row)
(format "@%d$%d" row col))))
(when (called-interactively-p 'any)
(message "Field Location: %s" loc))
loc)))
(defun my-org-table-field (&optional arg)
"Get the value of the current field in the table"
(interactive "P")
(when (eq 'org-mode major-mode)
(org-table-get-specials)
(let* ((formula (org-table-current-field-formula))
(value (my-trim-string (org-table-get-field)))
(field (or (and arg formula) value)))
(when (called-interactively-p 'any)
(message "Field Value: %s" loc))
field)))
;; Define the format for the header line in Org mode
(setq my-org-table-header
(list '(:eval (let ((loc (my-org-table-location))
(field (my-org-table-field)))
(format " %s: %s" loc field)))))
(defun my-org-mode-setup ()
"Apply custom setup to org-mode buffers"
(setq-local header-line-format my-org-table-header))
(add-hook 'org-mode-hook 'my-org-mode-setup)
```
It has withstood a few days of (minimal) testing, so I decided to go ahead and share it. If anybody else ends up using this, please let me know if you encounter any problems with it.
> 11 votes
# Answer
Inspired by seth's answer, you may always display the tooltip text on the header line (which is a little-known mode line at the top of the window).
Execute the following:
```
(setq-default header-line-format (list '(:eval (help-at-pt-kbd-string))))
```
Now, every time the text under the point has a tooltip property, it will be displayed on the header line.
Actually, org-table tooltips contain an annoying prefix with instructions, but it is an approximation to your problem.
> 9 votes
# Answer
If you put your cursor in the cell and hit `C-h .` it'll show the help text for that cell in the echo area. The help text contains the full value as well as the other help text. Kind of noisy but it shows the value.
See `display-local-help` and Help Echo.
> 8 votes
# Answer
This is an old question, but let me add this.
```
(add-hook 'org-mode-hook
'(lambda ()
(setq-local header-line-format (list '(:eval (substring-no-properties (org-table-get-field)))))
))
```
This is a more direct way to implement @nispio 's solution, I think.
> 3 votes
# Answer
`M-x org-table-follow-field-mode` should not only allow to view but remote-edit as well, while being in the org-mode in your file. So you can do various things with tables and cells easily such as swap columns, without loosing the cell-editing in sight.
With keybinding, I press that key whenever I am inside table and want to activate this mode. Now only, if I can find a way to auto-activate it whenever I am inside the table.
> 0 votes
---
Tags: org-mode, org-table
---
|
thread-52977
|
https://emacs.stackexchange.com/questions/52977
|
Searching text between markers as in Nota Bene
|
2019-10-05T08:27:08.300
|
# Question
Title: Searching text between markers as in Nota Bene
The Word Processor Nota Bene has a feature which I would like if possible to emulate within Emacs. One can insert into a document non-printing markers which are then used to delineate areas of text or individual keywords to be indexed in text files. For example in the paragraph below the area in double brackets would be the area that would be searched in a document, as opposed to the whole document.
*\[\[Emacs is the extensible\]\], customizable, self-documenting real-time display editor. This manual describes how to edit with Emacs and some of the ways to customize it; it corresponds to GNU Emacs version 26.3.*
If one then did a search through the Nota Bene search tool Orbis, one would search for (say) the word "extensible" and only the text between the markers would be searched. This allows one to more easily find specific information in a file, rather than having to search through dozens of possible hits.
# Answer
Yes. Here are some ways.
1. With just vanilla Emacs you can narrow the buffer to the text between your two "markers", using `C-x n n`. You need only one marker - the *mark*, at one end of that bit of text, and point (the cursor position) at the other end of that bit of text.
2. With library Isearch+ you can just search the active region - no need to narrow the buffer to it. This is controlled by option `isearchp-restrict-to-region-flag`.
3. If you use library Zones, as well as library Isearch+ then you can you can search a set of buffer zones that are defined by their limits (markers or numbers) – like multiple regions, using commands `isearchp-zones-forward` and `isearchp-zones-forward-regexp`.
The set can contain just a single zone (pair of markers), if you want. There's no need to first activate the zone as the region.
You can of course use any of these approaches from Lisp, as well, e.g., if you don't want to search interactively. Your question doesn't make clear whether you want to do what you ask interactively or from Lisp. (I added tag `isearch`.)
If you just want to search, from Lisp, between two positions (whether or not there are markers there), then you can do that directly using functions `re-search-forward` and `search-forward` (and the `backward` functions). Just start the search at the first of the two limits.
> 1 votes
---
Tags: search, region, isearch, marker
---
|
thread-13127
|
https://emacs.stackexchange.com/questions/13127
|
disable specific warning in flycheck (specifically "#pragma once in main file")
|
2015-06-12T23:08:31.807
|
# Question
Title: disable specific warning in flycheck (specifically "#pragma once in main file")
I'm using flycheck for C++ development, and get the following warning:
```
#pragma once in main file
```
In all headers included in a main file. Searching the webs, I get the impression this has something to do with how gcc and clang (both give the same warning) compile for flymake.
I would like to get rid of this warning. Is there anything I can do?
# Answer
Clang has an option to disable this warning. Adding the following to my config fixed the issue for me.
```
(with-eval-after-load "flycheck"
(setq flycheck-clang-warnings `(,@flycheck-clang-warnings
"no-pragma-once-outside-header")))
```
Unfortunately, I don't know if similar option exists for gcc.
> 2 votes
# Answer
Currently GCC has no way of suppressing this warning. And flycheck has no way to ignore errors without touching its internals.
Here is a hack that works for gcc:
```
; ignore gcc "#pragma once" warning
(with-eval-after-load "flycheck"
(eval-when-compile (require 'flycheck)) ; for flycheck-error struct
(defun my-filter-pragma-once-in-main (orig-fun errors)
(dolist (err errors)
(-when-let (msg (flycheck-error-message err))
(setf (flycheck-error-message err)
(if (string-match-p "#pragma once in main file" msg) nil msg))))
(funcall orig-fun errors))
(advice-add 'flycheck-sanitize-errors :around #'my-filter-pragma-once-in-main))
```
For completeness, @grepcake's answer for clang:
```
; ignore clang "#pragma once" warning
(with-eval-after-load "flycheck"
(setq flycheck-clang-warnings `(,@flycheck-clang-warnings
"no-pragma-once-outside-header")))
```
> 0 votes
---
Tags: c++, flycheck
---
|
thread-52979
|
https://emacs.stackexchange.com/questions/52979
|
How to install and use exwm (the emacs based window manager) in Ubuntu 19.04?
|
2019-10-05T13:07:01.670
|
# Question
Title: How to install and use exwm (the emacs based window manager) in Ubuntu 19.04?
I am running Ubuntu 19.04 on my laptop and want to use EXWM as my window manager, but am not sure how to get it into the list of window managers that one can pull down when one logs in. It seems to only list "officially supported" ones.
# Answer
You need to create `/usr/share/xsessions/emacs.desktop` with the following content:
```
[Desktop Entry]
Name=EmacsWM
Comment=Emacs Window Manager
Exec=emacs
Type=Application
```
After that you should be able to select it from that menu.
> 1 votes
# Answer
You shouldn't have to. Link or copy the file 'xinitrc' to '~/.xinitrc' and make latter executable by `chmod +x ~/.xinitrc` Launch EXWM in a tty1 with
```
xinit -- vt01
```
To obtain a tty1 at the login screen just do `ctl-alt <F1>`. It's usually `Ctl-alt <F7>` to get back, maybe `ctl-alt <F8>` depending on your system.
Read docs at https://github.com/ch11ng/exwm On the wiki you will find an example ~/.xinitrc to use as a template.
To get a desktop file to launch from a login window, follow clemera above with `ln -s ~/.xinitrc ~/.xsessions`.
> 0 votes
---
Tags: ubuntu, exwm
---
|
thread-52988
|
https://emacs.stackexchange.com/questions/52988
|
how to generate tags and find mark-whole-buffer definition
|
2019-10-05T21:18:22.150
|
# Question
Title: how to generate tags and find mark-whole-buffer definition
I am following the `Introduction to Programming in Emacs Lisp` tutorial built in in Emacs and have arrived at the `Buffer Walk-through` section.
In the 4.1 Finding more information the function `xref-find-definitions` is mentioned. As suggested - I try to find the definition of the `mark-whole-buffer` function.
when I run the function by typing `M-.` and `mark-whole-buffer` it returns:
```
No definitions found for: mark-whole-buffer
```
Before that I have done/tried the following
---
* Installed `ctags.io` like so: `brew install --HEAD universal-ctags/universal-ctags/universal-ctags`
* run the ctags command in my `~/.emacs.d/` folder like so: `ctags -R` also tried `ctags -R *.el` \- it generates a `TAGS` file and I can open it in Emacs and search with `C-s` and there is no mark-whole-buffer entry in there.
* tried similar approach in other folders (running Emacs on macOS)
+ in the `/Applications/Emacs.app/Contents/` folder - using same commands as in the `.emacs.d` folder
+ in the `/Applications/Emacs.app/Contents/Resources/lisp` folder - using same commands as in the `.emacs.d` folder
* something else that I have tried is `M-x visit-tags-table` and when trying on for example the contents folder like `Visit tags table (default TAGS): /Applications/Emacs.app/Contents/` it returns `File /Applications/Emacs.app/Contents/TAGS is not a valid tags table`
---
Can you please clarify the two following points?
* Where to find the `mark-whole-buffer` function definition
* How to do so from within Emacs
# Answer
> 1 votes
`C-h f mark-whole-buffer` tells us that the function is defined in `simple.el`. If you click on the link in the help buffer to `simple.el`, it takes you right to the definition of the function.
---
Tags: help, emacs-lisp-mode
---
|
thread-50463
|
https://emacs.stackexchange.com/questions/50463
|
Getting a sorted window list
|
2019-05-12T13:36:44.653
|
# Question
Title: Getting a sorted window list
`(window-list)` returns a list of visible windows. Is it possible to get this list sorted from the most recently active window to the least?
# Answer
Found a solution by digging into `get-mru-window`, which uses `window-use-time`:
```
(sort (window-list)
(lambda (a b) (> (window-use-time a)
(window-use-time b))))
```
> 1 votes
---
Tags: window, sorting
---
|
thread-45630
|
https://emacs.stackexchange.com/questions/45630
|
what to do with "magit-wip-commit-worktree: Cannot read tree refs/heads/master"?
|
2018-10-28T12:48:23.977
|
# Question
Title: what to do with "magit-wip-commit-worktree: Cannot read tree refs/heads/master"?
When I commit via magit I get:
`magit-wip-commit-worktree: Cannot read tree refs/heads/master`
while it commits ok. But the message frightens me. There seems to be nothing wrong with the repo:
```
$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (2270/2270), done.
dangling blob ff2aef45cae6a3b1f980c192c748af754fb538d4
```
and there are readable files which match the message:
```
$ find .git | grep refs/heads/master | xargs ls -l
-rw-r--r-- 1 grfz grfz 12505 Okt 28 13:20 .git/logs/refs/heads/master
-rw-r--r-- 1 grfz grfz 495 Okt 28 13:20 .git/logs/refs/wip/index/refs/heads/master
-rw-r--r-- 1 grfz grfz 41 Okt 28 13:20 .git/refs/heads/master
-rw-r--r-- 1 grfz grfz 41 Okt 28 13:20 .git/refs/wip/index/refs/heads/master
```
There is nothing special about this repo:
```
core.excludesfile=/home/grfz/.gitignore_global
core.whitespace=trailing-space,space-before-tab,indent-with-non-tab
sendemail.chainreplyto=false
transfer.fsckobjects=true
fetch.fsckobjects=true
receive.fsckobjects=true
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
```
The customizables in cutomize-group magit-wip and magit-wip-legacy are all at standard values.
I used the worlds mightiest search engine and found: nothing besides magit documentation and the like. This astonishes me.
I would at least like to silence this message, better find its root cause.
# Answer
Update magit, it's a bug which was fixed yesterday: https://github.com/magit/magit/issues/3631.
(I am repeating Noam's comment as an answer because every question needs an answer.)
> 1 votes
# Answer
This can also happen if there's a stale git process. Check `ps` for stale git processes, and if so end them and remove `.git/index.lock`
> 0 votes
---
Tags: magit
---
|
thread-52983
|
https://emacs.stackexchange.com/questions/52983
|
Elpy Auto Complete is not working at all
|
2019-10-05T15:45:52.097
|
# Question
Title: Elpy Auto Complete is not working at all
I am trying to configure my emacs for python programming. Elpy auto-complete suggestion is not working at all in all instances. Any suggestions?
Here is my `elpy-config`...
```
Elpy Configuration
Emacs.............: 26.3
Elpy..............: 1.31.0
Virtualenv........: None
Interactive Python: python 3.7.4 (/Users/mdmorshed/.pyenv/shims/python)
RPC virtualenv....: rpc-venv (/Users/mdmorshed/.emacs.d/elpy/rpc-venv)
Python...........: python 3.7.4 (/Users/mdmorshed/.emacs.d/elpy/rpc-venv/bin/python)
Jedi.............: 0.15.1
Rope.............: 0.14.0
Autopep8.........: 1.4.4
Yapf.............: 0.28.0
Black............: 19.3b0
Syntax checker....: flake8 (/usr/local/bin/flake8)
You have not activated a virtual env. While Elpy supports this, it is
often a good idea to work inside a virtual env. You can use M-x
pyvenv-activate or M-x pyvenv-workon to activate a virtual env.
The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH -- and then do
`elpy-rpc-restart'.
```
# Answer
The online help of Elpy says:
> Elpy uses Company Mode for the completion interface, so its documentation is a good place for further information.
The most probable explanation is that `company` is not installed, or not correctly tweaked in your `init.el` file.
Make sure that `company` is installed and then try to add the following line in your init file:
`(add-hook 'after-init-hook 'global-company-mode)`
> 2 votes
---
Tags: auto-complete-mode, elpy
---
|
thread-52985
|
https://emacs.stackexchange.com/questions/52985
|
Should I be worried about the inability to undo a Custom Theme?
|
2019-10-05T15:55:47.090
|
# Question
Title: Should I be worried about the inability to undo a Custom Theme?
I am relatively new to emacs and am liking it... so much so that I'd like to customize the look and feel.
I'm aware the Custom Theme is the new way and is different from Color Theme.
The one thing that gives me pause is that Custom Theme cannot be undone. That freaks me out.
As I understand it, this means that if/when I uninstall Custom Theme 1 and install a new Custom Theme 2, the first one might leave remnants behind that still linger when I use Theme 2. Some of those remnants could conflict and give strange appearances (strange meaning different what Theme 2 intended).
How pervasive is this problem of Custom Themes leaving remnants behind? In practice, are there "good-behaving" Custom Themes that clean up after themselves when uninstalled? If things go bad, is the only option to go nuclear (i.e., re-install emacs, saving my init file)?
# Answer
You're confused:
* Re-installing Emacs will not help fix any problem due to installing a theme (just like redoing the road won't fix your car).
* The undesirable effects that might linger after disabling a theme only apply to the currently running Emacs session.
* Those undesirable effects should be considered as bugs and reported to the theme's author. They should be rare.
So, the problem is really minor in practice. In the worst case, you just need to restart Emacs.
> 1 votes
---
Tags: customize, colors
---
|
thread-52995
|
https://emacs.stackexchange.com/questions/52995
|
Installing helm-projectile results in "mapc: Lisp nesting exceeds ‘max-lisp-eval-depth’"
|
2019-10-06T14:11:20.263
|
# Question
Title: Installing helm-projectile results in "mapc: Lisp nesting exceeds ‘max-lisp-eval-depth’"
## Context
* Linux Mageia 7.
* Emacs 26.3 (vanilla install).
## Problem
Reproducible steps:
1. (Re)Move the content of `~/.emacs.d/elpa`.
2. Start `emacs` with no configuration (`emacs -Q`).
3. In the `*scratch*` buffer, run:
```
(package-initialize)
(with-eval-after-load "package"
(setq package-archives
(append '(("melpa" . "http://melpa.org/packages/"))
package-archives))
```
4. `M-x list-packages`.
5. Install `helm-projectile` (`20190731.1538`).
The error message appears:
```
mapc: Lisp nesting exceeds ‘max-lisp-eval-depth’
```
Do you know what's going on?
Below is the whole `*Messages*` buffer:
```
nil
(("melpa" . "http://melpa.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/"))
Importing package-keyring.gpg...done
Package refresh done
Mark set
Mark saved where search started
Mark set
Mark saved where search started
Install package ‘helm-projectile-20190731.1538’? (y or n) y
Package menu: Operation started [Installing 1]
Setting ‘package-selected-packages’ temporarily since "emacs -q" would overwrite customizations
Dependency cycle going through "helm-20191006.647"
Contacting host: melpa.org:80
Generating autoloads for epl.el...done
Wrote /home/bitouze/.emacs.d/elpa/epl-20180205.2049/epl-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/epl-20180205.2049... [3 times]
Compiling /home/bitouze/.emacs.d/elpa/epl-20180205.2049/epl.el...done
Wrote /home/bitouze/.emacs.d/elpa/epl-20180205.2049/epl.elc
Checking /home/bitouze/.emacs.d/elpa/epl-20180205.2049...
Done (Total of 1 file compiled, 2 skipped)
Contacting host: melpa.org:80
Generating autoloads for pkg-info.el...done
Wrote /home/bitouze/.emacs.d/elpa/pkg-info-20150517.1143/pkg-info-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/pkg-info-20150517.1143... [3 times]
Compiling /home/bitouze/.emacs.d/elpa/pkg-info-20150517.1143/pkg-info.el...done
Wrote /home/bitouze/.emacs.d/elpa/pkg-info-20150517.1143/pkg-info.elc
Checking /home/bitouze/.emacs.d/elpa/pkg-info-20150517.1143...
Done (Total of 1 file compiled, 2 skipped)
Contacting host: melpa.org:80
Generating autoloads for projectile.el...done
Wrote /home/bitouze/.emacs.d/elpa/projectile-20191006.926/projectile-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/projectile-20191006.926... [3 times]
Compiling /home/bitouze/.emacs.d/elpa/projectile-20191006.926/projectile.el...done
Wrote /home/bitouze/.emacs.d/elpa/projectile-20191006.926/projectile.elc
Checking /home/bitouze/.emacs.d/elpa/projectile-20191006.926...
Done (Total of 1 file compiled, 2 skipped)
Generating autoloads for helm-org.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-org-20190819.617/helm-org-autoloads.el [2 times]
Unable to activate package ‘helm-org’.
Required package ‘helm-3.3’ is unavailable
Contacting host: melpa.org:80
Parsing tar file...done
Extracting async-20190503.656/
Extracting async-20190503.656/dired-async.el
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/dired-async.el
Extracting async-20190503.656/async-bytecomp.el
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async-bytecomp.el
Extracting async-20190503.656/smtpmail-async.el
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/smtpmail-async.el
Extracting async-20190503.656/async-pkg.el
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async-pkg.el
Extracting async-20190503.656/async.el
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async.el
Generating autoloads for async-bytecomp.el...done
Generating autoloads for async-pkg.el...done
Generating autoloads for async.el...done
Generating autoloads for dired-async.el...done
Generating autoloads for smtpmail-async.el...done
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/async-20190503.656... [2 times]
Compiling /home/bitouze/.emacs.d/elpa/async-20190503.656/async-bytecomp.el...done
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async-bytecomp.elc
Checking /home/bitouze/.emacs.d/elpa/async-20190503.656... [2 times]
Compiling /home/bitouze/.emacs.d/elpa/async-20190503.656/async.el...done
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/async.elc
Checking /home/bitouze/.emacs.d/elpa/async-20190503.656...
Compiling /home/bitouze/.emacs.d/elpa/async-20190503.656/dired-async.el...done
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/dired-async.elc
Checking /home/bitouze/.emacs.d/elpa/async-20190503.656...
Compiling /home/bitouze/.emacs.d/elpa/async-20190503.656/smtpmail-async.el...done
Wrote /home/bitouze/.emacs.d/elpa/async-20190503.656/smtpmail-async.elc
Checking /home/bitouze/.emacs.d/elpa/async-20190503.656...
Done (Total of 4 files compiled, 2 skipped)
Contacting host: melpa.org:80
Parsing tar file...done
Extracting helm-core-20191003.1622/
Extracting helm-core-20191003.1622/helm-source.el
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-source.el
Extracting helm-core-20191003.1622/helm-lib.el
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-lib.el
Extracting helm-core-20191003.1622/helm-multi-match.el
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-multi-match.el
Extracting helm-core-20191003.1622/helm.el
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm.el
Extracting helm-core-20191003.1622/helm-core-pkg.el
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-core-pkg.el
Generating autoloads for helm-core-pkg.el...done
Generating autoloads for helm-lib.el...done
Generating autoloads for helm-multi-match.el...done
Generating autoloads for helm-source.el...done
Generating autoloads for helm.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-core-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622... [3 times]
Compiling /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-lib.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-lib.elc
Checking /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622...
Compiling /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-multi-match.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-multi-match.elc
Checking /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622...
Compiling /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-source.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm-source.elc
Checking /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622...
Compiling /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622/helm.elc
Checking /home/bitouze/.emacs.d/elpa/helm-core-20191003.1622...
Done (Total of 4 files compiled, 2 skipped)
Contacting host: melpa.org:80
Generating autoloads for popup.el...done
Wrote /home/bitouze/.emacs.d/elpa/popup-20160709.1429/popup-autoloads.el [2 times]
Checking /home/bitouze/.emacs.d/elpa/popup-20160709.1429... [3 times]
Compiling /home/bitouze/.emacs.d/elpa/popup-20160709.1429/popup.el...done
Wrote /home/bitouze/.emacs.d/elpa/popup-20160709.1429/popup.elc
Checking /home/bitouze/.emacs.d/elpa/popup-20160709.1429...
Done (Total of 1 file compiled, 2 skipped)
Contacting host: melpa.org:80
Parsing tar file...done
Extracting helm-20191006.647/
Extracting helm-20191006.647/helm-eval.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-eval.el
Extracting helm-20191006.647/helm-for-files.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-for-files.el
Extracting helm-20191006.647/helm-net.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-net.el
Extracting helm-20191006.647/helm-dabbrev.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-dabbrev.el
Extracting helm-20191006.647/helm-shell.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-shell.el
Extracting helm-20191006.647/helm-x-files.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-x-files.el
Extracting helm-20191006.647/helm-elisp-package.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-elisp-package.el
Extracting helm-20191006.647/helm-utils.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-utils.el
Extracting helm-20191006.647/helm-semantic.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-semantic.el
Extracting helm-20191006.647/helm-bookmark.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-bookmark.el
Extracting helm-20191006.647/helm-help.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-help.el
Extracting helm-20191006.647/helm-adaptive.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-adaptive.el
Extracting helm-20191006.647/helm-grep.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-grep.el
Extracting helm-20191006.647/helm-config.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-config.el
Extracting helm-20191006.647/helm-font.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-font.el
Extracting helm-20191006.647/helm-comint.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-comint.el
Extracting helm-20191006.647/helm-imenu.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-imenu.el
Extracting helm-20191006.647/helm-occur.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-occur.el
Extracting helm-20191006.647/helm-easymenu.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-easymenu.el
Extracting helm-20191006.647/helm-tags.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-tags.el
Extracting helm-20191006.647/helm-elisp.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-elisp.el
Extracting helm-20191006.647/helm-misc.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-misc.el
Extracting helm-20191006.647/helm-id-utils.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-id-utils.el
Extracting helm-20191006.647/helm-types.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-types.el
Extracting helm-20191006.647/helm-eshell.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-eshell.el
Extracting helm-20191006.647/helm-info.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-info.el
Extracting helm-20191006.647/helm-command.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-command.el
Extracting helm-20191006.647/helm-regexp.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-regexp.el
Extracting helm-20191006.647/emacs-helm.sh
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/emacs-helm.sh
Extracting helm-20191006.647/helm-find.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-find.el
Extracting helm-20191006.647/helm-mode.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-mode.el
Extracting helm-20191006.647/helm-external.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-external.el
Extracting helm-20191006.647/helm-buffers.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-buffers.el
Extracting helm-20191006.647/helm-sys.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-sys.el
Extracting helm-20191006.647/helm-ring.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-ring.el
Extracting helm-20191006.647/helm-locate.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-locate.el
Extracting helm-20191006.647/helm-files.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-files.el
Extracting helm-20191006.647/helm-man.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-man.el
Extracting helm-20191006.647/helm-pkg.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-pkg.el
Extracting helm-20191006.647/helm-color.el
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-color.el
Generating autoloads for helm-adaptive.el...done
Generating autoloads for helm-bookmark.el...done
Generating autoloads for helm-buffers.el...done
Generating autoloads for helm-color.el...done
Generating autoloads for helm-comint.el...done
Generating autoloads for helm-command.el...done
Generating autoloads for helm-config.el...done
Generating autoloads for helm-dabbrev.el...done
Generating autoloads for helm-easymenu.el...done
Generating autoloads for helm-elisp-package.el...done
Generating autoloads for helm-elisp.el...done
Generating autoloads for helm-eshell.el...done
Generating autoloads for helm-eval.el...done
Generating autoloads for helm-external.el...done
Generating autoloads for helm-files.el...done
Generating autoloads for helm-find.el...done
Generating autoloads for helm-font.el...done
Generating autoloads for helm-for-files.el...done
Generating autoloads for helm-grep.el...done
Generating autoloads for helm-help.el...done
Generating autoloads for helm-id-utils.el...done
Generating autoloads for helm-imenu.el...done
Generating autoloads for helm-info.el...done
Generating autoloads for helm-locate.el...done
Generating autoloads for helm-man.el...done
Generating autoloads for helm-misc.el...done
Generating autoloads for helm-mode.el...done
Generating autoloads for helm-net.el...done
Generating autoloads for helm-occur.el...done
Generating autoloads for helm-pkg.el...done
Generating autoloads for helm-regexp.el...done
Generating autoloads for helm-ring.el...done
Generating autoloads for helm-semantic.el...done
Generating autoloads for helm-shell.el...done
Generating autoloads for helm-sys.el...done
Generating autoloads for helm-tags.el...done
Generating autoloads for helm-types.el...done
Generating autoloads for helm-utils.el...done
Generating autoloads for helm-x-files.el...done
Wrote /home/bitouze/.emacs.d/elpa/helm-20191006.647/helm-autoloads.el [2 times]
mapc: Lisp nesting exceeds ‘max-lisp-eval-depth’
```
# Answer
This seems to be due to a bug introduced recently in library `async.el`. It seems to affect Helm code (at least).
See https://lists.gnu.org/archive/html/help-gnu-emacs/2019-10/msg00021.html.
> 1 votes
# Answer
I fixed this issue by commenting out all the lines related to helm in my config, launching emacs and installing the package I needed, and once the package was installed, uncommenting the lines in my config.
> 1 votes
---
Tags: helm, debugging, helm-projectile
---
|
thread-53001
|
https://emacs.stackexchange.com/questions/53001
|
Set difference for sets of strings
|
2019-10-07T03:46:40.300
|
# Question
Title: Set difference for sets of strings
Why the following in emacs-lisp works as expected:
```
(set-difference '(1 2) '(1))
=> (2)
```
But if strings used it doesn't:
```
(set-difference '("foo" "bar") '("foo"))
=> ("foo" "bar")
```
How do can I calculate set difference for sets of strings?
# Answer
> 6 votes
It is for the same reason that:
```
(eql "foo" "foo")
=> nil
```
Along with the other `cl-lib` sequence functions generally, `set-difference` (aka `cl-set-difference`) defaults to using `eql` for its equality test, and therefore in your example none of the members of the first set are present in the second set.
You can tell it what to use for its equality test, however:
```
(set-difference '("foo" "bar") '("foo") :test #'equal)
=> ("bar")
```
---
Tags: string, equality
---
|
thread-53004
|
https://emacs.stackexchange.com/questions/53004
|
improving isearch
|
2019-10-07T11:59:08.650
|
# Question
Title: improving isearch
1. I wonder if I can disable the 'failing overwrapped' warning in the minibuffer and directly wrap around instead if I do a search?
Does anyone know how to facilitate this?
2. Also there is a slight delay in highlighting occurrences of the search-for expression, can I decrease this as well?
3. Finally, how can I invoke custom function upon a key combination, only if Isearch is active?
Specifically, I want to invoke
```
(defun contrib/isearchp-remove-failed-part-or-last-char ()
"Remove failed part of search string, or last char if successful.
Do nothing if search string is empty to start with."
(interactive)
(if (equal isearch-string "")
(isearch-update)
(if isearch-success
(isearch-delete-char)
(while (isearch-fail-pos) (isearch-pop-state)))
(isearch-update)))
```
if I hit `<backspace>` during Isearch.
# Answer
For quick direction change and wrap around you can use the following:
```
(defun isearch-repeat-forward+ ()
(interactive)
(unless isearch-forward
(goto-char isearch-other-end))
(isearch-repeat-forward)
(unless isearch-success
(isearch-repeat-forward)))
(defun isearch-repeat-backward+ ()
(interactive)
(when (and isearch-forward isearch-other-end)
(goto-char isearch-other-end))
(isearch-repeat-backward)
(unless isearch-success
(isearch-repeat-backward)))
(define-key isearch-mode-map (kbd "C-s") 'isearch-repeat-forward+)
(define-key isearch-mode-map (kbd "C-r") 'isearch-repeat-backward+)
```
By binding the keys in `isearch-mode-map` those bindings are only used when isearch is active, you can do the same with your `contrib/isearchp-remove-failed-part-or-last-char` command.
As for the delay question, you need to search for the variable for this setting. You can use `apropos-user-option`, `apropos-documentation` or just `describe-variable` (+ maybe using a completion framework of your choice) to find `isearch-lazy-highlight-initial-delay` which is obsoleted by `lazy-highlight-initial-delay` (as you can read in the docstring).
> 4 votes
---
Tags: isearch
---
|
thread-52846
|
https://emacs.stackexchange.com/questions/52846
|
How to remove message `Indentation setup for shell type sh`
|
2019-09-26T15:26:20.727
|
# Question
Title: How to remove message `Indentation setup for shell type sh`
I open shell files at startup and often get this in `*Messages*`:
```
Setting up indent for shell type sh
Indentation variables are now local.
Indentation setup for shell type sh
```
All my files cause this warning, even if they have indentation, e.g.:
```
source /path/to/file.sh
var=0
foo() {
exit 0
}
```
When Emacs open Python files, it guesses the indentation from the file and does not produce these messages.
How can I avoid these messages when opening files with shell scripts?
# Answer
**This is hardcoded** into the function `sh-set-shell` which is called when `sh-mode` is invoked.
**It's probably better to not touch that behaviour** as it will also not display messages if it was not possible to set up indentation correctly.
You can **hide the message in the minibuffer** (will still be displayed in *Messages*) by placing an advice around that function.
```
(advice-add 'sh-set-shell :around
(lambda (orig-fun &rest args)
(let ((inhibit-message t))
(apply orig-fun args))))
```
Or **hide it completely** by lexically overwritting the `message` function:
```
(require cl-lib)
(advice-add 'sh-set-shell :around
(lambda (orig-fun &rest args)
(cl-letf (((symbol-function 'message) #'ignore))
(apply orig-fun args))))
```
> 5 votes
---
Tags: indentation, shell
---
|
thread-53008
|
https://emacs.stackexchange.com/questions/53008
|
describe key for menu-bar items from `menu-bar-open` calls
|
2019-10-07T14:26:44.850
|
# Question
Title: describe key for menu-bar items from `menu-bar-open` calls
Preface: I disabled `menu-bar-mode` and bound `<mouse-3>` to `menu-bar-open`, via `(global-set-key [mouse-3] #'menu-bar-open)`
**With this configuration, how can I get help for menu-bar items?**
(My ugly workaround now is to temporary enable `menu-bar-mode` and call help with that enabled)
*Problem is:* pressing `C-h k` and then `mouse-3` brings description for `menu-bar-open`.
What I'd like to get instead, is the same `describe-key` behaviour as on `C-<mouse2>` menus.
This should be done in a way, which does not break on emacs updates (i.e: redefining `describe-key` seems to dangerous).
If there is no way to do above , how could I bind `<mouse-3>` to open the menu-bar *and* get the desired help functionality?
*Edit:* Solution from Tobias is not complete, it does not show `local-menu` and `minor-mode-menus`. Function `mouse-menu-bar-map`, which is called from `menu-bar-open` collects them all.
*Edit2:* `[C-down-mouse-3]` does what I expect, but I can't remap this with:
```
(global-set-key [mouse-3] (lookup-key (current-global-map) [C-down-mouse-3]))
```
# Answer
> 1 votes
The value of the variable `facemenu-menu` is bound to `C-<mouse2>` and that value is a sparse keymap.
Instead of binding `#'menu-bar-open` to `<mouse-3>` you can also bind the sparse keymap defining the menu bar to `<mouse-3>`:
EDIT: As indicated by jue t is better to receive the menu bar keymap from `mouse-menu-bar-map` than to use the value of `(lookup-key [menu-bar])` because the menu bar is changed dynamically. `menu-bar-update-hook` cannot be used for reacting on dynamical changes of the menu bar since that hook is only run when the menu bar is switched on. But an advice for `define-key` does the job as far as I could test it up to now.
```
(defun my-menu-bar-update (&rest _ignore)
"Update the [mouse-3] menu bar."
(unless my-menu-bar-update-running
(let ((my-menu-bar-update-running t))
(global-set-key [mouse-3] (mouse-menu-bar-map)))))
(my-menu-bar-update)
(add-hook 'menu-bar-update-hook #'my-menu-bar-update)
(advice-add 'define-key :after #'my-menu-bar-update)
```
---
Tags: help, menu-bar
---
|
thread-18313
|
https://emacs.stackexchange.com/questions/18313
|
file org-capture item under existing heading if it exists
|
2015-11-22T15:24:53.720
|
# Question
Title: file org-capture item under existing heading if it exists
I have the following org-template set up:
```
("mw" "Note" entry (file+headline "~/org/mathematica.org" "WIA")
"* %f code review \n ** %T \n%? \n%a \n%i")
```
So that the heading name is determined by the file name and the "code review," and then there's a subheading using the date and time of the note.
If for example I've already made a note using this template while visiting the file foo.do, I would like the next entry to be with that one as in the following example:
```
> * foo.do code review
> **<2015-11-22 Sun 09:00>
> first note
> **<2015-11-22 Sun 10:00>
> second note
```
But instead I get
```
> * foo.do code review
> **<2015-11-22 Sun 09:00>
> first note
> * foo.do code review
> **<2015-11-22 Sun 10:00>
> second note
```
How can I make all the foo.do code review notes be under the same heading?
# Answer
This is what I use:
```
("p" "Pick a file" entry (function myOrg-captureFile))
```
for my org-capture-template with
```
(defun myOrg-captureFile ()
"pick a file for capture and file the stuff"
(interactive "P")
(let* ((file (read-file-name "Enter file name: "))
(heading (read-string "Heading ")))
(find-file file)
(goto-char 0)
(unless (search-forward (format "* %s" heading) nil t)
(insert (format "* %s\n" heading))
(goto-line -1))))
```
as the function definition. This works rather nicely
> 1 votes
# Answer
You can't; there's nothing implemented that would let you do it. You'll have to make some modifications to the code to support it.
I don't use capturing myself, so I took a look through the documentation to see how it works. You've no doubt read it, but you can jump right to this chapter of the manual in emacs by running `M-: (info "(org) Capture")`; of course it's also available online. This also tells me that the user starts a capture by calling the function `org-capture`, which will be the most natural place to start reading the source. `C-h f org-capture` will show the documentation of that function, along with a link directly to its source code.
When you define a capture template you're specifying several things: how to select the template, what type of entry to create, where to save the entry, and any boilerplate text to insert on behalf of the user.
Your question asks that org-capture match the boilerplate text against the content of the save location in order to avoid adding some lines to the file twice. You could implement it this way, but I recommend that you don't. The save location doesn't need to be an org file at all; you could be capturing to any type of file at all. The boilerplate text therefore isn't always going to use org syntax. A good example would be capturing to a BibTeX file; the boilerplate would presumably be LaTeX.
Instead I think the best way to implement it would be to add a new type of save location. These are all handled by the `org-capture-set-target-location` function in `org-capture.el`. You're currently using the `'file+headline` locator, which takes a filename and a headline, and sets org-capture to insert the new entry as a subheading of that headline found in that file. This is almost what you need. If you could specify `(file+headline "~/org/mathematica.org" "WIA" "%f code review")` then you would be in good shape.
However, the `'file+headline` locator only accepts a single headline, and doesn't allow any of the substitutions allowed in the boilerplate text.
Allowing multiple headlines shouldn't be too difficult to implement. Just modify this branch of the case in `org-capture-set-target-location` so that it loops over all of the remaining items in the list, first searching for the headline and then narrowing the buffer to that subtree after it either finds it or creates it. Each time through the loop the search will naturally be limited to the narrowed region of the file, so the correct subheadings will be found or created.
Allowing substitutions should be even easier; just call `org-capture-fill-template` on each argument before using it. This should be done for all cases, so do it before handling any of them. This list is never likely to be very long, so the simplest thing to do is to map down the list calling `org-capture-fill-template` on all the strings, even though you're later going to loop over the list again.
Also, once you've written this I recommend submitting your changes for inclusion in the next release; see orgmode.org for the details on how to do that.
> -1 votes
---
Tags: org-mode, org-capture
---
|
thread-31448
|
https://emacs.stackexchange.com/questions/31448
|
Report duplicates in a list?
|
2017-03-13T20:28:28.670
|
# Question
Title: Report duplicates in a list?
**Q:** how do I get only the duplicate elements in a list?
`delete-dups` (and `cl-delete-duplicates`) *deletes* all duplicate elements from a list:
```
(delete-dups '(a b c c d d)) ; => '(a b c d)
```
I want the reverse: is there a function that returns *only* the duplicates in a list?
```
(mystery-function '(a b c c d d)) ; => '(c d)
```
# Answer
> 6 votes
I think the easiest way is to use hash tables:
```
(defun get-duplicates (list &optional test)
(let ((ht (make-hash-table :test (or test #'equal)))
ret)
(dolist (x list)
(incf (gethash x ht 0)))
(maphash (lambda (key value)
(when (> value 1)
(push key ret)))
ht)
ret))
(get-duplicates '(a 2 a b 3 2))
==> (2 a)
```
# Answer
> 7 votes
Using dash:
```
(defun find-duplicates (list)
"Return a list that contains each element from LIST that occurs more than once."
(--> list
(-group-by #'identity it)
(-filter (lambda (ele) (> (length ele) 2)) it)
(mapcar #'car it)))
```
A quick test suite:
```
(ert-deftest nothing ()
(should-not (find-duplicates '())))
(ert-deftest no-duplicates ()
(should-not (find-duplicates '(1 2 3 4 5 6 7 "eight"))))
(ert-deftest single-duplicate ()
(should (equal (find-duplicates '(1 2 3 4 1))
'(1))))
(ert-deftest multiple-duplicates ()
(should (equal (sort (find-duplicates '(1 2 3 4 1 6 7 8 9 2))
#'<)
'(1 2))))
(ert-deftest string-duplicates ()
(should (equal (find-duplicates '(1 2 "three" 4 "three"))
'("three"))))
```
It currently seems to return the items in the order of the first occurrence of each duplicate, but I don't see anything in `-group-by` that guarantees that, so I don't think that can be relied on. It could possibly be more efficient, using hashtables, but this works.
# Answer
> 3 votes
Here is a non-hash version:
```
#+BEGIN_SRC emacs-lisp
(defun find-duplicates (list)
(loop for (item . count) in (let ((counts '())
place)
(dolist (el list)
(setq place (assoc el counts))
(if place
(incf (cdr place))
(push (cons el 1) counts)))
counts)
if (> count 1)
collect item))
#+END_SRC
```
# Answer
> 1 votes
Reversing `delete-dups` using... `delete-dups` (and `seq`):
```
(defun report-dups (list)
(delete-dups (seq-filter
(lambda (el) (member el (cdr (member el list))))
list)))
```
# Answer
> 0 votes
This is similar to @caseneuve's definition.
```
(defun report-dups (xs)
(delete-dups (cl-remove-if-not (lambda (x) (member x (cdr (member x xs)))) xs)))
```
But both suffer from testing each element in the list, even if it has already been tested. And then they run `delete-dups`.
This definition is straightforward, and it doesn't suffer from those inefficiencies:
```
(defun report-dups (xs)
(let ((ys ()))
(while xs
(unless (member (car xs) ys) ; Don't check it if already known to be a dup.
(when (member (car xs) (cdr xs)) (push (car xs) ys)))
(setq xs (cdr xs)))
ys))
```
It also seems to be about 6 times faster than the hash-table solution (`get-duplicates`, above).
---
Tags: list
---
|
thread-53019
|
https://emacs.stackexchange.com/questions/53019
|
a lisp function to toggle a mode (org mode in this case) on and off with a single shortcut
|
2019-10-07T23:47:31.153
|
# Question
Title: a lisp function to toggle a mode (org mode in this case) on and off with a single shortcut
I'm trying to create a shortcut (C-c c) regardless of what kind of file is currently opened (it could be a .pl file or a .txt file or an extension less file) pressing C-c c should turn on org mode if its not turned on already. pressing it again and again toggles it off and on....
Here's what I have
```
(global-set-key (kbd "C-c c") (lambda () (interactive)
(org-mode))))
```
Any help? It's important that when turning off org mode, whatever the "native" mode the file was originally on comes back on.
# Answer
> 2 votes
This seems to work on a few examples I have tried:
```
(defvar-local last-mode nil
"Buffer-local variable to store last mode in.")
(defun toggle-org-mode ()
"Toggle the mode between the current mode and `org-mode'."
(interactive)
(make-local-variable 'last-mode)
(put 'last-mode 'permanent-local t)
(if (eq major-mode 'org-mode)
(progn
(message "switch back to %s" last-mode)
(funcall last-mode)
(setq last-mode nil))
;; This means you are in the native mode you started in and now want to
;; switch to org-mode
(message "switch to org from %s" major-mode)
(setq last-mode major-mode)
(org-mode)))
```
This is more subtle than it seemed. You have to mark the buffer-local variable as permanent, or it can get wiped out by changing the major mode.
---
Tags: org-mode
---
|
thread-33974
|
https://emacs.stackexchange.com/questions/33974
|
Reloading .Xresources colors on the fly
|
2017-07-05T14:45:56.207
|
# Question
Title: Reloading .Xresources colors on the fly
I use pywal on Linux which is really cool and works on everything I use except for Firefox (gotta tinker with it) and (GTK) Emacs.
For Emacs the author recommends this which is awesome but requires me to restart Emacs whenever I change my wallpaper (and my global colorscheme).
For terminal Neovim with the wal vim theme it just works, I reload my colorscheme and wallpaper and the terminal AND Neovim change colors, but for Emacs I must restart it for it to use the new .Xresources, which is a PITA since I use Spacemacs.
Now I'd like to know if there's any way at all to make Emacs reload it's .Xresources data on the fly (if there isn't any way then I'll seriously consider switching full-time to Neovim because with some configuration it can be really, really good. One thing I really like about it is the terminal, lightyears better than `ansi-term`)
# Answer
> 2 votes
**PART-1: modifying `xresources-theme.el`**
The problem with `xresources-theme.el` is that it uses `x-get-resource` to get the `Xresources` colors and it doesn't refresh (even if `.Xresources` has been updated using `xrdb`) until `emacs` is closed and restarted.
So my solution relies on parsing `.Xresources` file directly. To do this replace the function `xresources-theme-color` in `xresources-theme.el` with the following:
```
(defun xresources-theme-color (name)
"Read the color NAME (e.g. color5) from the X resources."
(shell-command-to-string (format
"xrdb -q | grep \"%s\" | awk '{print $2}' | tr -d \"\\n\""
(concat "*\\(.*\\)" name ":")))
)
```
Now you can reload the `xresources-theme.el` using `M-x load-file /path/to/file/xresource-theme.el`.
(*CAUTION:* The above code uses `grep` which can be tricky as different users have different styles while writing `.Xresources` and `grep` can end up matching to something not intended. So you would have to customize the `grep` part in a manner that is appropriate for your `.Xresources`. Also, I will like to hear about any ideas you have about how to make `grep` command more universal in above.)
**PART-2: (optional) using `SIGUSR1` for hot-reloading `xresources-theme.el`**
Add the following to your `.emacs`
```
;; SIGUSR1 to reload config files
(defun sigusr1-handler ()
(interactive)
(load "xresources-theme.el"))
(define-key special-event-map [sigusr1] 'sigusr1-handler)
```
Now you can hot-reload `xresoures-theme.el` by executing `kill -USR1 $(pgrep emacs)` at `bash` prompt.
(One takes a similar approach to reload the config for `URxvt` as in this github-project.)
(*CAUTION*: Sane thing to do: make sure you have `(add-to-list 'load-path "~/path/to/xresources-theme")`in your `.emacs`)
**PART-3: (optional) suggested workflow**
I would recommend creating a bash script called `apply-themes.sh` with the content:
```
#!/bin/bash
xrdb .Xresources
kill -1 $(pgrep urxvt)
kill -USR1 $(pgrep emacs)
```
and use it to update your `.Xresources` so that `URxvt` and `emacs` get updated along with it as well. If you use `pywal` or similar you could still adapt your workflow to accomodate the above.
Hope this helps. Cheers!
(Sept 9, 2022's Edit: p.s.: Been years and no up-votes yet! :( Please up-vote if useful.)
---
Tags: spacemacs, themes, x-resources
---
|
thread-53022
|
https://emacs.stackexchange.com/questions/53022
|
How to make font-lock use my face?
|
2019-10-08T03:34:10.713
|
# Question
Title: How to make font-lock use my face?
I'm interested in making a major mode to display PGN files nicely. I'm trying to create my own faces since the defaults don't seem super-appropriate.
My mode definition looks like this:
```
(defface my-r-face `((t (:foreground "red"))) "Red highlight")
(setq pgn-highlights
'(("Pi\\|Infinity" . font-lock-constant-face)
("Sin\\|Cos" . font-lock-string-face)
("[0-9]+\\." . font-lock-keyword-face)
;; ("%.*" . my-r-face) ;; This doesn't show up (the relevant text appears just like the default text
("%.*" . font-lock-comment-face) ;; works great - relevant text looks like the comment face
))
(define-derived-mode pgn-mode fundamental-mode "mymath"
"major mode for editing mymath language code."
(setq font-lock-defaults '(pgn-highlights)))
```
A typical file that I'd like to use this on is:
```
[Event "?"]
[Site "?"]
[Date "2019.6.3"]
[Round "?"]
[White "Mike"]
[Black "Mikey"]
[Result "*"]
[WhiteELO "?"]
[BlackELO "?"]
%Created by Caissa's Web PGN Editor
1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. O-O Nf6 5. d3 d6 6. Nc3 a6 7. a3 Be6 8.
Bxe6 fxe6 9. h3 O-O 10. Be3 Ba7 11. Ra2 Qe8 12. Qc1 Nh5 13. Qd2 Nf4 14. g3
Nxh3+ 15. Kg2 Qh5 16. Rh1 Qxf3+ 17. Kh2 Nxf2 18. Rf1 Qh5+ 19. Kg2 Qf3+ 20.
Kg1 Qh1#
```
The issue is the line with the comment (`%Created by...`). **If I use the built-in `font-lock-comment-face` then everything is highlighted nicely and the comment looks like the normal comment. But if I change it to use `my-r-face`then the comment is *not* highlighted, and instead appears be be the default font face.**
What am I doing wrong here?
# Answer
> 1 votes
Just add this, after the `defface`, to define a variable of the same name, whose value is the face symbol:
```
(defvar my-r-face 'my-r-face
"Variable for face `my-r-face'.)
```
`font-lock-defaults` in the case of just `(pgn-highlights)` defines `font-lock-keywords` as the list that is the value of variable `pgn-highlights`.
The doc for **`font-lock-keywords`** tells you about this case, which is the one you are using:
> `(MATCHER . FACESPEC)`
>
> In this kind of element, `FACESPEC` is an expression whose value specifies the face to use for highlighting. In the simplest case, `FACESPEC` is **a Lisp variable** (a symbol) **whose value is a face name**.
>
> ```
> ;; Highlight occurrences of ‘fubar’,
> ;; using the face which is the value of ‘fubar-face’.
> ("fubar" . fubar-face)
>
> ```
---
Tags: major-mode, font-lock
---
|
thread-53010
|
https://emacs.stackexchange.com/questions/53010
|
configure packages without`provide` with `use-package`
|
2019-10-07T14:58:02.993
|
# Question
Title: configure packages without`provide` with `use-package`
How to configure packages, which have no `(provide <PACKAGENAME>)` call in their source code?
Immediate problem: configure `isearch` with use-package.
(Editing `isearch.el` is not an option because it may break updates and may trigger heavy bug hunting)
*Edit:* answering Drews comment: `use-package` can be used to cluster elisp code, which should belong to a package/library. The user is then able to write functions or set up keybindings, which are part of a users emacs configuration. Whith this technique it is possible to lazy load self written functions, or even redefine functions from a package *after* the package/library has been loaded. (Of course there are also other ways to do that but use-package is a nice Domain Specific Language for that kind of configuration).
By "configure" I mean writing a valid `use-package` sexp which serves the purpose of changing emacs default behavior.
Yes, with "Editing" I meant changing the source code file isearch.el. Emacs is hackable after all.
# Answer
> Immediate problem: configure `isearch` with use-package.
You can pass the filename as a string instead of a symbol (this is similar to `eval-after-load`, which is basically what the `use-package` macro expands to).
```
(use-package "isearch"
...)
```
Another possibilty for builtin preloaded packages like isearch is to "use" the "emacs" package (since Emacs always provides the `emacs` feature):
```
(use-package emacs ; isearch
...)
```
Or simply put the `provide` into your init file:
```
(provide 'isearch)
(use-package isearch
...)
```
See also Bug#25026 - Add missing (provide 'isearch) (this is done as of Emacs 26.1).
> 2 votes
---
Tags: use-package, isearch
---
|
thread-53031
|
https://emacs.stackexchange.com/questions/53031
|
get the full path (path + filename) of the currently editing file in to the OS clipboard
|
2019-10-08T14:23:33.217
|
# Question
Title: get the full path (path + filename) of the currently editing file in to the OS clipboard
when editing a file (for example a .pl file)
Whats the quickest way to get the full path (path + filename) of the currently editing file in to the OS clipboard.
I'm on macOS, where `echo "hello" | pbcopy` works btw
# Answer
Here's the function I use, which you can bind to a keybinding. The link to the original author of the function is also provided.
```
;; http://camdez.com/blog/2013/11/14/emacs-show-buffer-file-name/
(defun cpm/show-and-copy-buffer-filename ()
"Show the full path to the current file in the minibuffer and copy to clipboard."
(interactive)
(let ((file-name (buffer-file-name)))
(if file-name
(progn
(message file-name)
(kill-new file-name))
(error "Buffer not visiting a file"))))
```
> 2 votes
---
Tags: buffers, files
---
|
thread-53027
|
https://emacs.stackexchange.com/questions/53027
|
Org export on mac os # option
|
2019-10-08T11:48:40.700
|
# Question
Title: Org export on mac os # option
When I press `C-c C-e` in org mode I get the export options. However I can not choose "Insert template" as when I try and type the `#` in mac os I need to press the `option` key and the `3` key. But `Option` is the meta key. How can I get to the insert template option.
# Answer
> 1 votes
try
```
(setq mac-right-option-modifier 'none) ;; unbind right key for accented input
```
Though for my mac you use shift and 3 to get the '#' sign. But in any case it is good to keep one of the 'option' keys free for modifiers.
---
Tags: org-mode, org-export, osx
---
|
thread-53000
|
https://emacs.stackexchange.com/questions/53000
|
Is variable assignment an atomic operation in elisp?
|
2019-10-07T00:00:21.830
|
# Question
Title: Is variable assignment an atomic operation in elisp?
I have a situation in a mode I'm writing that saves a portion of the output of a long-running asynchronous process to a variable at intermittent intervals. I need to access this data periodically. My question is are variable assignments in elisp atomic (meaning I would always get a complete value, even if it was potentially slightly out of date) or would this be a race condition?
# Answer
Elisp relies on cooperative concurrency, so yes, these are "atomic".
But I suspect, like Tobias, that this answer won't help you very much because you're probably not asking the right question.
> 2 votes
---
Tags: process, variables, async
---
|
thread-53038
|
https://emacs.stackexchange.com/questions/53038
|
Create many buffers, name properly, silently
|
2019-10-08T16:47:57.053
|
# Question
Title: Create many buffers, name properly, silently
I am trying to avoid using the desktop save mode 1 option in my `.emacs` file.
We sudo a shared service account, so my buffers may differ from my colleagues buffers.
I launch Emacs from GNU/Linux with `emacs -nw` (as the `sudo`'d user) and then I start creating my buffers. We have a monthly machine restart. I do not mind losing my history, but it would be cool if I could save everything and just re-launch that.
If I cannot simply save / relaunch the save, then I'd like to know how to create ~20 buffers by executing a file (if possible).
Also, once I launch a buffer - is it possible to also run commands automatically after the launch?
# Answer
> 0 votes
You could automate the opening of those 20 buffers and associate them with shells with something like this called from your init file (code for ilustrative purposes only):
```
(defun twenty-buffers()
"Create 20 buffers and associate them to a shell process."
(interactive)
(let ((buffer-names (list "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t")))
(dolist (item buffer-names)
(shell (get-buffer-create item)))))
```
You can send input to each shell programmatically just switching to the desired buffer and inserting the text for the command at the end of the buffer this way:
```
(insert "ls -lah")
(comint-send-input)
```
On saving the buffers there are various options,but probably I'd go with `run-at-time` and a function similar to twenty-buffers shown above.
# Answer
> 0 votes
I would simply set `desktop-dirname` to something non-conflicting. Then you can safely use `desktop` as normal.
---
Tags: buffers, auto-save
---
|
thread-53047
|
https://emacs.stackexchange.com/questions/53047
|
Customising the increments in an org-mode timestamp
|
2019-10-09T10:13:31.553
|
# Question
Title: Customising the increments in an org-mode timestamp
When I create an appointment in org-agenda I make use of timestamps. The item is created with today's date and time and I then place my cursor on the date and time respectively and use `S-up` or `S-down` to increase or decrease the time until I get to the time I need. I see that time increments by default are 5 minutes. I would prefer it to be 30 minutes. Can can I achieve this?
# Answer
`S-up` and `S-down` are bound to `org-shiftup` and `org-shiftdown`. On timestamps, these call `org-timestamp-up` and `org-timestamp-down` respectively. These methods use the variable `org-time-stamp-rounding-minutes`:
> Number of minutes to round time stamps to.
>
> These are two values, the first applies when first creating a time stamp.
>
> The second applies when changing it with the commands ‘S-up’ and ‘S-down’.
>
> When changing the time stamp, this means that it will change in steps of N minutes, as given by the second value.
So we can change the second value to `30`:
```
(setf (elt org-time-stamp-rounding-minutes 1)
30)
```
And now these methods will move by 30 minutes\[1\].
\[1\] It will move to the nearest multiple of this value; `S-up` once on `<2019-10-09 Wed 06:27>` will move it to `<2019-10-09 Wed 06:30>`; calling it again gives `<2019-10-09 Wed 07:00>`.
> 3 votes
---
Tags: org-agenda, time-date
---
|
thread-53048
|
https://emacs.stackexchange.com/questions/53048
|
Convert a selected region to org table
|
2019-10-09T10:25:27.880
|
# Question
Title: Convert a selected region to org table
I have such a block
```
Function Description
count Number of non-NA observations
sum Sum of values
mean Mean of values
mad Mean absolute deviation
median Arithmetic median of values
min Minimum
max Maximum
mode Mode
abs Absolute Value
prod Product of values
std Bessel-corrected sample standard deviation
var Unbiased variance
sem Standard error of the mean
skew Sample skewness (3rd moment)
kurt Sample kurtosis (4th moment)
quantile Sample quantile (value at %)
cumsum Cumulative sum
cumprod Cumulative product
cummax Cumulative maximum
cummin Cumulative minimum
```
How could convert it to org table?
# Answer
There's a function `org-table-convert-region`:
```
org-table-convert-region is an interactive autoloaded compiled Lisp
function in ‘org-table.el’.
(org-table-convert-region BEG0 END0 &optional SEPARATOR)
Convert region to a table.
The region goes from BEG0 to END0, but these borders will be moved
slightly, to make sure a beginning of line in the first line is included.
SEPARATOR specifies the field separator in the lines. It can have the
following values:
(4) Use the comma as a field separator
(16) Use a TAB as field separator
(64) Prompt for a regular expression as field separator
integer When a number, use that many spaces, or a TAB, as field separator
regexp When a regular expression, use it to match the separator
```
Note that your table has an inconsistent number of spaces between the function and the description, so we can't use the `integer` argument.
So we can provide three prefix arguments to the function (`C-u C-u C-u M-x org-table-convert-region RET`), to make it prompt for a regex.
The regex `\{2,\}` (two or more spaces) will match what we want.
Overall, this will do it: `C-u C-u C-u M-x org-table-convert-region RET SPC {2,} RET`.
> 1 votes
---
Tags: org-mode
---
|
thread-53035
|
https://emacs.stackexchange.com/questions/53035
|
How to display unicode chars in ielm
|
2019-10-08T16:10:54.837
|
# Question
Title: How to display unicode chars in ielm
I'm using emacs on MAC OSX
```
ELISP> (emacs-version)
"GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2019-09-06"
```
ielm REPL echoes back the octal, hex and character representation when entering an integer less than or equal to 127:
```
ELISP> 81
81 (#o121, #x51, ?Q)
ELISP> ?a
97 (#o141, #x61, ?a)
```
But when using unicode chars like for example lambda ('λ') I get only the number 955
```
ELISP> 955
955 (#o1673, #x3bb)
ELISP> ?\N{Greek small letter Lamda}
955 (#o1673, #x3bb)
ELISP> ?\u03bb
955 (#o1673, #x3bb)
```
Since Emacs support full unicode, (you need to use Symbola or some similar font), it should be possible for ielm to echo back the actual glyph for the character:
ELISP\> (concat '(?I 32 955 32 ?\u2665 32) "Emacs") "I λ ♥ Emacs"
# Answer
This behaviour is controlled by the `eval-expression-print-maximum-character` variable.
```
eval-expression-print-maximum-character is a variable defined in `simple.el'.
Its value is 2305843009213693951
Original value was 127
Probably introduced at or before Emacs version 26.1.
Documentation:
The largest integer that will be displayed as a character.
This affects printing by `eval-expression' (via
`eval-expression-print-format').
```
See Lisp-Eval for further details.
> 1 votes
---
Tags: unicode, characters, ielm
---
|
thread-53056
|
https://emacs.stackexchange.com/questions/53056
|
How can I check the implementation of a builtin function?
|
2019-10-09T15:48:54.837
|
# Question
Title: How can I check the implementation of a builtin function?
Is there a way to check the implementation of a builtin function (e.g. `load-file`) without cloning the Emacs repository?
# Answer
For `load-file` `C-h f load-file`then follow the link from the first line, in this case:
```
load-file is an interactive compiled Lisp function in ‘files.el’.
```
will open the elisp function definition, C source code, AFAIK, will require the repo.
> 4 votes
# Answer
On debian, and I guess on Ubuntu as well, the elisp sources (.el files as opposed to byte compiled .elc files) are available in the `emacs-el` package.
The elisp sources are not provided in the basic emacs package since they're not necessary to run emacs, only usefull if, like you do, you want to look at the source.
So absolutely don't need to clone the emacs repo, you just need to install that emacs-el package, eg
```
sudo apt-get install emacs-el
```
> 2 votes
# Answer
If you are interested in looking at a file from a computer that Emacs isn't even installed on, you can take the filename it's found in from help (`C-h f load-file RET`), then browse the source at Emacs's GNU Savannah repository, or the Github mirror.
This code will be later than the version of Emacs you're using, and it may be different in important ways.
> 1 votes
---
Tags: help
---
|
thread-52819
|
https://emacs.stackexchange.com/questions/52819
|
What is the equivalent of save-restriction for org-mode cycling?
|
2019-09-24T19:32:34.417
|
# Question
Title: What is the equivalent of save-restriction for org-mode cycling?
I coded a function that accesses lines in a folded drawer:
```
(defun org-try-merging-last-clock-out ()
"Try to merge the latest clock-out, and catch the error if the discrepancy is not zero."
(save-restriction
(save-excursion
(org-clock-goto)
(search-forward org-last-inserted-timestamp)
(condition-case nil
(org-clock-merge t)
(error)))))
```
The function `org-clock-merge` is an interactive function that I defined in this other thread that merges two clock lines. It is long and I can copy it here if needed.
My clock lines are in a `LOGBOOK` drawer. The headline initially looks like this:
```
** DONE Some task...
```
After calling the function programmatically through the `org-clock-out-hook`, it looks like this:
```
** DONE Some task
CLOSED: [2019-09-24 Tue 15:56] SCHEDULED: <2019-10-07 Mon>
:PROPERTIES:
:CREATED: [2019-09-23 Mon]
:END:
:LOGBOOK:...
```
I confirm that my `org-clock-merge` function ran and merged the clock stamps. I would like the headline appearance not to change after running the command.
Does a function similar to `save-restriction` for narrowing exist for org-mode cycling?
# Answer
> 1 votes
You might try `org-save-outline-visibility`. It sounds like it should do what you want. From the documentation (`C-h f org-save-outline-visibility RET`):
```
Save and restore outline visibility around BODY.
If USE-MARKERS is non-nil, use markers for the positions. This
means that the buffer may change while running BODY, but it also
means that the buffer should stay alive during the operation,
because otherwise all these markers will point to nowhere.
```
**Update from original poster:** This is indeed what I wanted, and here is some example code:
```
(defun org-try-merging-last-clock-out ()
"Try to merge the latest clock-out, and catch the error if the discrepancy is not zero."
(save-excursion
(org-save-outline-visibility t
(progn
(org-clock-goto)
(search-forward org-last-inserted-timestamp)
(condition-case nil
(org-clock-merge t)
(error))))))
```
It saves visibility of the heading and also any drawers in the heading.
# Answer
> 1 votes
You might be looking for `org-narrow-to-subtree` and/or `org-toggle-narrow-to-subtree`
Anyway, in your code it looks like you're calling `org-cycle` over the LOGBOOK, cycling will only affect it, not the subtree.
This code snippet will help you keeping the folding state:
```
(defun org-try-merging-last-clock-out ()
"Try to merge the latest clock-out, and catch the error if the discrepancy is not zero."
(org-back-to-heading) ;; Move to heading line to check if folded
(let (folded (invisible-p (point-at-eol))) ; is subtree folded?
(save-restriction
(save-excursion
(org-narrow-to-subtree)
(when folded (org-cycle)) ; cycle if folded
;; do whatever you need
(goto-char (point-max))
(insert "whatever")
;; end of task
(org-back-to-heading)
(when folded (org-cycle)) ; cycle again if it was folded
)))
```
---
Tags: org-mode
---
|
thread-53059
|
https://emacs.stackexchange.com/questions/53059
|
Ignore a repeated diary entry, just this once, in Org Agenda?
|
2019-10-09T16:09:42.327
|
# Question
Title: Ignore a repeated diary entry, just this once, in Org Agenda?
**In a nutshell:** *I'm looking for a way to selectively hide one instance of a repeated diary entry so it doesn't show up in my org-agenda.*
---
I have many repeating diary entries for things like weekly meetings, etc. using basic sexp syntax.
I've set up my org-agenda to include these diary entries in my weekly/daily views.
Sometimes, a weekly event is cancelled. How can I hide/delete it from my org agenda just this once, without deleting the entire entry in the diary?
# Answer
How about modifying the *last* line of your custom diary sexp so that it becomes an `and` statement that checks to ensure that the DATE is *not* a `member` of your excluded dates?:
```
(and [YOUR-SEXP-RESULT-THAT-IS-NON-NIL]
(not (member DATE '((2 28 2017)
(5 1 2017)
(5 31 2017)))))
```
Granted, of course, you will need to modify the diary sexp every time you decide to add a custom date to be excluded. You can assign the list of excluded dates to a variable that is accessible to the sexp, if that makes things easier to add additional dates as needed ...
Here is a link to an example of a custom diary sexp that looks for the last day of every month:
https://emacs.stackexchange.com/a/31708/2287
The last line in that *linked* example is `(= day last-day-of-month)`, which would be replaced with the snippet above -- the incoming argument of `date` to the custom sexp named `diary-last-day-of-month` is written in *lowercase*; i.e.,
```
(and (= day last-day-of-month)
(not (member date '((2 28 2017)
(5 1 2017)
(5 31 2017)))))
```
> 1 votes
---
Tags: org-mode, org-agenda, diary
---
|
thread-19861
|
https://emacs.stackexchange.com/questions/19861
|
How to unhighlight symbol highlighted with highlight-symbol-at-point
|
2016-01-27T03:57:47.377
|
# Question
Title: How to unhighlight symbol highlighted with highlight-symbol-at-point
`highlight-symbol-at-point` is really useful however I could not find an easy way to un-highlight symbols.
Currently I have to call `unhighlight-regexp` repeatedly for each highlighted symbol.
Is there a better way to:
* unhighlight all highlighted symbols in a buffer
* unhighlight a symbol at point?
# Answer
> 22 votes
## Is there a better way to unhighlight all highlighted symbols in a buffer?
From `C-h f unhighlight-regexp`, we get
> (unhighlight-regexp REGEXP)
>
> Remove highlighting of each match to REGEXP set by hi-lock. Interactively, prompt for REGEXP, accepting only regexps previously inserted by hi-lock interactive functions. If REGEXP is t (or if C-u was specified interactively), then remove all hi-lock highlighting.
That means that we simply need to call `unhighlight-regexp` with `t` as its argument to remove all hi-lock highlighting in the buffer.
If it were a one-time thing, it could be quickly done by `M-: (unhighlight-regexp t)` or `C-u M-s h u`. But it seems that this is something you need to do quite often. In that case, it's better to wrap it in an `interactive` function and bind it to some key.
Below is a proposed solution where `my/unhighlight-all-in-buffer` is the wrapper interactive function and it is bound to `hU` in the `search-map`. By default the `search-map` prefix is `M-s`. So now, just as `M-s h u` launches `unhighlight-regexp`, `M-s h U` (note the capital U) launches `my/unhighlight-all-in-buffer`.
```
(require 'hi-lock)
(defun my/unhighlight-all-in-buffer ()
"Remove all highlights made by `hi-lock' from the current buffer.
The same result can also be be achieved by \\[universal-argument] \\[unhighlight-regexp]."
(interactive)
(unhighlight-regexp t))
(define-key search-map "hU" #'my/unhighlight-all-in-buffer)
```
---
## Is there a better way to unhighlight a symbol at point?
The good thing is that you do not need to place the point on a symbol you need to unhighlight.
You simply call `M-x unhighlight-regexp` or `M-s h u` (its default binding) and hit `M-p`/`M-n` till you come across the regexp of the symbol you need to unhighlight, and hit Enter.
# Answer
> 10 votes
`C-u C-x w r`
> `(unhighlight-regexp REGEXP)` (...) If REGEXP is t (or if `C-u` was specified interactively), then remove all hi-lock highlighting.
# Answer
> 4 votes
Another way is to use library **Highlight** (`highlight.el`), commands `hlt-highlight-symbol-at-point` and `hlt-unhighlight-symbol-at-point`.
They are bound default to `C-x X h s` and `C-x X u s`, respectively. All of the highlighting and unhighlighting commands are bound on prefix key **`C-x X`** by default. Highlighting commands use prefix key **`C-x X h`**. Unhighlighting commands use prefix key **`C-x X u`**. You can use a different prefix key than `C-x X` by just binding it to prefix command `hlt-map`.
Highlighting in library Highlight can use overlays or text properties (or both). The highlighting face or color can be chosen automatically (from a customized sequence of faces and colors) or not.
Highlighting can use property `font-lock-face`, so that it is controlled by Font Lock mode. Or it can use property `face`, so that it is not controlled by it. (You can use property `face` to highlight in buffers that do not use font-lock, and the highlighting remains in font-locked buffers when you turn off Font Lock mode.)
# Answer
> 1 votes
This will unhighlight a single symbol:
```
(defun unhighlight-symbol-at-point ()
"Remove highlight of symbol at point."
(interactive)
(unhighlight-regexp (concat "\\_<" (thing-at-point 'symbol) "\\_>")))
```
---
Tags: highlighting
---
|
thread-53074
|
https://emacs.stackexchange.com/questions/53074
|
Change AUCTeX behavior inside an environment
|
2019-10-10T09:29:19.437
|
# Question
Title: Change AUCTeX behavior inside an environment
I am using the LaTeX markdown package to insert quick notes in my document. I would like Emacs to switch to markdown mode inside the markdown environment so it for example won't automatically re-indent markdown nested lists.
Here is an excerpt of the latex file:
```
\chapter{Introduction}
\label{chap:intro}
\begin{markdown}
Here's what'll be in this chapter:
* thing 1
* thing 2
- aspect A
- aspect B
\end{markdown}
In this chapter, we describe ...
```
Is there a way to change Emacs behavior without the need to invoking markdown mode manually each time I want to edit the inside of the environment?
# Answer
> 5 votes
You can use mmm-mode available at GNU Elpa.
There are examples how `mmm-mode` is to be configured.
In your case the following Elisp lines in your init file should work.
When you open a LaTeX file with `markdown` environments those are highlighted in grey. If you put point within those regions `markdown-mode` becomes active (e.g., indentation). When you write a new `markdown` environment per hand you should run `Parse Block` from the `MMM` menu. This is automagically done for you if you insert a `markdown` environment by `C-c C-e` (bound to `LaTeX-environment`).
```
(require 'mmm-auto)
(setq mmm-global-mode 'maybe)
(mmm-add-classes
'((latex-markdown
:submode markdown-mode
:face mmm-declaration-submode-face
:front "\\\\begin{markdown}"
:delimiter-mode nil
:back "\\\\end{markdown}")))
(mmm-add-mode-ext-class 'latex-mode nil 'latex-markdown)
(defun my-LaTeX-parse-block-after-insert-environment (env _b _e)
"Parse MMM block after inserting a markdown environment.
`mmm-parse-block' is only called when ENV is \"markdown\"."
(when (string-equal env "markdown")
(mmm-parse-block 3)))
(add-hook 'LaTeX-after-insert-env-hook #'my-LaTeX-parse-block-after-insert-environment)
```
---
Tags: auctex, markdown, multiple-modes
---
|
thread-53052
|
https://emacs.stackexchange.com/questions/53052
|
How to make a diff tool ignore asterisks?
|
2019-10-09T12:59:27.503
|
# Question
Title: How to make a diff tool ignore asterisks?
I want to compare and merge some org files. How can I make a diff tool assume that some tasks or notes are identical, even if they are on different levels, i.e. strings only differ in the number of asterisks (\*) at the beginning? I would then collapse those strings and consider merging only the rest that really differ.
# Answer
> 2 votes
One can configure `ediff-filtered-filters` such that it replaces multiple leading stars with one leading star and call `ediff-buffers`.
The following Elisp function `my-org-ediff` does that for you. Just copy the Elisp code to your init file, restart Emacs, and use `my-org-ediff` for diffing org files in the way you want it.
```
(defvar ediff-filtered-filters)
(defun my-org-ediff ()
"Ediff like `ediff-buffers' but convert all heading leaders \\*+\\([[:space:]]\\) to \\*\\1."
(interactive)
(let ((ediff-filtered-filters '(("^\\*+\\([[:space:]]\\)" . "*\\1"))))
(call-interactively #'ediff-buffers)))
```
# Answer
> 2 votes
If you are content to use `diff` on the bash command line and are not looking for a pure emacs solution, you can use process substitution to pass into `diff` slightly modified files:
```
diff <(sed -E 's/^\*+/*/' file1.org) <(sed -E 's/^\*+/*/' file2.org)
```
Each `sed` command outputs its input file unchanged, except that a string of one or more asterisks at the beginning of a line is changed to a single asterisk. Bash process substitution makes a file out of that output. Conceptually, the above is equivalent to
```
sed -E 's/^\*+/*/' file1.org > /tmp/file1.modified.org
sed -E 's/^\*+/*/' file2.org > /tmp/file2.modified.org
diff /tmp/file1.modified.org /tmp/file2.modified.org
rm /tmp/file1.modified.org /tmp/file2.modified.org
```
You can also write a bash script to simplify the invocation:
```
#!/bin/bash
diff <(sed -E 's/^\*+/*/' $1) <(sed -E 's/^\*+/*/' $2)
```
Save it as `stardiff` in `$HOME/bin` (which I assume is in your `$PATH`), make it executable: `chmod +x $HOME/bin/stardiff` and invoke it like this:
```
stardiff file1.org file2.org
```
Process substitution is a general mechanism and is very useful in situations like this one, where we basically want to pipe the output of a command (the sed command output) into the input of another command (the diff command), except that we have two or more inputs: an ordinary pipe cannot deal with that, but process subsitution can.
Of course, this has nothing to do with emacs, but I hope the emacs SE moderators will not be too upset :-)
# Answer
> 2 votes
You can do an `ediff-buffers-wordwise` and type `#h` `\*+` to ignore words consisting of stars.
If you advance to the next diff by pressing `SPC` ediff will skip words only differing in the number of stars.
---
Tags: org-mode, diff
---
|
thread-53084
|
https://emacs.stackexchange.com/questions/53084
|
How to get line number for a given buffer position in a performant way?
|
2019-10-10T16:05:31.840
|
# Question
Title: How to get line number for a given buffer position in a performant way?
I have list of buffer positions and I want to get the numbers of the lines at those positions. Is there a better way to do that then using `with-current-buffer`, `goto-point` and `get-thing-at-point 'line`? I want the code to be as fast as possible.
# Answer
For a faster method to get line number at position -- `(with-current-buffer BUFFER (goto-char POSITION) (string-to-number (format-mode-line "%l")))` -- see the following thread, which cites some limitations / disadvantages in the comments:
A faster method to obtain \`line-number-at-pos\` in large buffers
The traditional method is to use `line-number-at-pos`, which is a compiled Lisp function in `simple.el`:
```
(line-number-at-pos &optional POS ABSOLUTE)
Return buffer line number at position POS.
If POS is nil, use current buffer location.
If ABSOLUTE is nil, the default, counting starts
at (point-min), so the value refers to the contents of the
accessible portion of the (potentially narrowed) buffer. If
ABSOLUTE is non-nil, ignore any narrowing and return the
absolute line number.
```
> 2 votes
---
Tags: point, lines
---
|
thread-53080
|
https://emacs.stackexchange.com/questions/53080
|
how to tell org mode to make subsequent lines children of the hierarchy
|
2019-10-10T14:20:12.427
|
# Question
Title: how to tell org mode to make subsequent lines children of the hierarchy
I have a list like this:
```
remember to undo:
product 0 discrimination
limit(100)
ENV['MANUAL_...']
```
When point is at the beginning of line 1, how can I tell org mode to make subsequent lines children of the hierarchy, like this
```
remember to undo:
product 0 discrimination
limit(100)
ENV['MANUAL_...']
```
I don't even mind this
```
remember to undo:
- product 0 discrimination
- limit(100)
- ENV['MANUAL_...']
```
or this
```
remember to undo:
[ ] product 0 discrimination
[ ] limit(100)
[ ] ENV['MANUAL_...']
```
or even asterisks
# Answer
1. If you only want to modify a part of your text select the relevant region otherwise put point at the beginning of the first line.
2. Replace the empty string at the line-beginning with the string consisting of one star and one space `C-M-%` `^` `RET` `*⎵` `RET` (thereby the char stands for a space).
3. Select the lines below the first one and demote the headings with `M-right`.
> 1 votes
# Answer
Here's a command that does that until it finds an empty line:
```
(defun indent-children ()
(interactive)
(save-excursion
(while (looking-at ".*[^\n[:space:]]")
(forward-line 1)
(indent-to 2))))
```
> 1 votes
---
Tags: org-mode, outline-mode
---
|
thread-52950
|
https://emacs.stackexchange.com/questions/52950
|
Preventing Helm C-k from deleting entire minibuffer
|
2019-10-03T17:34:57.877
|
# Question
Title: Preventing Helm C-k from deleting entire minibuffer
Probably a very simple answer, but when I use `helm-find-files`, I often accidentally hit C-k (`helm-delete-minibuffer-contents`) instead of C-j (`helm-execute-persistent-action`), deleting the entire minubuffer instead of navigating into a directory.
I noticed that the variable `helm-delete-minibuffer-contents-from-point` exists, which when, the documentation states,
`is non-‘nil’, delete minibuffer contents from point instead of deleting all. Giving a prefix arg reverses this behavior. When at the end of minibuffer, deletes all.`
So I've tried in my init to set
`(setq helm-delete-minibuffer-contents-from-point t)`
but still C-k produces exactly the same behaviour of deleting the entire minibuffer. What gives? Am I doing something totally stupid?
# Answer
> 0 votes
That variable does something else. In this case you want to unbind C-k:
```
(define-key helm-map (kbd "C-k") nil)
```
---
Tags: helm, helm-for-files
---
|
thread-53068
|
https://emacs.stackexchange.com/questions/53068
|
Emacs displays some characters as squares
|
2019-10-10T00:48:17.900
|
# Question
Title: Emacs displays some characters as squares
For example this:
Emacs displays it like this:
I have noticed this just after a Windows update this morning (now version is 1903). I remember it was working well a few days ago. I tried `emacs -Q` to not load any of my init files and the problem is still there.
I have another PC which is runninig Windows 1809, and on that PC it works correctly even if I run `emacs -Q`. And on that PC if I place cursor at the 1st char of my example and do `C-u C-x =` I can see the font is `uniscribe:-outline-Cambria-normal-normal-normal-serif-13-*-*-*-p-*-iso10646-1 (#x967)`, so how does emacs know to use that font? and how come emacs on my new PC doesn't do that?
I'm using emacs 26.2 on both PCs.
What could be the problem?
# Answer
The font you are using cannot display those particular characters. Try a different font.
(You likely see those boxes for some, but not for all, characters.)
Try also, and first, if you haven't already, starting Emacs using `emacs -Q` (no init file), to eliminate any possible complications coming from your init file.
> 2 votes
# Answer
I executed the following elisp code and the problem was fixed:
```
(set-fontset-font "fontset-default"
'unicode
'("Cambria Math" . "iso10646-1"))
```
But I don't understand why on my old PC emacs is able to display without any configuration at all (emacs -Q).
If someone can help me understand why on one PC above code is not need while on another PC it is needed, I'd appreciate it.
> 1 votes
# Answer
### Font Suggestion
A great programming font that has all the characters needed to show up in every tool I've run across and use including emacs is: **MesloLGS NF**. It is already patched for Windows (I ran across it being used in an advanced ZSH theme - Powerlevel10k) and might be one to try for comparison?
I've tried most of the other Nerd Fonts and always ran into issues with characters missing here and there. But not this one:
### Meslo Nerd Font
Download these four ttf files:
> 0 votes
---
Tags: microsoft-windows, fonts
---
|
thread-45726
|
https://emacs.stackexchange.com/questions/45726
|
How select and kill desire many buffers in ido mode?
|
2018-11-03T16:14:27.360
|
# Question
Title: How select and kill desire many buffers in ido mode?
Emacs 26.1. ido, smex
If I want to kill one buffer I use command `C-x k`
Here result:
As result I can kill ONE desire buffer. But suppose I need to kill the next buffers:
```
build.gradle, approfile.json, cascade.update.txt
```
How I can do this quickly?
# Answer
> 2 votes
`ido` isn't designed for that; use the buffer list instead. `C-x C-b` opens a buffer containing a list of all buffers that are open. In this buffer you can use `C-k` to mark buffers to be deleted, then `x` to delete all marked buffers. Since it's a full buffer, you can also use `C-s` to search it.
# Answer
> 0 votes
Another option which I find really handy is `M-x kill-some-buffers`. Really nice option no need for split screens or anything like that it uses the mini buffer keeping things tight, meaning that after the command is executed you won’t have to `C-x o C-x k` the remaining open buffer of ibuffer or the listed buffers `C-x C-b`
---
Tags: buffers, ido, kill-buffer
---
|
thread-53092
|
https://emacs.stackexchange.com/questions/53092
|
Want to Alt-Q on a long piece of text - but it has no spaces so it doesn't work
|
2019-10-11T03:00:55.737
|
# Question
Title: Want to Alt-Q on a long piece of text - but it has no spaces so it doesn't work
When you press Meta-Q to wrap a long blob of text, it doesn't work, probably because my text has no spaces. my text is the result of a curl, json with no spaces.
so how do I tell emacs to add newlines at around 80 chars mark?
# Answer
> 3 votes
Go to the beginning of the line, start a keyboard macro, advance 80 chars (`C-U 80 C-F`), add a return, finish the macro and then repeat it as many times as needed.
See keyboard macros.
Cheers, Peter.
---
Tags: fill-paragraph
---
|
thread-21696
|
https://emacs.stackexchange.com/questions/21696
|
How to edit multiple files at once?
|
2016-04-18T18:02:11.130
|
# Question
Title: How to edit multiple files at once?
Is there a way to open multiple buffers that are open at the same time? The idea is to be able to refactor code and variable names in multiple files at once. I know that `dired-do-find-regexp-and-replace` exists but I was hopeing for a way where I could more clearly see what was happening.
Perhaps something related to `multi-occur`. Or allowing me to have multiple files open in one buffer and then using `multiple-cursors`.
# Answer
> 5 votes
You can give multifiles a try. From its README:
> Bind a key to mf/mirror-region-in-multifile, let's say C-!. Now mark a part of the buffer and press it. A new *multifile* buffer pops up. Mark some other part of another file, and press C-! again. This is added to the *multifile*.
>
> You can now edit the *multifile* buffer, and watch the original files change. Or you can edit the original files and watch the *multifile* buffer change.
>
> Saving the *multifile* buffer will save all the original files.
# Answer
> 1 votes
The noccur package makes it easier to edit multiple (not-necessarily opened) files with multi-occur. After installing, this is an example of how to do a multi-occur edit:
1. `M-x noccur-project`, and provide a search regexp and directory to be searched.
2. In the multi-occur buffer that appears, type `e` to switch to edit mode.
3. Make any changes to the multi-occur buffer that you want (e.g. using `iedit-mode`), and when finished, press `C-c` to save all changes.
---
Tags: files, multiple-cursors, refactoring
---
|
thread-53066
|
https://emacs.stackexchange.com/questions/53066
|
Treat initial numbers as argument to functions in minor mode
|
2019-10-09T23:04:59.827
|
# Question
Title: Treat initial numbers as argument to functions in minor mode
Is it possible to treat typed numbers similar to universal argument `C-u 10 C-n`, but make it so that there is no need to type `C-u` in a minor mode? So only `10 C-n` would be needed to move 10 lines down and `C-n` to move 1 line down.
# Answer
> 0 votes
Of course. The canonical way to do that is to use `suppress-keymap` on your mode's keymap. E.g.
```
(defvar my-mode-map
(let ((map (make-keymap)))
(suppress-keymap map)
...
map))
```
In the unlikely case that you want to keep the self-inserting behavior of non-digits, then you should instead manually bind each digit to `digit-argument` as you apparently discovered in the mean time.
---
Tags: minor-mode, prefix-argument
---
|
thread-53098
|
https://emacs.stackexchange.com/questions/53098
|
How to know whether a function is implemented in C or Elisp?
|
2019-10-11T14:17:24.963
|
# Question
Title: How to know whether a function is implemented in C or Elisp?
I want to switch some behavior in my `.emacs` based on whether I have the new native fast `json-serialize` which is implemented in C rather than Elisp.
Is there a simple way to detect whether a function is implemented in C rather than Elisp? I assume there must be because `C-h f json-serialize` knows it.
# Answer
> 2 votes
I did `C-h f C-h f` and got a `*Help*` buffer describing `describe-function` as a `"Lisp function"` defined in `help-fns.el`. I clicked on the file name and searched for `"Lisp function"` which lead me to the function `help-fns-function-description-header` whose code indicated that what we want is `subrp`.
```
(subrp (symbol-function 'car))
==> nil
```
A bit more consideration would point to `help-fns--analyze-function` which disentangles things like aliasing and advising.
I think, however, that you should look at the "source" rather than the result here, i.e., check that the lisp file where `json-serialize` could be defined has been loaded - use `featurep` for that.
# Answer
> 2 votes
```
(subrp (symbol-function 'json-serialize))
```
should do it. See Functions for details.
---
Tags: functions
---
|
thread-53093
|
https://emacs.stackexchange.com/questions/53093
|
How delete folder named "build" in all subfolders?
|
2019-10-11T08:41:05.083
|
# Question
Title: How delete folder named "build" in all subfolders?
Emacs 26.1, Dired+, Windows 10
Suppose I has the next dir tree:
```
myproject
myproject\app\
myproject\app\build
myproject\app\src
myproject\lib\build
myproject\lib\src
myproject\lib2\build
myproject\lib3\build
myproject\lib3\src
```
I want to delete folders **build** in all subfolders. After delete the result must be like this.
```
myproject
myproject\app\
myproject\app\src
myproject\lib\
myproject\lib\src
myproject\lib2\
myproject\lib3\
myproject\lib3\src
```
Is it possible? And is it possible in dired mode?
# Answer
In Dired:
* You can use **`D`** (command `dired-do-delete`) to delete all marked files and subdirectories in the current Dired listing
* You can use **`M-+ D`** (command `diredp-do-delete-recursive`) to delete all marked files and subdirectories, found recursively. (This one is Dired+ only).
User option `dired-recursive-deletes` controls whether deletion of non-empty directories is allowed.
You can also use commands like these, to mark files and subdirectories:
* **`% m`** (`dired-mark-files-regexp`)
* **`M-+ % m`** (`diredp-mark-files-regexp-recursive`)
* **`% g`** (`dired-mark-files-containing`)
* **`M-+ % g`** (`diredp-mark-files-containing-regexp-recursive`)
You can also use various commands in `find-dired.el` and `find-dired+.el`, to list files that satisfy certain conditions, found recursively. (You can then mark some of them and act on the marked ones.)
> 2 votes
---
Tags: dired, files, directories
---
|
thread-53111
|
https://emacs.stackexchange.com/questions/53111
|
Can't mark specific folder in all subfolders in dired mode
|
2019-10-12T10:59:09.377
|
# Question
Title: Can't mark specific folder in all subfolders in dired mode
Emacs 26.1 Windows 10, Dired
1. Show content of folder "**myproject**". All files and subfolders.
2. `M-x dired-maybe-insert-subdir (C-u i) -R` and here result
Nice.
Now I want to mark only folder **build**
1. `%m`
2. `^build$`
But I get message:
```
0 matching files marked
```
Why?
# Answer
> 1 votes
You want to match all files whose relative file names (no directory part) match `^build$`. The answer, in the version of `dired+.el` that you have, is to use a negative prefix arg. That's the short answer, for the version you have, but please read on.
---
The Dired+ command didn't correspond to the doc string (which was correct), concerning what the regexp is matched against. I've fixed that now.
In the version before the fix, as just mentioned, you needed to use a negative prefix arg (e.g. `M--`) to match against only the relative file-name part (no directory part).
Now (after the fix) that's the default behavior, just as the doc string said - no prefix arg (to mark) or a plain prefix arg (`C-u`, to unmark) means match against the *relative* file name.
---
In any case, there's a lot of functionality (controlled by the prefix arg) that's rolled into **`% m`** (command `dired-mark-files-regexp`), so it can be confusing.
`C-h f` tells you:
> **`dired-mark-files-regexp`** is an interactive Lisp function in `dired+.el`.
>
> `(dired-mark-files-regexp REGEXP &optional MARKER-CHAR LOCALP)`
>
> Mark all file names matching `REGEXP` for use in later commands.
>
> `.` and `..` are never marked or unmarked by this command.
>
> Whether to mark or unmark, and what form of file name to match, are governed by the prefix argument. For this, a plain (`C-u`) or a double-plain (`C-u C-u`) prefix arg is considered only as such - it is not considered numerically.
>
> *Whether* to mark or unmark:
>
> * No prefix arg, a positive arg, or a negative arg means mark.
> * Plain (`C-u`), double-plain (`C-u C-u`), or zero (e.g. `M-0`) means unmark.
>
> The form of a file name used for *matching*:
>
> * No prefix arg (to mark) or a plain prefix arg (`C-u`, to unmark) means use the *relative* file name (no directory part).
> * A negative arg (e.g. `M--`, to mark) or a zero arg (e.g. `M-0`, to unmark) means use the *absolute* file name, that is, including all directory components.
> * A positive arg (e.g. `M-+`, to mark) or a double plain arg (`C-u C-u`, to unmark) means construct the name relative to `default-directory`. For an entry in an inserted subdir listing, this means prefix the relative file name (no directory part) with the subdir name relative to `default-directory`.
>
> Note that the default matching behavior of this command is different for Dired+ than it is for vanilla Emacs. Using a positive prefix arg or a double plain prefix arg (`C-u C-u`) gives you the same behavior as vanilla Emacs (marking or unmarking, respectively): matching against names that are relative to the `default-directory`.
>
> What Dired+ offers in addition is the possibility to match against names that are relative (have no directory part - no prefix arg or `C-u` to mark and unmark, respectively) or absolute (`M--` or `M-0`, respectively).
>
> The default behavior uses relative names because this is likely to be the more common use case. But matching against absolute names gives you more flexibility.
>
> `REGEXP` is an Emacs regexp, not a shell wildcard. Thus, use `\.o$` for object files -- just `.o` might mark more than you might expect.
>
> `REGEXP` is added to `regexp-search-ring`, for regexp search.
>
> Non-interactively:
>
> * `MARKER-CHAR` is the marker character - used for `dired-marker-char`.
> * `LOCALP` is passed to `dired-get-filename`. It determines the form of filename that is matched against `REGEXP`.
---
Tags: dired
---
|
thread-53089
|
https://emacs.stackexchange.com/questions/53089
|
Is there some completion plugin that can display the details of the currently selected item below the completion list?
|
2019-10-10T22:13:29.793
|
# Question
Title: Is there some completion plugin that can display the details of the currently selected item below the completion list?
When you use a dialog such as with `C-x b`, `C-x C-b` or `C-x k` the columns are usually not long enough, especially with long file names and directories.
Is it possible to have a detail view below the completion list, that will show the currently selected item below the completion list, with labels on the left and the values on the right.
A file selection dialog may look like this
So if I was on the row with `another filename` below the list I would have something like this
Is there some plugin for something like this?
Not only that when you navigate a list, shouldn't it be possible to scroll through the truncated columns to see more detail?
This problem is ruining the emacs experience for me. For instance it makes it hard to disambiguate browser windows in `exwm`.
# Answer
You can get something like this with ivy, but you might have to write some code to get exactly what you want. Here, I get the files in the current directory, and construct a list of candidates that looks like "filename | directory". If you want them on separate lines, replace | with \n. Then you use ivy-read to get completion. If you want a buffer where you can see the candidates, you type C-o U in the ivy-read minibuffer to open the candidates in an Occur buffer. The action function will be run on the entry you select.
```
(require 'f)
(require 'ivy)
(let* ((entries (f-entries "."))
(directories (mapcar 'file-name-directory entries))
(files (mapcar 'file-name-nondirectory entries))
(candidates (mapcar* (lambda (f d e)
(cons (format "%s | %s" f d) e))
files directories entries)))
(ivy-read "f: " candidates
:action (lambda (candidate)
(message "you picked %s" (cdr candidate)))))
```
You can also do something like this with helm.
> 1 votes
---
Tags: completion
---
|
thread-53118
|
https://emacs.stackexchange.com/questions/53118
|
Match any character in a regexp (e.g. `string-match`)
|
2019-10-12T19:33:41.037
|
# Question
Title: Match any character in a regexp (e.g. `string-match`)
In perl when matching multi-line strings you can add the `s` modifier `/.../s` that will change the semantics of `.` to match also newline. Is there something similar for `string-match`? Or is there a workaround?
# Answer
> 1 votes
No, you can't make `.` match newlines; you have to simply state what you want to match. e.g.: `"\\(?:.\\|\n\\)"`
However if you use `rx` to generate your regexp, then note that it provides distinct symbols for the two cases:
```
`not-newline', `nonl'
matches any character except a newline.
`anything'
matches any character
```
e.g.:
```
(rx "foo" anything "bar")
=> "foo\\(?:.\\|
\\)bar"
```
---
Tags: regular-expressions
---
|
thread-16637
|
https://emacs.stackexchange.com/questions/16637
|
How to set up elpy to use python3?
|
2015-09-15T17:47:39.503
|
# Question
Title: How to set up elpy to use python3?
When setting up my emacs for a new work environment, I am unable to get the elpy configuration to correctly use python 3. I have installed all of the required packages in `/usr/local/bin` and have installed them using python3.
Right now, when I run elpy-config I am getting the following:
```
Virtualenv........: None
RPC Python........: 2.7.6 (/usr/bin/python)
Interactive Python: python (/usr/bin/python)
Emacs.............: 24.5.1
Elpy..............: 1.9.0
Jedi..............: 0.9.0
Rope..............: Not found (0.10.2 available)
Importmagic.......: 0.1.3
Autopep8..........: 0.1.3
Syntax checker....: Not found (pyflakes)
```
I would like to have RPC Python be ipython3 and the same for the interactive. For the purposes of this question, assume my .emacs file is blank.
# Answer
You can conffigure `elpy-rpc-python-command`. If you want Python3 you can set it like this.
```
(setq elpy-rpc-python-command "python3")
```
**Update**
Create python3 virtualenv using virtualenvwrapper from terminal
```
$ mkvirtualenv test -p /usr/bin/python3
```
and then install required packages
```
$ pip install rope jedi importmagic autopep8 flake8
```
Now go to emacs, activate virtualenv and run `M-x elpy-config`
```
M-x pyvenv-workon test
M-x elpy-config
```
If you want to have `ipython` as your REPL, you can put this function in you config
```
(elpy-use-ipython)
```
or
```
(elpy-use-ipython "python3")
```
Note: `elpy-use-ipython` is deprecated. Use
```
(setenv "IPY_TEST_SIMPLE_PROMPT" "1")
(setq python-shell-interpreter "ipython3"
python-shell-interpreter-args "-i")
```
or `ipython` based on your version.
> 28 votes
# Answer
You can solve this by modifying the python shell configuration from python to python3 in elpy-config
1. `M-x elpy-config` to enter the configuration page of elpy
2. if you scroll down you will see groups with \[+\] signs, toggle the Python one and find the shell interpreter option: `Option Python Shell Interpreter` is the one you are looking for.
3. If you click (or Enter in terminal version) on the Option button you will be able to edit the part "python" to "python3"
4. Apply and save, and restart emacs
> 8 votes
# Answer
Set the interpreter variable in your `.emacs` file:
```
(setq python-shell-interpreter "python3"
python-shell-interpreter-args "-i")
```
Taken from elpy manual
> 2 votes
---
Tags: python, osx, ipython, elpy
---
|
thread-2426
|
https://emacs.stackexchange.com/questions/2426
|
How do I auto-refresh eww pages?
|
2014-10-22T06:07:05.600
|
# Question
Title: How do I auto-refresh eww pages?
If I load a local file, I'd like eww to refresh when the source is changed. This would be similar to auto-revert mode. Is there any way to do this? Right now I have to manually refresh by hitting `g` in the `*eww*` buffer.
# Answer
# Solution
* Start a `file-notify` watch when opening a file in `eww`.
* In the callback function for that watch, do 2 things:
+ Reload the \*eww\* buffer every time the function is triggered by `file-notify` event.
+ Log the event descriptors specific to file opening actions in `eww`. This is because you need to know which `file-notify` watches to remove when you quit `eww` (especially if you use the watches for other purposes than this too).
* On quitting `eww` remove all the watches related to `eww`. You have to make sure that you call this specific function to quit `eww` and clean up the now-not-required watches.
# How to use
* Copy the below implementation to your `init.el`.
* Launch any file you want to load in `eww` using `C-u M-x eww-open-file`.
* Make sure you quit `eww` by calling `modi/eww-quit-and-update-fn-descriptors`. For convenience, the default binding `q` in `eww-mode-map` is now bound to this function. If you use any other binding to quit `eww` or to kill windows, make sure you call this function. `modi/eww-quit-and-update-fn-descriptors` ensures that the eww-specific file-notify watches are removed.
# Implementation
```
(defvar modi/eww--file-notify-descriptors-list ()
"List to store file-notify descriptor for all files that have an
associated auto-reloading eww buffer.")
(defun modi/advice-eww-open-file-to-auto-reload (orig-fun &rest args)
"When `eww-open-file' is called with \\[universal-argument], open
the file in eww and also add `file-notify' watch for it so that the eww
buffer auto-reloads when the HTML file changes."
(prog1
(apply orig-fun args)
(when current-prefix-arg ; C-u M-x eww-open-file
(require 'filenotify)
(let ((file-name (car args)))
(file-notify-add-watch file-name
'(change attribute-change)
#'modi/file-notify-callback-eww-reload)
;; Show the HTML file and its rendered form in eww side-by-side
(find-file-other-window file-name))
;; Redefine the `q' binding in `eww-mode-map'
(bind-key "q" #'modi/eww-quit-and-update-fn-descriptors eww-mode-map))))
(advice-add 'eww-open-file :around #'modi/advice-eww-open-file-to-auto-reload)
(defun modi/file-notify-callback-eww-reload (event)
"On getting triggered, switch to the eww buffer, reload and switch
back to the working buffer. Also save the `file-notify-descriptor' of the
triggering event."
(let* ((working-buffer (buffer-name)))
(switch-to-buffer-other-window "eww")
(eww-reload)
(switch-to-buffer-other-window working-buffer))
;; `(car event)' will return the event descriptor
(add-to-list 'modi/eww--file-notify-descriptors-list (car event)))
(defun modi/eww-quit-and-update-fn-descriptors ()
"When quitting `eww', first remove any saved file-notify descriptors
specific to eww, while also updating `modi/eww--file-notify-descriptors-list'."
(interactive)
(dotimes (index (safe-length modi/eww--file-notify-descriptors-list))
(file-notify-rm-watch (pop modi/eww--file-notify-descriptors-list)))
(quit-window :kill))
```
# Assumptions
* You have only one \*eww\* buffer open.
* This solution requires emacs 24.4 or newer.
> 4 votes
# Answer
I fixed the same issue with a noob solution so here it is:
I basically added a hook that calls `eww-reload` on the "other frame" -that supposedly has the web page open- once the markdown gets saved.
This works fine for me as I usually have my window split into two frames only when I'm writing in markdown, one for md and the other for preview -using either doc-view or eww-
So here is the snippet I added to my init.el, please read carefully and edit according to your situation:
```
(defun compile-md ()
"Run available makefile that should compile markdown to whatever."
(interactive)
(when (derived-mode-p 'markdown-mode)
(shell-command "make")); that make file uses pandoc to compile md to html
(windmove-right); supposing the eww frame is on the right
(when (derived-mode-p 'eww-mode)
(eww-reload))
(windmove-left); get back to the md buffer
)
(add-hook 'after-save-hook #'compile-md)
```
> 2 votes
---
Tags: eww
---
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.