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-51953
|
https://emacs.stackexchange.com/questions/51953
|
UTF-8 error everytime Org-gcal sync entries
|
2019-08-01T12:48:31.920
|
# Question
Title: UTF-8 error everytime Org-gcal sync entries
I continue to get bogged down with this error every time I sync from gcal, I have this ut8 flag set in my config as well, any direction would be helpful.
```
(prefer-coding-system 'utf-8-unix)
```
# Answer
> 1 votes
After upgrading **request** package to the latest version this is working for me. See this https://github.com/kidd/org-gcal.el/issues/41
---
Tags: org-mode, utf-8
---
|
thread-52483
|
https://emacs.stackexchange.com/questions/52483
|
Search within column or rectangle
|
2019-09-03T19:24:43.110
|
# Question
Title: Search within column or rectangle
Is there a simple way to search within the current column or within a rectangle?
I am navigating a CSV file and would like to find the value "10" in a particular column. Searching the entire file is unproductive. However, it is easy to select the column with a rectangle.
I don't see any commands to search within a rectangle or to narrow to a rectangle. The best I've been able to come up with is to copy the column and paste it into a scratch buffer and then search.
Any ideas?
# Answer
You can do this with library Isearch+. As far as I know, this is the only library that offers this possibility.
1. Set or bind option **`isearchp-restrict-to-region-flag`** to non-`nil`. This means that when the region is active and you start isearching the search will be limited to the region.
2. Select the text between the upper-left and lower-right corners of the column you want to search as the active region.
You might want to use `C-x C-x` (to `exchange-point-and-mark`), depending on which end the cursor is at and which direction you want to search.
3. Make the region rectangular using **`C-x SPC`** (command `rectangle-mark-mode`.
4. Start isearching (regexp or literal-string search).
If option **`isearchp-deactivate-region-flag`** is non-`nil` then the region is automatically deactivated when you start searching, so you can better see the search space.
(You can use **`C-x n`** (command `isearchp-toggle-region-restriction`) and **`C-SPC C-SPC`** (command `isearchp-toggle-region-deactivation`) during search to toggle `isearchp-restrict-to-region-flag` and `isearchp-deactivate-region-flag`, respectively, but in each case the new value takes effect only when the current search is exited.)
---
If you use also library Mode-Line Position then not only can you restrict Isearch to the active region but you can keep that restriction when you invoke a query-replacement command from Isearch (e.g. `M-%` from Isearch, to use `query-replace`).
The main job of that library is to show information about the active region in the mode line. And whenever you invoke a replacement command or Isearch for the active region, that region information is highlighted specially.
> 2 votes
---
Tags: search, region, isearch, rectangle, column
---
|
thread-52489
|
https://emacs.stackexchange.com/questions/52489
|
Map each element of a list over every element of another list
|
2019-09-04T06:30:36.587
|
# Question
Title: Map each element of a list over every element of another list
Let's assume I've got two lists: `("A" "B" "C" "D")` and `("+" "-")`. I want to concatenate each element of the first list with every element of the second to get `("A+" "A-" "B+" "B-" ... )`. Is there a proper function to do that, e.g. `(map-each 'concat list1 list2) => list3`?
I came to a solution using nested `mapcar` calls and `reduce` but I think I may be missing something since it doesn't seem to be very uncommon task.
```
(reduce 'append
(mapcar
(lambda (x)
(mapcar
(lambda (y)
(concat x y))
'("+" "-")))
'("A" "B" "C" "D")))
```
# Answer
I am not aware of any Elisp built-in function that calls a function on the cartesian product of its list arguments and returns the collected result.
But I like the general `map-cartestian-product` from an answer at stackoverflow quite much.
Since that is a nice general method I've generalized it a bit more to an arbitrary number of sets:
```
(defmacro map-cartesian-product-recursion (fun vars lists)
"Apply (FUN x1 ... xn) for all tuples with xi element of (nth i LISTS)."
(if (car lists)
(let ((x (make-symbol "x")))
`(mapc
(lambda (,x)
,(macroexpand `(map-cartesian-product-recursion ,fun ,(cons x vars) ,(cdr lists))))
,(car lists)))
`(funcall ,fun ,@(nreverse vars))))
(defmacro map-cartesian-product (fun &rest lists)
"Apply (FUN x1 ... xn) for all tuples with xi element of (nth i LISTS)."
`(map-cartesian-product-recursion ,fun nil ,lists))
```
You can use `map-cartesian-product` for your purpose as follows:
```
(let (ret)
(map-cartesian-product
(lambda (letter sign)
(setq ret (cons (concat letter sign) ret)))
'("A" "B" "C" "D")
'("+" "-"))
(nreverse ret))
```
The advantage with respect to your proposal is that you do not construct intermediate lists but only one return list.
> 2 votes
---
Tags: list, mapping
---
|
thread-52496
|
https://emacs.stackexchange.com/questions/52496
|
Append to a list inside an alist for custom find-file behaviour
|
2019-09-04T12:41:05.143
|
# Question
Title: Append to a list inside an alist for custom find-file behaviour
`cc-other-file-alist` is part of `find-file` that looks something like this.
```
(("\\.cc\\'"
(".hh" ".h"))
("\\.hpp\\'"
(".cpp"))
;; more such entries
)
```
This is an alist where I'd like to append an additional entry to the `cdr` of `"\\.hpp\\'"`. I've done it but I feel it's too round about.
```
(with-eval-after-load 'find-file
(setq my-cc-other-file-alist (copy-alist cc-other-file-alist))
;; create a new cons (key-value) pair in the alist
(add-to-list 'my-cc-other-file-alist '("\\.mm\\'" (".h")))
;; Add: .h -> .mm, .hpp -> .inl
;; append to existing value (list) for a given key
(setcdr (assoc "\\.h\\'" my-cc-other-file-alist)
(list (append (car (cdr (assoc "\\.h\\'"
my-cc-other-file-alist)))
'(".mm"))))
(setcdr (assoc "\\.hpp\\'" my-cc-other-file-alist)
(list (append (car (cdr (assoc "\\.hpp\\'"
my-cc-other-file-alist)))
'(".inl"))))
(setq-default ff-other-file-alist 'my-cc-other-file-alist))
```
I'm sure there would be an elegant way to reference the inner list (`cdr`) and simply append to it, instead of making copying and replacing. Please tell me there's a better way and show me how!
# Answer
> 1 votes
You could use `nconc`; it appends a structure to the end of a list by `setcdr`ing the last cons in the list.
Or you could just prepend a new entry onto the alist, so that it looks like this:
```
(("\\.hpp\\'"
(".inl" ".cpp"))
("\\.cc\\'"
(".hh" ".h"))
("\\.hpp\\'"
(".cpp"))
;; more such entries
)
```
This works because everything that reads an alist stops at the first matching entry.
```
(let ((new-list (cons "\\.inl"
(cdr (assoc "\\.hpp\\'"
my-cc-other-file-alist)))))
(cons (cons "\\.hpp\\'" new-list)
cc-other-file-alist))
```
In general it's better to avoid `setcdr`, `nconc`, and other functions which modify lists in place, because the list you're modifying might have been shared between multiple data structures. I'm sure it would be fine in this case, though.
---
Tags: find-file, alists
---
|
thread-52488
|
https://emacs.stackexchange.com/questions/52488
|
Propertize org-agenda-overriding-header
|
2019-09-04T04:28:01.083
|
# Question
Title: Propertize org-agenda-overriding-header
Wondering how would one go about applying a face to the agenda header. I tried it with the below code, but it does not apply the face. It does not generate errors, but it won't apply a face. I am quite new to spacemacs and org-mode.
To be precise, this is within a configuration for custom agenda. The relevant line looks like this:
```
(org-agenda-overriding-header (propertize "Purchases" 'face '(:foreground "yellow")))
```
I have spent a lot of time searching for an answer online and tried a lot of different things to no avail. As a last resort I am asking for help here.
Thanks a bunch!
# Answer
> 1 votes
The `face` property is overwritten by org after inserting the header. It's using the face `org-agenda-structure`. There are seven places in "org-agenda.el" that put this face property. Changing this behavior would probably get complicated.
There are two workarounds that work:
## 1. Change the Face
Not sure if `org-agenda-structure` only affects the header, but if it does you could change the face:
* with `(set-face-attribute 'org-agenda-structure nil :foreground "red")`
* or in the theme you are using.
## 2. Put the text property afterwards with an advice
Add an advice around the functions called by `org-agenda`, get the point before calling the original function, call the original function and then replace the header with the propertized one. With the advice the lexical bound value of `org-agenda-overriding-header` is available.
```
(defun my-org-agenda-override-header (orig-fun &rest args)
"Change the face of the overriden header string if needed.
The propertized header text is taken from `org-agenda-overriding-header'.
The face is only changed if the overriding header is propertized with a face."
(let ((pt (point))
(header org-agenda-overriding-header))
(apply orig-fun args)
;; Only replace if there is an overriding header and not an empty string.
;; And only if the header text has a face property.
(when (and header (> (length header) 0)
(get-text-property 0 'face header))
(save-excursion
(goto-char pt)
;; Search for the header text.
(search-forward header)
(unwind-protect
(progn
(read-only-mode -1)
;; Replace it with the propertized text.
(replace-match header))
(read-only-mode 1))))))
(defun my-org-agenda-override-header-add-advices ()
"Add advices to make changing work in all agenda commands."
(interactive)
(dolist (fun '(org-agenda-list org-todo-list org-search-view org-tags-view))
(advice-add fun :around #'my-org-agenda-override-header)))
```
Then run the function to add the advices:
```
(my-org-agenda-override-header-add-advices)
```
### Test
```
(let ((org-agenda-custom-commands
'(("b" "Test"
((agenda ""
((org-agenda-span 1)
(org-agenda-overriding-header
(propertize "Red\ntext with new line" 'face '(:foreground "red")))))
(todo "JUSTFOR"
((org-agenda-overriding-header "Not propertized, uses standard face")))
(todo "SCREENSHOT"
((org-agenda-overriding-header
(propertize "Green background" 'face '(:background "green" :foreground "black"))))))))))
(org-agenda nil "b"))
```
Result: *(had to eval twice to make it not complain about missing key)*
### Note
It would be simpler to just add an :after advice to `org-agenda--insert-overriding-header` but was not able to because:
> When you advise a macro, keep in mind that macros are expanded when a program is compiled, not when a compiled program is run. All subroutines used by the advice need to be available when the byte compiler expands the macro.
If anyone knows how to do this, please add a comment or a new answer.
---
Tags: org-mode
---
|
thread-52491
|
https://emacs.stackexchange.com/questions/52491
|
Why can't Emacs find gfortran on my Mac?
|
2019-09-04T10:07:42.457
|
# Question
Title: Why can't Emacs find gfortran on my Mac?
I have tried to compile a simple helloworld.f95 on my Mac, using emacs. The root of emacs was set in the directory containing helloworld.f95. I used the following commands
```
M-x compile
gfortran -o helloworld helloworld.f95
```
I got the following error:
```
-*- mode: compilation; default-directory: "~/Desktop/fortran/" -*-
Compilation started at Wed Sep 4 17:37:51
gfortran -o helloworld helloworld.f95
/bin/bash: gfortran: command not found
Compilation exited abnormally with code 127 at Wed Sep 4 17:37:51
```
I have previously been able to compile with the same command on the terminal. Fortran was installed on my mac by following the instructions on this link: http://www.lapk.org/gfortran/gfortran.php?OS=7
The location in which gfortran is installed is at:
```
Desktop$ which gfortran
/usr/local/bin/gfortran
```
**How do I compile .f95 files from emacs, as well as run them?**
# Answer
As mentioned by @JeanPierre , the problem was because the location of gfortran was not added to the PATH environment variable for the emacs shell. Thus the shell did not know where to look to find the command. To do so (and to make the PATH environment readily available for editing) I added this code block into my initialisation file: ~/.emacs.d/init.el
```
;; defining "PATH"
(setenv "PATH" (mapconcat identity
'("/usr/local/bin"
"/usr/bin"
"/bin")
":"))
```
> 1 votes
---
Tags: osx, path, compile-mode
---
|
thread-52485
|
https://emacs.stackexchange.com/questions/52485
|
How to generate directory structure out of org-mode outline?
|
2019-09-03T21:00:16.197
|
# Question
Title: How to generate directory structure out of org-mode outline?
I want to create the directory tree structure like this out of org-mode outlines.
> Dir1
>
> > * Dir-1.1
> > + Dir -1.1.1
> > * Dir-1.2
> >
> > Dir 2
> >
> > * Dir-2.1
> > * Dir-2.2
I am new to emacs and I have tried a few shell commands from here like
```
xargs -d '\n' mkdir -p -- < test.txt
```
For that to work I need a file with the following structure.
```
# Test.txt
A1/A2/A3
B1/B2/B3
C1/C2/C3
```
TLDR: Generate Directory structure out of org outlines.
# Answer
`org-element-parse-buffer` and `org-element-map` are your friends. You get the doc strings of these two functions (and of every other function) by `C-h f`.
The following function `org-headlines-to-dir-tree` parses the org buffer via `org-element-parse-buffer` and creates the directories corresponding to the headlines via `org-element-map`. This is pure Elisp. No shell commands are required.
```
(defun org-headlines-to-dir-tree (dir &optional data)
"Transform org headlines in DATA to directory tree below DIR.
DATA defaults to the headline structure of the current org buffer."
(interactive "DTarget directory:")
(unless data
(unless (derived-mode-p 'org-mode)
(user-error "%S is not an org buffer" (current-buffer)))
(setq data (org-element-parse-buffer 'headline)))
(unless (file-directory-p dir)
(user-error "%S is not a directory" dir))
(let ((default-directory (expand-file-name dir)))
(org-element-map
data
'headline
(lambda (el)
(let ((title (org-element-property :title el))
(contents (org-element-contents el)))
(when (y-or-n-p (format "Create directory %S?" (expand-file-name title)))
(mkdir title)
(when contents
(org-headlines-to-dir-tree title contents))))) ;; Recursion.
nil ;; info
nil ;; first match
'headline ;; no-recursion (We do the recursion ourselves with additional directory changes.)
)))
```
You can paste that stuff into your `*scratch*` buffer and evaluate it by placing point in to the function body and typing `C-M-x`.
> 2 votes
---
Tags: org-mode
---
|
thread-52503
|
https://emacs.stackexchange.com/questions/52503
|
Understanding why lsp-scala is not giving completions
|
2019-09-04T15:38:52.910
|
# Question
Title: Understanding why lsp-scala is not giving completions
I have installed `lsp-mode`, `lip-scala`, `lsp-ui`, `company-lsp` and many other packages. When entering scala code, I often get popups to complete the method/class/variable name, which also add the relevant imports if needed.
However, this does not always happen. I am new to `lip-mode`, so I am not sure how to debug what is going wrong. What are useful commands/settings to figure out what is going wrong when it is not working?
I have configured it with
```
;; lsp configuration
(use-package lsp-scala
:after scala-mode
:demand t
;; Optional - enable lsp-scala automatically in scala files
:hook (scala-mode . lsp))
```
There are lots of messages in \*lsp-log\* but none of them indicate any obvious to me.
# Answer
lsp-scala is deprecated and you should now use lsp-mode which has scala support via metals. From the lsp-scala repo:
> lsp-scala is now part of lsp-mode as lsp-metals. Please do not use this package.
I would suggest referring to the metals documentation which can help you with installation: https://scalameta.org/metals/docs/editors/emacs.html (make sure you uninstal lsp-scala first).
# Useful command for debugging
What I usually do when something is not working is setting `(debug-on-error t)`, this will throw you into a debugger when there is an error and will enable you to start investigating where something went wrong.
> 3 votes
---
Tags: lsp-mode
---
|
thread-52506
|
https://emacs.stackexchange.com/questions/52506
|
magit: how do I turn off the -S (--gpg-sign) argument when committing?
|
2019-09-04T17:18:18.777
|
# Question
Title: magit: how do I turn off the -S (--gpg-sign) argument when committing?
I forgot my GPG key at home and want to check in the code until I am home and can amend/resign the commits. Unfortunately I can't seem to figure out how to disable the `--gpg-sign=` argument in the `magit` commit popup, which is preventing me from committing.
I took a look in the manual and it says you can toggle these on and off, but doesn't specify how one toggles them.
Cheers!
**Edit:** In my magit popup the option appears as `-S` not `=S`. In the past I know that I could do just `=S` to disable it. I can't figure out how to do it with it now being prefixed with `-`.
# Answer
That was a bug and I have fixed it.
~~I suggest you delete your question because it is no longer relevant.~~ Then again not everyone updates when encountering an issue.
> 2 votes
---
Tags: magit
---
|
thread-52443
|
https://emacs.stackexchange.com/questions/52443
|
AucTeX not loading beamer class
|
2019-08-31T20:20:06.500
|
# Question
Title: AucTeX not loading beamer class
When trying to use the LaTeX document class `beamer` with AucTeX it does not load the template. Emacs reports `Symbol’s value as variable is void: LaTeX-hyperref-package-options-list` after loading `beamer.elc`. How can this be fixed?
If I type `\documentclass{beamer}` by hand and press `C-c C-n`, then AucTeX loads `beamer` (works for the whole Emacs session).
# Answer
The issue you describe was a bug in AUCTeX which was fixed with this change. This change loads `hyperref.el` when you request the `beamer` class and are asked for class options, making `LaTeX-hyperref-package-options-list` available before the style hook runs.
> 1 votes
---
Tags: latex, auctex, beamer
---
|
thread-52492
|
https://emacs.stackexchange.com/questions/52492
|
Change TODO keywords of all nodes in an Orgmode subtree in Elisp
|
2019-09-04T11:28:39.690
|
# Question
Title: Change TODO keywords of all nodes in an Orgmode subtree in Elisp
Imagine we have a tree like this:
```
* TODO Read X book
** TODO Chapter 1
** TODO Chapter 2
```
I'd like to mark all nodes in the tree as `DONE`:
```
* DONE Read X book
** DONE Chapter 1
** DONE Chapter 2
```
What's the best way to do it in Elisp?
# Answer
Org has a built-in function to map over entries: `org-map-entries`
> (org-map-entries FUNC &optional MATCH SCOPE &rest SKIP)
>
> Call FUNC at each headline selected by MATCH in SCOPE.
>
> FUNC is a function or a lisp form. The function will be called without arguments, with the cursor positioned at the beginning of the headline. The return values of all calls to the function will be collected and returned as a list.
For example `(org-map-entries (lambda () (org-todo 'done)) nil 'tree)` when called with point at the start of a headline will mark that headline and all of its children done (whatever the done state for the current keyword is).
> 1 votes
# Answer
I wrote this quick function to do it. Point needs to be on a heading or you'll get an error. I got help writing this from reading this article by Xah Lee.
```
(defun my/replace-todos-with-done ()
(interactive)
(save-match-data
(unless (org-at-heading-p) (error "not at heading!"))
(let ((regexp (rx bol (1+ "*") (1+ "\s") (submatch "TODO")))
(bound (save-excursion (org-end-of-subtree) (point)))
(case-fold-search nil))
(while (search-forward-regexp regexp bound :no-error nil)
(replace-match "DONE" t nil nil 1)))))
```
> 1 votes
# Answer
At first I came up with this solution:
```
(defun my/org-walk-tree (fn &rest args)
(save-excursion
(save-restriction
(org-narrow-to-subtree)
(org-save-outline-visibility 'use-markers
(apply fn args)
(while (outline-next-heading)
(apply fn args))))))
(my/org-walk-tree 'org-todo 'done)
```
It works in simple cases, but I haven't tested it thoroughly.
Then I started reading `org-todo` function source code (should've done it earlier) and noticed that right at the start it uses `org-loop-over-headlines-in-active-region` variable:
> Shall some commands act upon headlines in the active region?
>
> When set to t, some commands will be performed in all headlines within the active region.
When it's set to `t`, `org-todo` uses `org-map-entries` to process all nodes in the subtree.
So all we need to do is:
```
(defun my/org-todo-subtree (keyword)
(let ((org-loop-over-headlines-in-active-region t))
(save-mark-and-excursion
(org-mark-subtree)
(org-todo keyword))))
(my/org-todo-subtree "DONE")
```
I'm not sure if we need to use `save-mark-and-excursion` rather than `save-excursion`. It'd also be great to make it interactive.
With that variable name I found a similar question on Superuser: Editing multiple TODO simultaneously — priority and/or deadine. But I can't set my question as a duplicate of that one, as it's on the other site.
> 1 votes
---
Tags: org-mode
---
|
thread-41946
|
https://emacs.stackexchange.com/questions/41946
|
Multiple buffers for same file
|
2018-06-11T06:29:33.500
|
# Question
Title: Multiple buffers for same file
The `find-file` command automatically selects and uses a preexisting buffer that is visiting the same file.
My problem is, when using the same buffer in multiple frames, the frames will lag significantly (slow response, delayed input, etc.). This problem also occurs when using indirect buffers.
Is there a way to tell Emacs to open a file in a new buffer instead of reusing a preexisting buffer?
# Answer
> 1 votes
Emacs tries to prevent multiple buffers visiting a given file because that's not generally desirable (e.g. you can then have conflicting changes in each of the buffers); but it's certainly possible. In essence you just need the buffer-local `buffer-file-name` variable to be set.
Here's a very basic command:
```
(defun find-file-new-buffer (filename)
"Very basic `find-file' which does not use a pre-existing buffer."
(interactive "fFind file in new buffer: ")
(let ((buf (create-file-buffer filename)))
(with-current-buffer buf
(insert-file-contents filename t))
(pop-to-buffer-same-window buf)))
```
# Answer
> 0 votes
When running Emacs as daemon, the different frames that might be open have access to the buffers on memory. a file will not be open twice to prevent conflicts (any changes should be consistent.
Try running `M-x ibuffer` usually `C-x b` and choose a buffer to open in window rather than `C-x C-f`
---
Tags: buffers, frames, files
---
|
thread-52479
|
https://emacs.stackexchange.com/questions/52479
|
How do you create an org-ref harvard style in-text citation - with a page number - using shortcuts?
|
2019-09-03T14:21:43.570
|
# Question
Title: How do you create an org-ref harvard style in-text citation - with a page number - using shortcuts?
There are only really two kinds of citations I need to have in my paper
1. `(Lewis, 2001)`
2. `(Lewis, 2001:54)` where 54 is the page number
After a ton of googling I managed to find out that it's possible to create both these kinds of citations with `org-ref` in `org-mode` \[1\] \[2\]
For a minimal example:
```
#+LATEX_HEADER: \usepackage[round]{natbib}
#+LATEX_HEADER: \setcitestyle{notesep={:}}
* Test
1. This is an author year citation citep:lewis_plurality_2001
2. This has a page number [[cite:lewis_plurality_2001][100]]
bibliographystyle:apalike
bibliography:bibliography.bib
```
Will create:
> 1. This is an author year citation (Lewis, 2001)
> 2. This has a page number (Lewis, 2001:100)
But as noted in *How to cite author-date including page number in org-mode?* \- to achieve the citation with page number you have to type `[[cite:lewis_plurality_2001][100]]`
The problem is that it will be virtually impossible to write a paper where you have to stop and square bracket every reference in that way. So I'm wondering if there isn't an easier way to do this with `org-ref` that I'm missing ?
# Answer
If you know the bibtex key you want to cite then you can use `org-insert-link` to do this. Usually that is bound to C-c C-l, you will be prompted for what kind of link, you can choose cite (the capitalization is a little annoying and you might have to figure out how to not get Cite with this. I use ivy, and I have to toggle the case sensitivity, and search for ^cite: to get what I want.), then use completion to select the bibtex key, then you will be prompted for the description.
If you want the completion on the title/author etc, you need to make a new function like this
```
(defun harvard-cite (key page)
(interactive (list (completing-read "Cite: " (orhc-bibtex-candidates))
(read-string "Page: ")))
(insert
(org-make-link-string (format "cite:%s"
(cdr (assoc
"=key="
(cdr (assoc key (orhc-bibtex-candidates))))))
page)))
```
Then, you can bind it to a convenient key and get on with your writing.
> 1 votes
# Answer
Just wanted to mention another possible way of doing this, building on what Professor Kitchin said. I am also a complete lisp noob so this may violate lisp intergalactic laws I am not aware of, be that as it may - the function does seem to work for me.
The `harvard-cite` function works near perfectly fine just by itself. The only other thing I had to do to get it running was add `(setq org-ref-bibtex-files '("bibliography.bib"))` to my `~/.emacs` otherwise my `orhc-bibtex-candidates` would be empty.
As it is the function will use only a single citation type with a page number, but if you also listen for an ivy prefix arg, then you can do a `M-X harvard-cite` and when hovering over an entry hit `C-u` to choose a different citation type. But if you just hit `RET` your default citation link will be used.
After reading https://kitchingroup.cheme.cmu.edu/blog/2016/06/14/Using-prefix-args-in-ivy-actions/ I somehow managed to modify the function to do just that. And with the code below you can select an alternate citation with `C-u RET`.
```
(setq org-ref-bibtex-files '("bibliography.bib")) ;; replace with your default bib file
(defun harvard-cite (entry page)
(interactive (list (completing-read "Cite: "
(orhc-bibtex-candidates))
(read-string "Page: ")))
(setq key (cdr (assoc "=key=" (cdr (assoc entry (orhc-bibtex-candidates))))))
(setq type (if ivy-current-prefix-arg
(ivy-read "type: " org-ref-cite-types)
org-ref-default-citation-link))
(insert (org-make-link-string (format "%s:%s" type key) page)))
```
> 0 votes
---
Tags: org-mode, org-ref
---
|
thread-52516
|
https://emacs.stackexchange.com/questions/52516
|
How does emacs flash its icon on the windows taskbar?
|
2019-09-05T08:02:19.043
|
# Question
Title: How does emacs flash its icon on the windows taskbar?
Sometimes when I run a process if there is an error during the process the emacs icon on the windows taskbar lights up, so if I'm in an other app I can see something happened there.
I'd like to use this indication in my elisp programs too. Is there a lisp call which makes the emacs icon light up on the taskbar?
# Answer
Try using function `ding` with variable `visible-bell` bound to non-`nil`. For example:
```
(let ((visible-bell t)) (ding t))
```
If you need to impose a delay before flashing then you can use `sit-for` or `sleep-for`. For example:
```
(let ((visible-bell t))
(sleep-for 2) ; Wait 2 seconds
(ding t)) ; Flash screen
```
> 0 votes
---
Tags: microsoft-windows, error-handling, notifications
---
|
thread-52522
|
https://emacs.stackexchange.com/questions/52522
|
Not work "subscr": Symbol’s function definition is void:
|
2019-09-05T15:33:10.653
|
# Question
Title: Not work "subscr": Symbol’s function definition is void:
Emacs 26.1, I try to use function `subscr`
Example:
```
subscr({a,b,c,d,e,f,h},{1,2,3})
```
But I get error:
```
eval: Symbol’s function definition is void: {a
```
# Answer
> 1 votes
What language are you trying to use, and where/how are you trying to use it?
If you are trying to evaluate `subscr({a,b,c,d,e,f,h},{1,2,3})` as Lisp (which it seems you are) then there are a few things wrong.
* First, `subscr` is evaluated as a variable, not a function. If it's not bound as a Lisp variable then you should get an error saying that.
* Second, the list `({a,b,c,d,e,f,h},{1,2,3})` is evaluated as an application of function `{a` to a list of arguments. You should get an error saying that `{a` is not a defined function (which is the error you saw).
* Third, the rest of that function application - the list of arguments - is illegal Lisp, starting with the use of commas.
In short, this is not Lisp. It's not clear what you're trying to do or in what context you tried to use this text, but it seems that you tried to evaluate at least some of it as Lisp.
A guess is that you wanted to apply a Lisp function called `subscr` (not a predefined function - where is it defined?) to a *string*. That would be done like this in Lisp:
```
(subscr "{a,b,c,d,e,f,h},{1,2,3}")
```
Or perhaps you wanted to apply `subscr` to a list of two strings:
```
(subscr '("{a,b,c,d,e,f,h}" "{1,2,3}"))
```
In any case, again, function `subscr` needs to be defined.
---
Tags: org-mode, text
---
|
thread-52521
|
https://emacs.stackexchange.com/questions/52521
|
How to execute one line in the .emacs file?
|
2019-09-05T15:01:43.087
|
# Question
Title: How to execute one line in the .emacs file?
To test a function definition, for example :
```
(defun count-words-buffer ()
(let ((count 0))
(goto-char (point-min))
(while (< (point) (point-max))
(forward-word 1)
(setq count (1+ count)))
(message "buffer contains %d words." count)))
```
The goal would be to test a function while writing, without restarting Emacs.
# Answer
> 3 votes
If you've just typed or modified the function and you want to (re)define it, press `C-M-x` (`eval-defun`) with the cursor anywhere in the definition.
To run the function, use `M-:` (`eval-expression`) and type `(count-words-buffer)` then `RET`. If the function needed arguments, you'd need to add them after the function name, e.g. `(my-function "first argument" 'second-argument)`.
Alternatively, go to the `*scratch*` buffer and type your code (e.g. `(count-word-buffers)`). You can either use `C-M-x` or press `C-j` at the end of a line to execute that line of code (or more precisely, the Lisp expression that ends at the cursor). `C-j` additionally inserts the return value into the buffer. This only lets you execute the function in the `*scratch*` buffer, you need to use the `M-:` method to run it from another buffer.
---
The way you've defined the function, it isn't a command that can be called interactively. To make it one, add an interactive specification to the function definition.
```
(defun count-words-buffer ()
(interactive "@")
…)
```
Then you can run the command with `M-x count-words-buffer RET`, you can bind it to a key, etc.
To be able to use the function from Elisp as well, it should return the number of words rather than print it as a message. You can either make a non-interactive function for lisp use and a separate command that just calls the non-interactive function and calls `message` on the result, or combine the two and just omit the `message` call if the function is not called interactively.
```
(defun count-words-buffer ()
(interactive "@")
(let ((count 0))
(goto-char (point-min))
(while (< (point) (point-max))
(forward-word 1)
(setq count (1+ count)))
(if (called-interactively-p)
(message "buffer contains %d words." count)
count))
```
---
This function already exists in Emacs, with the added bonus that if the region is active, it counts the words in the region. It's called (unsurprisingly) `count-words` and you can look at how it's coded.
---
Tags: functions
---
|
thread-52524
|
https://emacs.stackexchange.com/questions/52524
|
What is the point of the Ctrl-M binding? Can I overwrite it if I use the Return key?
|
2019-09-05T15:45:00.860
|
# Question
Title: What is the point of the Ctrl-M binding? Can I overwrite it if I use the Return key?
Looking for a new convenient keybinding for a frequently used command I stumbled upon Ctrl-M which is the same as Return/Enter.
What is the point of this binding? Can it cause some problem if I overwrite it?
# Answer
ASCII control character `Control M` is a carriage-return character. It *is* return, and its ASCII name is `RET`. That's the reason why `C-m` in Emacs is `RET`.
In terminal mode (no graphic display) Emacs does not have a `<return>` (pseudo-)function key. There is *only* the `RET` key, also known as `C-m`.
In a graphic-display Emacs has both a `<return>` key and a `RET` (`C-m`) key. **You can bind** either of them to **whatever command you like**.
If `<return>` is *not* explicitly bound then when you use `<return>` the binding of `RET` takes effect.
This is for *convenience* \- it's the same principle that lets key `M` act as key `m` if `m` is bound to a command and `M` is not explicitly bound to a command.
---
As @phils mentioned in a comment here, see also `C-h i g (elisp)Function Keys`.
> 3 votes
---
Tags: key-bindings
---
|
thread-52526
|
https://emacs.stackexchange.com/questions/52526
|
Why does calc subscr work with index vectors in org tables?
|
2019-09-05T16:12:43.493
|
# Question
Title: Why does calc subscr work with index vectors in org tables?
In my org table I use the next formula to sum rows `1,5,7` of column `6`.
```
| | Start date | End date | Task | State | Duration (hours) |
|---+------------------+------------------+----------+-----------+------------------|
| # | 15.08.2019 10:30 | 15.08.2019 12:00 | T-320 | Taken | 1.50 |
| # | 15.08.2019 13:00 | 15.08.2019 14:00 | T-320 | Taken | 1.00 |
| # | 15.08.2019 14:30 | 15.08.2019 18:00 | T-321 | Taken | 3.50 |
| # | 16.08.2019 10:30 | 16.08.2019 12:00 | T-321 | Taken | 1.50 |
| # | 16.08.2019 13:30 | 16.08.2019 15:30 | T-321 | Taken | 2.00 |
| # | 16.08.2019 15:30 | 16.08.2019 18:00 | T-322 | Taken | 2.50 |
| # | 28.08.2019 14:00 | 28.08.2019 17:00 | T-330 | Taken | 3.00 |
| # | 28.08.2019 17:00 | 28.08.2019 18:00 | T-331 | Taken | 1.00 |
| # | 29.08.2019 10:30 | 29.08.2019 15:00 | INIT-117 | Done | 4.50 |
| # | 29.08.2019 15:30 | 29.08.2019 16:00 | FM-222 | Done | 0.50 |
| # | 29.08.2019 16:00 | 29.08.2019 18:00 | T-331 | Postponed | 2.00 |
| # | 30.08.2019 10:30 | 30.08.2019 12:00 | INIT-121 | Taken | 1.50 |
| # | 30.08.2019 13:30 | 30.08.2019 21:00 | INIT-121 | Taken | 7.50 |
|---+------------------+------------------+----------+-----------+------------------|
| | | | | | 6.5 |
#+TBLFM: $6=$3-$2;t::@>$6=vsum(subscr(@I$6..@II$6,{1,5,7}));%.2f
```
Nice. It's work fine.
But I have a question: What is the return value of `subscr`?
# Answer
> 2 votes
I've given you a link to the calc manual in my other answer.
The manual describes that `subscr` is a synonym of `mrow` and the extension to vectors of indexes is described in the paragraph on `mrow`:
> If the index is itself a vector of integers, the result is a vector of the corresponding elements of the input vector, or a matrix of the corresponding rows of the input matrix. This command can be used to obtain any permutation of a vector.
Furthermore, the org-manual says that with org tables you have all the power of calc at your fingertips.
Note further that `@I$6..@II$6` in the org table formula expands to the calc vector `[1.50,1.00,3.50,1.50,2.00,2.50,3.00,1.00,4.50,0.50,2.00,1.50,7.50]` and that your expanded formula looks like:
```
vsum(subscr([1.50,1.00,3.50,1.50,2.00,2.50,3.00,1.00,4.50,0.50,2.00,1.50,7.50],{1,5,7}))
```
You can discover that for yourself by debugging your org table formula. Switch on `Tbl` -\> `Debug Formulas` before evaluating the formula.
---
Tags: org-mode
---
|
thread-52510
|
https://emacs.stackexchange.com/questions/52510
|
Not scape braces in LaTeX org-mode
|
2019-09-04T21:39:26.383
|
# Question
Title: Not scape braces in LaTeX org-mode
I am writting a LaTeX document using org-mode, and there is a section where I want to include a proof, which has the following code.
```
#+LaTeX_HEADER: \newcommand{\dem}[1]{\textcolor{gris}{\small{Demostración. #1}}}
```
If I write
```
\dem{(1) Esto es una demostración}
```
There is nothing wrong when exporting to LaTeX, and the text appears formated correctly. However, if I add an equation with some braces in it, like
```
\dem{Esto es una demostración con ecuación: \(x = x^{-2}\)}
```
then, the document is exported as
```
\dem\{Esto es una demostración con ecuación: \(x = x^{-2}\)\}
```
and the format is not correct. Is there any way I can "escape" those curly braces in my org-mode text to format the text correctly?
# Answer
> 1 votes
I don't know the reason why this happens. I've found a quick fix for the problem though.
```
#+BEGIN_EXPORT latex
\dem{Esto es una demostración con ecuación: \(x = x^{-2}\)}
#+END_EXPORT
```
Works fine
# Answer
> 1 votes
`org-element-latex-fragment-parser` is too simple to scope with nested brace-delimited lists as arguments of latex macros.
The following advice for `org-element-latex-fragment-parser` replaces the LaTeX macro parsing with a version that parses LaTeX arguments as sexps.
```
(require 'tex-mode)
(defun bugfix-org-forward-latex-sexp (&optional start count)
"Scan forward COUNT sexps starting with character START.
COUNT defaults to 1.
Skip over any sexp if START is not given.
Scanning stops at the end of the current line."
(let ((line-end (line-end-position))
state pos)
(unless count (setq count 1))
(while (and
(> count 0)
(or (null start)
(eq (char-after) start))
(save-excursion
(with-syntax-table
tex-mode-syntax-table
(setq state (parse-partial-sexp (point) ;; from
line-end ;; to
0 ;; targetdepth for forward-sexp
nil ;; stopbefore
state ;; oldstate
)
pos (point))
(null (> (nth 0 state) 0) ;; depth
))))
(goto-char pos)
(cl-decf count))
pos))
(defun bugfix-org-element-latex-fragment-parser (fun)
"See `org-element-latex-fragment-parser'.
This bugfix parses arguments of LaTeX macros as sexps."
(let ((begin (point))
(latex-macro (looking-at "\\\\[a-zA-Z]+\\*?")))
(if latex-macro
(progn
(goto-char (match-end 0))
;; scan optional arguments
(bugfix-org-forward-latex-sexp ?\[ (buffer-size))
;; scan brace-delimited argument
(bugfix-org-forward-latex-sexp ?\{)
(let ((fragment (buffer-substring-no-properties begin (point)))
(post-blank (skip-chars-forward " \t")))
(list 'latex-fragment
(list :value fragment
:begin begin
:end (point)
:post-blank post-blank))))
(funcall fun))))
(advice-add 'org-element-latex-fragment-parser :around #'bugfix-org-element-latex-fragment-parser)
```
---
Tags: org-mode, org-export, preview-latex
---
|
thread-14811
|
https://emacs.stackexchange.com/questions/14811
|
How can I adjust the fixed-width of a Neotree buffer?
|
2015-08-17T15:15:12.073
|
# Question
Title: How can I adjust the fixed-width of a Neotree buffer?
Using emacs 24, when I try to use the Neotree package I am having issues with modifying the fixed-width of the window. I believe I have found the responsible chunk of lisp, but changing the value doesn't seem to help on reload.
```
(defcustom neo-window-width 25
"*Specifies the width of the NeoTree window."
:type 'integer
:group 'neotree)
```
# Answer
You can disable `neo-window-fixed-size` and restart Neotree.
> 7 votes
# Answer
I'm using spacemacs and adding:
```
(setq neo-window-width 55)
```
to my `.spacemacs` file.
This is having no affect. Also, if I go into `customize-group` and select `neotree` and change the `Neo Window Width` the setting doesn't stick. Every time I restart Spacemacs the width defaults back to 32 and setting revert back to 32. I am saving for future sessions. Also, in the neotree `customize-group` under `Neo Window Width` it says, "CHANGED outside Customize."
I cannot find where this setting is being set. Any ideas?
I'm on 0.200.13@26.2 (spacemacs) running on macOS 10.14.6 installed through Homebrew.
> 2 votes
---
Tags: window, osx
---
|
thread-52530
|
https://emacs.stackexchange.com/questions/52530
|
Semantic way to export Org subtrees inside arbitrary LaTeX environments
|
2019-09-06T01:15:10.463
|
# Question
Title: Semantic way to export Org subtrees inside arbitrary LaTeX environments
I would like to begin taking math class notes in Org mode -- I have thus far used plain LaTeX, but I have found Org has the potential to be much faster for real-time scribing. I already made a custom export class that links to my scribe document class.
I would like to be able to use an Org object (e.g. property, tag) to indicate an environment within which a subtree should be exported. As I show below, this is quite useful for theorem-like environments.
Having to use source blocks or literal LaTeX environments within my Org document annuls much of Org's value for fast, reviewable math notes. I think it would be much better to write this subtree:
```
* Cosets
** Lagrange's Theorem :theorem:
If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
*** :proof:
Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...
```
And get this LaTeX out:
```
\section{Cosets}
\begin{theorem}[Lagrange's Theorem]
If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
\end{theorem}
\begin{proof}
Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...
\end{proof}
```
There are some caveats here, most notably that we must know whether the entire subtree should be wrapped in the environment, or just the content accompanying the subtree's root headline. Minimally, I would like to identify an environment by a headline tag of the same name and set the title passed into the environment to the headline text (where applicable).
Note that I am taking the idea beyond that given in org-mode special blocks latex attribute. The solutions found in Org-mode latex environment in drawer still feel hacky, although the custom link approach is almost there. I want this environmenting to feel as native and Org-semantic as possible.
I don't see any high-level Org functions for wrapping subtrees as I have described. From what I can see, `ATTR_LATEX` doesn't fit the bill. Thus, I would derive an export backend with a transcoder that does the subtree wrapping, as well as define some other options (like course and professor) that will be exported. I would have a list of valid environment tags that would be active only in a notes Org file -- maybe a minor mode to encapsulate that.
I'm not asking for coding help, but I would like to know if I am I going about this the right way. I've been at Org for two months or so, and it seems to this newbie that if functionality as clearly useful as semantic environmenting hasn't been implemented, it's probably for a good reason.
I have specific questions:
* Is there some Org mode functionality that I have overlooked that would make this or a similar idea very easy?
* Are tags the best way to indicate an environment for a subtree as I have described?
Of course, I could just use `outline-minor-mode` or `latex-extras` and be largely done with it within LaTeX, but it would be neat to abstract environments into Org in this manner.
# Answer
I use drawers (not the property drawer) for cases like this although I am not sure if you can pass options to them. Basically, I do
```
:proof:
... contents here
:end:
```
and then define org-latex-format-drawer-function so that it generates the right LaTeX code for the specific drawer type. For instance, for solutions to questions, I use a :solution: drawer and format it as follows:
```
(setq org-latex-format-drawer-function
(lambda (name contents)
(cond ((string= name "solution")
(format "\\begin{mdframed}\\paragraph{Solution.} %s\\end{mdframed}" contents))
(t (format "\\textbf{%s}: %s" name contents)))))
```
> 3 votes
---
Tags: org-mode, org-export, latex
---
|
thread-52539
|
https://emacs.stackexchange.com/questions/52539
|
How to stop lsp-mode converting C/C++ includes into buttons?
|
2019-09-06T19:59:57.623
|
# Question
Title: How to stop lsp-mode converting C/C++ includes into buttons?
When `lsp-mode` is enabled all headers become clickable (draw as buttons), underlining them making them slightly harder to read.
I don't need this since I can have a key bound to go to the header.
Is there a way not to highlight headers in C/C++ with lsp-mode?
# Answer
Set `lsp-enable-links` to nil. This will disable `lsp-mode`'s link support.
> 3 votes
---
Tags: lsp-mode
---
|
thread-52543
|
https://emacs.stackexchange.com/questions/52543
|
Expand abbrev on two spaces
|
2019-09-07T02:22:03.730
|
# Question
Title: Expand abbrev on two spaces
I want to expand abbrev when I type two spaces instead of one. Is there any way to do it? Simply adding a space to the abbrev pattern doesn't work -- the abbrev is still expanded on the first space.
# Answer
First, note that abbrevs expand when typing a word separator character, not just space. Looking at the doc for `self-insert-command` suggests that's no way to easily change the behavior of `abbrev-mode`.
> self-insert-command is an interactive built-in function in ‘src/cmds.c’.
>
> (self-insert-command N)
>
> Insert the character you type. Whichever character you type to run this command is inserted. The numeric prefix argument N says how many times to repeat the insertion. Before insertion, ‘expand-abbrev’ is executed if the inserted character does not have word syntax and the previous character in the buffer does.
However, what can be done is to not use `abbrev-mode` and rather bind the space key to a command that calls `expand-abbrev` "on second space" and falls back to inserting a space if no abbrev is found. The following code does that.
```
(defun insert-space-or-expand-abbrev-on-second-space ()
"Insert a space or expand abbrev before current space."
(interactive)
(if (and (equal (char-before (point)) ? )
(not (equal (char-before (1- (point))) ? )))
;; try to expand abbrev
(progn
(backward-char 1)
;; if no expansion occurs, fall back to inserting space
(unless (expand-abbrev) (insert-char ? ))
(forward-char 1))
;; just insert space
(insert-char ? )))
(local-set-key " " 'insert-space-or-expand-abbrev-on-second-space)
```
If an abbrev in indeed expanded, the second space is not inserted, but you can insert one by typing the space key one more time, since no abbrev would be found this time.
One could define something like a `two-spaces-abbrev-mode` based on this code.
As mentionned by @Stefan, a different approach would be to use `post-self-insert-hook`.
> 3 votes
---
Tags: abbrev
---
|
thread-52430
|
https://emacs.stackexchange.com/questions/52430
|
“call-process” hangs and does not launch the program
|
2019-08-30T20:47:41.683
|
# Question
Title: “call-process” hangs and does not launch the program
I’m dipping my toes into reading news with Gnus. I’d like to continue using the same editor as before for composing posts, so I put these forms in my gnus.el:
```
(setq message-tab-body-function 'edit-in-vim)
(defun edit-in-vim ()
(let ((filename (make-temp-file "gnus_vim_" nil ".usenet" (buffer-string))))
(call-process "/home/bdesham/.nix-profile/bin/vim" nil nil nil filename)
(insert-file-contents filename nil nil nil t)))
```
My intention is to do the following:
1. Write the current buffer into a new temporary file.
2. Run Vim to edit this temporary file. Wait for Vim to exit.
3. Replace the current buffer’s contents with the file’s contents.
Step 1 works fine—when I hit Tab in a message buffer, I see
> Wrote /tmp/gnus\_vim\_BE6h2K.usenet
at the bottom of the screen. At that point, though, Emacs hangs and won’t do anything until I type C-g. If I run `ps` during this hang, it doesn’t look like a new Vim process was created.
Am I using `call-process` wrong? Or is it not intended to be used to call programs that have their own terminal UI? How can I get this kind of external-editor functionality?
# Answer
> 1 votes
It seems like the problem is that both Emacs and Vim want to control the entire screen. If I edit the function in the question to use `date` or a utility like that instead of Vim, there is no hang and the output replaces the buffer contents in the way I want.
Fortunately, Emacs has a function called `suspend-emacs` which can be used to suspend Emacs, run some other command, and then (using the `fg` command built in to Unix shells) resume Emacs right where it left off. My full solution is
```
(setq message-tab-body-function 'edit-in-vim)
(defun edit-in-vim ()
(interactive "F")
(let ((filename (make-temp-file "gnus_vim_" nil ".usenet")))
(progn
(save-restriction
(widen)
(write-region (point-min) (point-max) filename))
(suspend-emacs (format "vim %s; fg"
(shell-quote-argument filename)))
(erase-buffer)
(insert-file-contents filename)
(delete-file filename))))
```
This will probably only work under Unix (including e.g. macOS and Linux) due to the assumption that the shell has a `fg` command. Also note that when Vim exits, Emacs will immediately start again and continue running this function, even if you made Vim quit with a nonzero status code.
Thanks to npostavs for pointing me to the `suspend-tty` function, which is related to `suspend-emacs`!
---
Tags: gnus, process
---
|
thread-52546
|
https://emacs.stackexchange.com/questions/52546
|
How to disable semantic highlighting in lsp-mode?
|
2019-09-07T13:14:26.890
|
# Question
Title: How to disable semantic highlighting in lsp-mode?
Language server mode has a variable for semantic highlighting `lsp-ht`, I would like to disable all syntax highlighting in lsp-mode. Is this possible?
```
(setq lsp-enable-links nil)
(setq lsp-enable-semantic-highlighting nil)
```
---
Edit, added an intentional error in ccls which is doing syntax highlithgint to check the call-stack.
```
Debugger entered--Lisp error: (void-function my-missing-function)
(save-current-buffer (set-buffer buffer) (my-missing-function) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (ccls--clear-skipped-ranges) (if ccls-enable-skipped-ranges (progn (overlay-recenter (point-max)) (seq-do #'... (gethash "skippedRanges" params))))) (if modified nil (restore-buffer-modified-p nil)))))
(progn (save-current-buffer (set-buffer buffer) (my-missing-function) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (ccls--clear-skipped-ranges) (if ccls-enable-skipped-ranges (progn (overlay-recenter ...) (seq-do ... ...)))) (if modified nil (restore-buffer-modified-p nil))))))
(if buffer (progn (save-current-buffer (set-buffer buffer) (my-missing-function) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (ccls--clear-skipped-ranges) (if ccls-enable-skipped-ranges (progn ... ...))) (if modified nil (restore-buffer-modified-p nil)))))))
(let ((buffer (find-buffer-visiting file))) (if buffer (progn (save-current-buffer (set-buffer buffer) (my-missing-function) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (ccls--clear-skipped-ranges) (if ccls-enable-skipped-ranges ...)) (if modified nil (restore-buffer-modified-p nil))))))))
(if file (let ((buffer (find-buffer-visiting file))) (if buffer (progn (save-current-buffer (set-buffer buffer) (my-missing-function) (let* ((modified ...) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn ... ...) (if modified nil ...))))))))
(let ((file (lsp--uri-to-path (gethash "uri" params)))) (if file (let ((buffer (find-buffer-visiting file))) (if buffer (progn (save-current-buffer (set-buffer buffer) (my-missing-function) (let* (... ... ... ...) (unwind-protect ... ...))))))))
ccls--publish-skipped-ranges(#s(lsp--workspace :parser #s(lsp--parser :headers (("Content-Length" . "12258")) :body "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSemanticHi..." :reading-body t :body-length 12258 :body-received 2584 :leftovers nil :workspace #1) :server-capabilities #<hash-table equal 22/22 0x158953e91315> :registered-server-capabilities (#s(lsp--registered-capability :id "didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158953cad471>)) :root "/src/blender/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) (filter sentinel name) (let ((final-command ...) (process-name ...)) (let (...) (set-process-query-on-exit-flag proc nil) (cons proc proc)))) :test\? (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x158953d94aad> :request-handlers #<hash-table equal 0/65 0x158953d94cdd> :response-handlers #<hash-table eql 0/65 0x158953d94cfd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158953d94d1d> :action-handlers #<hash-table equal 0/65 0x158953d94d3d> :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x158953d94641>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil) :host-root nil :proc #<process ccls> :cmd-proc #<process ccls> :buffers (#<buffer creator.c>) :highlight-overlays #<hash-table eq 0/65 0x158953bd2cd5> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158953bd2e81> :watches #<hash-table equal 0/65 0x158953bd2ea1> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158953bd2ec1> :ewoc nil) #<hash-table equal 2/2 0x158953f46b79>)
funcall(ccls--publish-skipped-ranges #s(lsp--workspace :parser #s(lsp--parser :headers (("Content-Length" . "12258")) :body "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSemanticHi..." :reading-body t :body-length 12258 :body-received 2584 :leftovers nil :workspace #2) :server-capabilities #<hash-table equal 22/22 0x158953e91315> :registered-server-capabilities (#s(lsp--registered-capability :id "didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158953cad471>)) :root "/src/blender/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) (filter sentinel name) (let ((final-command ...) (process-name ...)) (let (...) (set-process-query-on-exit-flag proc nil) (cons proc proc)))) :test\? (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x158953d94aad> :request-handlers #<hash-table equal 0/65 0x158953d94cdd> :response-handlers #<hash-table eql 0/65 0x158953d94cfd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158953d94d1d> :action-handlers #<hash-table equal 0/65 0x158953d94d3d> :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x158953d94641>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil) :host-root nil :proc #<process ccls> :cmd-proc #<process ccls> :buffers (#<buffer creator.c>) :highlight-overlays #<hash-table eq 0/65 0x158953bd2cd5> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158953bd2e81> :watches #<hash-table equal 0/65 0x158953bd2ea1> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158953bd2ec1> :ewoc nil) #<hash-table equal 2/2 0x158953f46b79>)
(if handler (funcall handler workspace params) (if (string-prefix-p "$" method) nil (lsp-warn "Unknown method: %s" method)))
(let* ((handler (and t (or (gethash method (progn (or ... ...) (aref client 6))) (gethash method lsp--default-notification-handlers))))) (if handler (funcall handler workspace params) (if (string-prefix-p "$" method) nil (lsp-warn "Unknown method: %s" method))))
(let* ((params (gethash "params" input0)) (method (gethash "method" input0)) (client input1)) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method nil params 'incoming-notif) lsp--cur-workspace))) (let* ((handler (and t (or (gethash method (progn ... ...)) (gethash method lsp--default-notification-handlers))))) (if handler (funcall handler workspace params) (if (string-prefix-p "$" method) nil (lsp-warn "Unknown method: %s" method)))))
(let ((input0 notification) (input1 (progn (or (and (memq (type-of workspace) cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list 'lsp--workspace workspace))) (aref workspace 5)))) (let* ((params (gethash "params" input0)) (method (gethash "method" input0)) (client input1)) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method nil params 'incoming-notif) lsp--cur-workspace))) (let* ((handler (and t (or (gethash method ...) (gethash method lsp--default-notification-handlers))))) (if handler (funcall handler workspace params) (if (string-prefix-p "$" method) nil (lsp-warn "Unknown method: %s" method))))))
lsp--on-notification(#s(lsp--workspace :parser #s(lsp--parser :headers (("Content-Length" . "12258")) :body "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSemanticHi..." :reading-body t :body-length 12258 :body-received 2584 :leftovers nil :workspace #1) :server-capabilities #<hash-table equal 22/22 0x158953e91315> :registered-server-capabilities (#s(lsp--registered-capability :id "didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158953cad471>)) :root "/src/blender/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) (filter sentinel name) (let ((final-command ...) (process-name ...)) (let (...) (set-process-query-on-exit-flag proc nil) (cons proc proc)))) :test\? (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x158953d94aad> :request-handlers #<hash-table equal 0/65 0x158953d94cdd> :response-handlers #<hash-table eql 0/65 0x158953d94cfd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158953d94d1d> :action-handlers #<hash-table equal 0/65 0x158953d94d3d> :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x158953d94641>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil) :host-root nil :proc #<process ccls> :cmd-proc #<process ccls> :buffers (#<buffer creator.c>) :highlight-overlays #<hash-table eq 0/65 0x158953bd2cd5> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158953bd2e81> :watches #<hash-table equal 0/65 0x158953bd2ea1> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158953bd2ec1> :ewoc nil) #<hash-table equal 3/3 0x158953f46b21>)
(let ((before-notification (current-time))) (lsp--on-notification lsp--cur-workspace json-data) (lsp--log-notification-performance server-id json-data received-time after-parsed-time before-notification (current-time)))
(cond ((eq val 'response) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-62-- (gethash id (progn (or ... ...) (aref client 8)))) (callback (car-safe (prog1 --dash-source-62-- (setq --dash-source-62-- ...)))) (method (prog1 (car (cdr --dash-source-62--)) (setq --dash-source-62-- (nthcdr 2 --dash-source-62--)))) (start-time (car-safe (prog1 --dash-source-62-- (setq --dash-source-62-- ...)))) (before-send (car --dash-source-62--))) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method id data 'incoming-resp (/ ... 1000)) lsp--cur-workspace))) (if callback (progn (funcall callback (gethash "result" json-data)) (remhash id (progn (or ... ...) (aref client 8))) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time (current-time)))))) ((eq val 'response-error) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-64-- (cdr (gethash id (progn ... ...)))) (callback (car-safe (prog1 --dash-source-64-- (setq --dash-source-64-- ...)))) (method (car-safe (prog1 --dash-source-64-- (setq --dash-source-64-- ...)))) (start-time (car-safe (prog1 --dash-source-64-- (setq --dash-source-64-- ...)))) (before-send (car --dash-source-64--))) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method id data 'incoming-resp (/ ... 1000)) lsp--cur-workspace))) (if callback (progn (funcall callback (gethash "error" json-data)) (remhash id (progn (or ... ...) (aref client 8))) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time (current-time)))))) ((eq val 'notification) (let ((before-notification (current-time))) (lsp--on-notification lsp--cur-workspace json-data) (lsp--log-notification-performance server-id json-data received-time after-parsed-time before-notification (current-time)))) ((eq val 'request) (lsp--on-request lsp--cur-workspace json-data)) (t nil))
(let* ((val (lsp--get-message-type json-data))) (cond ((eq val 'response) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-62-- (gethash id (progn ... ...))) (callback (car-safe (prog1 --dash-source-62-- ...))) (method (prog1 (car ...) (setq --dash-source-62-- ...))) (start-time (car-safe (prog1 --dash-source-62-- ...))) (before-send (car --dash-source-62--))) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method id data ... ...) lsp--cur-workspace))) (if callback (progn (funcall callback (gethash "result" json-data)) (remhash id (progn ... ...)) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time (current-time)))))) ((eq val 'response-error) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-64-- (cdr (gethash id ...))) (callback (car-safe (prog1 --dash-source-64-- ...))) (method (car-safe (prog1 --dash-source-64-- ...))) (start-time (car-safe (prog1 --dash-source-64-- ...))) (before-send (car --dash-source-64--))) (if lsp-print-io (progn (lsp--log-entry-new (lsp--make-log-entry method id data ... ...) lsp--cur-workspace))) (if callback (progn (funcall callback (gethash "error" json-data)) (remhash id (progn ... ...)) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time (current-time)))))) ((eq val 'notification) (let ((before-notification (current-time))) (lsp--on-notification lsp--cur-workspace json-data) (lsp--log-notification-performance server-id json-data received-time after-parsed-time before-notification (current-time)))) ((eq val 'request) (lsp--on-request lsp--cur-workspace json-data)) (t nil)))
(let* ((client (progn (or (and (memq (type-of lsp--cur-workspace) cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list 'lsp--workspace lsp--cur-workspace))) (aref lsp--cur-workspace 5))) (received-time (current-time)) (server-id (progn (or (and (memq (type-of client) cl-struct-lsp--client-tags) t) (signal 'wrong-type-argument (list 'lsp--client client))) (aref client 15))) (json-data (lsp--read-json msg)) (after-parsed-time (current-time)) (id (let ((it (gethash "id" json-data))) (if it (progn (if (stringp it) (string-to-number it) it))))) (data (gethash "result" json-data))) (let* ((val (lsp--get-message-type json-data))) (cond ((eq val 'response) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-62-- (gethash id ...)) (callback (car-safe ...)) (method (prog1 ... ...)) (start-time (car-safe ...)) (before-send (car --dash-source-62--))) (if lsp-print-io (progn (lsp--log-entry-new ... lsp--cur-workspace))) (if callback (progn (funcall callback ...) (remhash id ...) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time ...))))) ((eq val 'response-error) (progn (or id (cl--assertion-failed 'id)) nil) (let* ((--dash-source-64-- (cdr ...)) (callback (car-safe ...)) (method (car-safe ...)) (start-time (car-safe ...)) (before-send (car --dash-source-64--))) (if lsp-print-io (progn (lsp--log-entry-new ... lsp--cur-workspace))) (if callback (progn (funcall callback ...) (remhash id ...) (lsp--log-request-time server-id method id start-time before-send received-time after-parsed-time ...))))) ((eq val 'notification) (let ((before-notification (current-time))) (lsp--on-notification lsp--cur-workspace json-data) (lsp--log-notification-performance server-id json-data received-time after-parsed-time before-notification (current-time)))) ((eq val 'request) (lsp--on-request lsp--cur-workspace json-data)) (t nil))))
(let ((lsp--cur-workspace (progn (or (and (memq (type-of p) cl-struct-lsp--parser-tags) t) (signal 'wrong-type-argument (list 'lsp--parser p))) (aref p 7)))) (let* ((client (progn (or (and (memq ... cl-struct-lsp--workspace-tags) t) (signal 'wrong-type-argument (list ... lsp--cur-workspace))) (aref lsp--cur-workspace 5))) (received-time (current-time)) (server-id (progn (or (and (memq ... cl-struct-lsp--client-tags) t) (signal 'wrong-type-argument (list ... client))) (aref client 15))) (json-data (lsp--read-json msg)) (after-parsed-time (current-time)) (id (let ((it (gethash "id" json-data))) (if it (progn (if ... ... it))))) (data (gethash "result" json-data))) (let* ((val (lsp--get-message-type json-data))) (cond ((eq val 'response) (progn (or id (cl--assertion-failed ...)) nil) (let* ((--dash-source-62-- ...) (callback ...) (method ...) (start-time ...) (before-send ...)) (if lsp-print-io (progn ...)) (if callback (progn ... ... ...)))) ((eq val 'response-error) (progn (or id (cl--assertion-failed ...)) nil) (let* ((--dash-source-64-- ...) (callback ...) (method ...) (start-time ...) (before-send ...)) (if lsp-print-io (progn ...)) (if callback (progn ... ... ...)))) ((eq val 'notification) (let ((before-notification ...)) (lsp--on-notification lsp--cur-workspace json-data) (lsp--log-notification-performance server-id json-data received-time after-parsed-time before-notification (current-time)))) ((eq val 'request) (lsp--on-request lsp--cur-workspace json-data)) (t nil)))))
lsp--parser-on-message(#s(lsp--parser :headers (("Content-Length" . "12258")) :body "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSemanticHi..." :reading-body t :body-length 12258 :body-received 2584 :leftovers nil :workspace #s(lsp--workspace :parser #1 :server-capabilities #<hash-table equal 22/22 0x158953e91315> :registered-server-capabilities (#s(lsp--registered-capability :id "didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158953cad471>)) :root "/src/blender/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) (filter sentinel name) (let (... ...) (let ... ... ...))) :test\? (closure ((command . #f(compiled-function () #<bytecode 0x158953d94635>)) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x158953d94aad> :request-handlers #<hash-table equal 0/65 0x158953d94cdd> :response-handlers #<hash-table eql 0/65 0x158953d94cfd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158953d94d1d> :action-handlers #<hash-table equal 0/65 0x158953d94d3d> :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x158953d94641>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil) :host-root nil :proc #<process ccls> :cmd-proc #<process ccls> :buffers (#<buffer creator.c>) :highlight-overlays #<hash-table eq 0/65 0x158953bd2cd5> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158953bd2e81> :watches #<hash-table equal 0/65 0x158953bd2ea1> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158953bd2ec1> :ewoc nil)) "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSkippedRan...")
(let ((m (car --dolist-tail--))) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--)))
(while --dolist-tail-- (let ((m (car --dolist-tail--))) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--))))
(let ((--dolist-tail-- messages)) (while --dolist-tail-- (let ((m (car --dolist-tail--))) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--)))))
(progn (let ((--dolist-tail-- messages)) (while --dolist-tail-- (let ((m (car --dolist-tail--))) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--))))))
(if messages (progn (let ((--dolist-tail-- messages)) (while --dolist-tail-- (let ((m (car --dolist-tail--))) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--)))))))
(let ((messages (condition-case err (lsp--parser-read p output) (error (let ((chunk ...)) (lsp--parser-reset p) (ignore (lsp-warn "Failed to parse the following chunk:\n'''\n%s\n'''\nwi..." chunk err))))))) (if messages (progn (let ((--dolist-tail-- messages)) (while --dolist-tail-- (let ((m ...)) (lsp--parser-on-message p m) (setq --dolist-tail-- (cdr --dolist-tail--))))))))
(progn (let ((messages (condition-case err (lsp--parser-read p output) (error (let (...) (lsp--parser-reset p) (ignore ...)))))) (if messages (progn (let ((--dolist-tail-- messages)) (while --dolist-tail-- (let (...) (lsp--parser-on-message p m) (setq --dolist-tail-- ...))))))))
(if (let* ((--cl-var-- ignore-regexps) (r nil) (--cl-var-- t) --cl-var--) (while (and (consp --cl-var--) (progn (setq r (car --cl-var--)) (if (string-match r output) (setq --cl-var-- nil --cl-var-- nil) t))) (setq --cl-var-- (cdr --cl-var--))) (if --cl-var-- (progn t) --cl-var--)) (progn (let ((messages (condition-case err (lsp--parser-read p output) (error (let ... ... ...))))) (if messages (progn (let ((--dolist-tail-- messages)) (while --dolist-tail-- (let ... ... ...))))))))
(closure ((ignore-regexps) (p . #s(lsp--parser :headers (("Content-Length" . "12258")) :body "{\"jsonrpc\":\"2.0\",\"method\":\"$ccls/publishSemanticHi..." :reading-body t :body-length 12258 :body-received 2584 :leftovers nil :workspace #s(lsp--workspace :parser #5 :server-capabilities #<hash-table equal 22/22 0x158953e91315> :registered-server-capabilities (#s(lsp--registered-capability :id "didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x158953cad471>)) :root "/src/blender/" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect ... :test\? ...) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x158953d94aad> :request-handlers #<hash-table equal 0/65 0x158953d94cdd> :response-handlers #<hash-table eql 0/65 0x158953d94cfd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x158953d94d1d> :action-handlers #<hash-table equal 0/65 0x158953d94d3d> :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x158953d94641>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil) :host-root nil :proc #<process ccls> :cmd-proc #<process ccls> :buffers (#<buffer creator.c>) :highlight-overlays #<hash-table eq 0/65 0x158953bd2cd5> :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x158953bd2e81> :watches #<hash-table equal 0/65 0x158953bd2ea1> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 1/65 0x158953bd2ec1> :ewoc nil))) cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags cl-struct-lsp--folding-range-tags cl-struct-lsp-diagnostic-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags cl-struct-lsp--parser-tags lsp--log-lines t) (_proc output) (if (let* ((--cl-var-- ignore-regexps) (r nil) (--cl-var-- t) --cl-var--) (while (and (consp --cl-var--) (progn (setq r ...) (if ... ... t))) (setq --cl-var-- (cdr --cl-var--))) (if --cl-var-- (progn t) --cl-var--)) (progn (let ((messages (condition-case err ... ...))) (if messages (progn (let ... ...)))))))(#<process ccls> "Content-Length: 1463\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":...")
```
# Answer
> 1 votes
The `ccls` semantic highlight is adhoc implementation implemented before the semantic highlight was added to lsp protocol(which FTR is still not in but there is proposal implemented by several language servers). and it is not controlled from `lsp-enable-semantic-highlight` variable.
To disable it do
```
(setq ccls-sem-highlight-method nil)
```
---
Tags: syntax-highlighting, lsp-mode
---
|
thread-52553
|
https://emacs.stackexchange.com/questions/52553
|
With "japanese" input method, unmap kanji selection via the spacebar?
|
2019-09-07T23:35:18.320
|
# Question
Title: With "japanese" input method, unmap kanji selection via the spacebar?
In emacs-26.1, I am enabling the Japanese input method as follows ...
```
(toggle-enable-multibyte-characters 1)
(set-language-environment "Japanese")
(set-input-method "japanese")
(setq coding-system-for-read 'utf-8-unix)
(setq coding-system-for-write 'utf-8-unix)
```
This works fine and gives me hiragana characters when I enter their romaji equivalents, but `SPC` is mapped to a selection dialog for kanji characters. I want `SPC` to be mapped simply as `self-insert-command`, and I'd like to remap the kanji selection dialog to a different key sequence.
I tried the following, but it had no effect ...
```
(define-key kkc-keymap " " 'self-insert-command)
(define-key kkc-keymap "\C-^" 'kkc-next)
```
`SPC` still got me into the kanji selection dialog, and `C-^`did nothing.
I'm not sure, but it seems like there is code somewhere in `kkc.el` which forces `kkc-next` to be mapped to `SPC`, no matter what.
Short of completely rewriting some of the code in `emacs-26.1/lisp/international/kkc.el`, is there any way to remap the kanji selection dialog to something other than `SPC`?
# Answer
I figured it out.
As defined in `lisp/international/quail.el`, `(quail-conversion-keymap)` returns the keymap which is used for input methods, including the Japanese input method. In this keymap, `" "` (and not `(kbd "SPC")` in this case) gets mapped to `quail-japanese-kanji-kkc`, which causes the input selection dialog to be invoked via `kkc-region` from within `lisp/international/kkc.el`.
So, doing the following to enter the Japanese input method accomplishes what I want ...
```
(toggle-enable-multibyte-characters 1)
(set-language-environment "Japanese")
(set-input-method "japanese")
(setq coding-system-for-read 'utf-8-unix)
(setq coding-system-for-write 'utf-8-unix)
;; Enter the kanji selection dialog via `\C-^`,
;; and change the spacebar to simply insert a space.
(let ((qckeymap (quail-conversion-keymap)))
(define-key qckeymap "\C-^" 'quail-japanese-kanji-kkc)
(define-key qckeymap " " 'self-insert-command))
```
> 1 votes
---
Tags: key-bindings, keymap, input-method, japanese
---
|
thread-52563
|
https://emacs.stackexchange.com/questions/52563
|
use-package can't load package at startup
|
2019-09-08T07:03:52.737
|
# Question
Title: use-package can't load package at startup
When I start Emacs I get the error message
> Error (use-package): Cannot load counsel
But when I open `init.el` in a buffer and run `eval-buffer` everything works fine. What I'm doing wrong?
My Emacs config: https://git.sr.ht/~inquisitive/emacs-adjustments/tree/package/ivy/.emacs.d/init.el
```
;; Bootstrap straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(use-package magit
:bind ("C-x g" . magit-status))
(use-package counsel
:config
(counsel-mode 1))
;; Display line numbers in programming major modes
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t)
'(menu-bar-mode nil)
'(scroll-bar-mode nil)
'(straight-use-package-by-default t)
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "#fcfcfc" :foreground "#232627" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 143 :width normal :foundry "FSD " :family "PragmataPro Mono Liga")))))
```
# Answer
> 0 votes
You need to add the straight keyword in the use-package macro call e.g. add `:straight t`
From straight.el documentation https://github.com/raxod502/straight.el#integration-with-use-package
> To use use-package, first install it with straight.el:
>
> ```
> (straight-use-package 'use-package)
>
> ```
>
> Now use-package will use straight.el to automatically install missing packages if you provide :straight t:
>
> ```
> (use-package el-patch
> :straight t)
>
> ```
# Answer
> 0 votes
It seems that the bug occurs because I set `straight-use-package-by-default` using the customize-interface. When I set the variable outside of `custom-set-variables` everything works fine.
# Answer
> -1 votes
In general you need to initialize the package system if you're going to use packages at init time.
i.e. Do this first:
```
(setq package-enable-at-startup nil)
(package-initialize)
```
(That said, I'd be slightly surprised if `use-package` didn't do that itself, so maybe this isn't the issue; but it's certainly worth testing it.)
---
Tags: init-file, use-package, start-up
---
|
thread-52549
|
https://emacs.stackexchange.com/questions/52549
|
Get Emacs to jump to the start of a word after isearch
|
2019-09-07T17:57:01.147
|
# Question
Title: Get Emacs to jump to the start of a word after isearch
If I use isearch to search for the word "accommodating" in my document, I have to type acc before the cursor jumps to the word. When I press enter the cursor is on the the second "c" as in acCommodating. This strikes me as rather unintuitive because I have to go back two characters to begin editing the word. In Vim, search puts the cursor at the start of the word. Can I replicate this behaviour in Emacs?
# Answer
> 2 votes
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit *some* key to tell it that. So at a minimum you have `C-s acc <SOME KEY>`.
You can end Isearch with any key that is not already bound to something in `isearch-mode-map`. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with `M-b` (that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
`C-s acc M-b`
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
`C-h k M-b` tells you:
> `M-b` runs the command `backward-word` (found in `global-map`), which is an interactive compiled Lisp function in `simple.el`.
>
> It is bound to `M-b`, `ESC left`.
>
> `(backward-word &optional ARG)`
>
> Move backward until encountering the beginning of a word.
>
> With argument `ARG`, do this that many times. If `ARG` is omitted or `nil`, move point backward one word.
>
> The word boundaries are normally determined by the buffer’s syntax table and character script (according to `char-script-table`), but `find-word-boundary-function-table`, such as set up by `subword-mode`, can change that. If a Lisp program needs to move by words determined strictly by the syntax table, it should use `backward-word-strictly` instead. See Info node (elisp) Word Motion for details.
# Answer
> 5 votes
As Drew pointed out in his answer you can also end the search with another key such as `M-b` or `M-f`, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
```
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
```
**UPDATE**: or in case you don't use `use-package`:
```
(define-key isearch-mode-map (kbd "<C-return>")
(defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
```
Basically, map `C-Ret` to another function `isearch-done-opposite` which checks the variable `isearch-other-end` which is defined in `isearch.el` as:
```
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
```
This will work with forward and backward searches.
# Answer
> 2 votes
Luckily this has been studied by Malabarba and published in his blog, Endless. I have the following in my config:
```
(use-package isearch
:no-require t
:demand t
;; Go to the start of current isearch match. (adapted from Endless)
:hook (isearch-mode-end . (lambda ()
(when (and isearch-forward
(number-or-marker-p isearch-other-end)
(not mark-active)
(not isearch-mode-end-hook-quit))
(goto-char isearch-other-end)))))
```
Check the blog entry for other solutions as well.
---
Tags: isearch, words
---
|
thread-26859
|
https://emacs.stackexchange.com/questions/26859
|
Trace calls to a function with the parameters
|
2016-09-05T18:02:01.883
|
# Question
Title: Trace calls to a function with the parameters
I need to track the calls to `org-tags-view` to discover the params passed to it.
I tried an advice:
```
(defun his-tracing-function (orig-fun &rest args)
(message "org-tags-view called with args %S" args)
(let ((res (apply orig-fun args)))
(message "org-tags-view returned %S" res)
res))
(advice-add 'org-tags-view :around #'his-tracing-function)
```
But the return was `display-buffer called with args (nil)`. How can I discover what params was passed for this function?
# Answer
> 6 votes
The easiest way to find out the arguments passed to a function is to use `M-x trace-function RET name-of-your-function RET`. Once you're done, use `M-x untrace-function` or `M-x untrace-all`.
Note that this should work for most functions you're interested in, but there are a few corner cases. See the commentary at the top of trace.el.
# Answer
> 1 votes
You can force entering the debugger when a function is called,
```
(debug-on-entry 'myf)
```
Any calls to `myf` triggers the debugger. A `(myf 2 3)` call, for example, would result in
```
Debugger entered--entering a function:
* (myf 2 3)
...
```
Remove it when you're done,
```
(cancel-debug-on-entry 'list)
```
# Answer
> 0 votes
Someone else will likely answer your direct question, which is about `nadvice`, the "new" advice system. In case it helps you or others, this answer is about the "old" advice system (`defadvice`).
One reason to show it here is that this information was purged from the Elisp manual (unwisely, IMHO). It is available now only with Emacs 23 and previous builds.
Answer for the "old" advice system: *Just use macro **`ad-get-arg`** or macro **`ad-get-args`**.*
The (Emacs 23) Elisp manual, node `Argument Access in Advice`, says this:
```
The simplest way to access the arguments of an advised function in the
body of a piece of advice is to use the same names that the function
definition uses. To do this, you need to know the names of the argument
variables of the original function.
While this simple method is sufficient in many cases, it has a
disadvantage: it is not robust, because it hard-codes the argument names
into the advice. If the definition of the original function changes,
the advice might break.
Another method is to specify an argument list in the advice itself.
This avoids the need to know the original function definition's argument
names, but it has a limitation: all the advice on any particular
function must use the same argument list, because the argument list
actually used for all the advice comes from the first piece of advice
for that function.
A more robust method is to use macros that are translated into the
proper access forms at activation time, i.e., when constructing the
advised definition. Access macros access actual arguments by their
(zero-based) position, regardless of how these actual arguments get
distributed onto the argument variables of a function. This is robust
because in Emacs Lisp the meaning of an argument is strictly determined
by its position in the argument list.
-- Macro: ad-get-arg position
This returns the actual argument that was supplied at POSITION.
-- Macro: ad-get-args position
This returns the list of actual arguments supplied starting at
POSITION.
-- Macro: ad-set-arg position value
This sets the value of the actual argument at POSITION to VALUE
-- Macro: ad-set-args position value-list
This sets the list of actual arguments starting at POSITION to
VALUE-LIST.
Now an example. Suppose the function `foo' is defined as
(defun foo (x y &optional z &rest r) ...)
and is then called with
(foo 0 1 2 3 4 5 6)
which means that X is 0, Y is 1, Z is 2 and R is `(3 4 5 6)' within the
body of `foo'. Here is what `ad-get-arg' and `ad-get-args' return in
this case:
(ad-get-arg 0) => 0
(ad-get-arg 1) => 1
(ad-get-arg 2) => 2
(ad-get-arg 3) => 3
(ad-get-args 2) => (2 3 4 5 6)
(ad-get-args 4) => (4 5 6)
Setting arguments also makes sense in this example:
(ad-set-arg 5 "five")
has the effect of changing the sixth argument to `"five"'. If this
happens in advice executed before the body of `foo' is run, then R will
be `(3 4 "five" 6)' within that body.
Here is an example of setting a tail of the argument list:
(ad-set-args 0 '(5 4 3 2 1 0))
If this happens in advice executed before the body of `foo' is run,
then within that body, X will be 5, Y will be 4, Z will be 3, and R
will be `(2 1 0)' inside the body of `foo'.
These argument constructs are not really implemented as Lisp macros.
Instead they are implemented specially by the advice mechanism.
```
---
Tags: debugging, functions, advice
---
|
thread-52575
|
https://emacs.stackexchange.com/questions/52575
|
Mimic human typing with emacs
|
2019-09-08T19:15:49.233
|
# Question
Title: Mimic human typing with emacs
I want to record some typing on a screen video using emacs and I'm wondering if there is something available in emacs to mimic human typing. I imagine I feed it a line(region) of text and it is displayed in the buffer, character by character which a human can follow. A bit faster and without backspace correction than my live typing, but still a lot slower than just playing back an recorded macro?
# Answer
You probably want to use the function `sit-for`:
> (sit-for SECONDS &optional NODISP)
>
> Redisplay, then wait for SECONDS seconds. Stop when input is available. SECONDS may be a floating-point value.
So you could do something like that:
```
(defun insert-like-human (text &optional delay)
(let ((d (or delay 0.1)))
(mapc (lambda (c) (sit-for d) (insert c)) text)))
```
You can call it with `M-: (insert-like-human "my text")` or `M-: (insert-like-human "my slower text" 0.2)`.
As mentionned by @zck, you could also use random delay to make it look more natural, eg:
```
(defun insert-like-human (text &optional delay)
(let ((d (or delay 0.2)))
(mapc (lambda (c) (sit-for (cl-random d)) (insert c)) text)))
```
> 4 votes
---
Tags: video
---
|
thread-52487
|
https://emacs.stackexchange.com/questions/52487
|
mu4e: how to stop the unarchiving of entire threads when new message arrives?
|
2019-09-04T01:02:53.543
|
# Question
Title: mu4e: how to stop the unarchiving of entire threads when new message arrives?
The issue:
Say a new message arrives in my inbox that is a reply to an existing thread/chain of emails that I've archived. mu4e will move the entire thread out of the archive and back into my inbox.
The question:
Is there a way to stop mu4e from moving the whole thread out of archive and back into my inbox? For context, in Gmail this can be accomplished by turning "conversation grouping" off.
I am a mu4e newb, but digging it so far. Any help with the issue I'm encountering would be much appreciated.
# Answer
You may have display of "related messages" turned on. Try pressing `W` (note: capital) while in your inbox (`mu4e-headers-toggle-include-related`) and seeing if those messages disappear.
If this is what is happening then those messages you were seeing weren't being "moved" back from where they were archived to; mu4e is including them in the inbox headers list for your convenience. It will also show your replies to inbox messages (which will be in some "sent" folder), or messages in the thread that you'd manually moved to any other folder.
Related messages is described in the mu4e documentation: https://www.djcbsoftware.nl/code/mu/mu4e/Other-search-functionality.html#Including-related-messages
> 7 votes
---
Tags: email, mu4e
---
|
thread-52596
|
https://emacs.stackexchange.com/questions/52596
|
Lexical binding in a process filter
|
2019-09-09T19:18:58.107
|
# Question
Title: Lexical binding in a process filter
The code constantly prints `server-process: nil` instead of the server process name:
```
-*- lexical-binding: t; -*-
(let* ((port 1234)
(server-process 'something))
(setq server-process
(make-network-process
:server t
:name "libbasecampel-oauth-http-server"
:service port
:buffer (generate-new-buffer "*libbasecampel-oauth-http-server*")
:filter (lambda (_process _data)
(message "server-process: %s" server-process)))))
```
Can someone please explain why I can't access the server process from the filter lambda? Also, I would like to know how to do it, my goal being to kill the server when data arrives.
In case you wonder, the `_process` argument to the filter function is the client process, not the server one.
# Answer
In a private email, Christopher Wellons answered my question. The problem is that `server-process` is a special variable defined in server.el. Special variables are always dynamically bound. As a result, the filter closure doesn't close over the `server-process` variable. When the filter closure is evaluated, the `server-process` variable's value is the one from server.el, i.e., `nil` for me.
The fix is to use a different variable name.
> 1 votes
---
Tags: process, lexical-scoping, networking, lexical-binding
---
|
thread-52608
|
https://emacs.stackexchange.com/questions/52608
|
How to add a value for CC or reply-to in each new message
|
2019-09-10T12:42:00.887
|
# Question
Title: How to add a value for CC or reply-to in each new message
I use `mu4e`. I would like to add a hook called with a new message, such as adding a certain value in CC or in Reply-to. I found no guidance online and no functions starting with `mu4e` and ending with `hook` (only `mu4e~compose-register-message-save-hooks`).
How can I add a header automatically?
# Answer
The documentation has one such example:
```
(add-hook 'mu4e-compose-mode-hook
(defun my-add-bcc ()
"Add a Bcc: header."
(save-excursion (message-add-header "Bcc: me@example.com\n"))))
```
This `mu4e-compose-mode-hook` does not show as a function because it's a variable. Do `C-h v RET mue4*hook` and you will see many matches.
> 0 votes
---
Tags: mu4e
---
|
thread-52610
|
https://emacs.stackexchange.com/questions/52610
|
magit-checkout does not update current buffer
|
2019-09-10T16:11:09.387
|
# Question
Title: magit-checkout does not update current buffer
When I checkout an existing remote branch, the current buffer remains on the old branch. However if I open a new file, that new file is on the checked-out branch.
My current workflow is this:
1. editing file `a.txt`
2. magit-checkout `feature` (`a.txt` exists on `feature`)
3. close `a.txt`
4. open `a.txt`
And the workflow I want to get is this:
1. editing file `a.txt`
2. magit-checkout `feature` (`a.txt` exists on `feature`)
3. `a.txt` is now the version from `feature`
Is there a way to make the current buffer file be checked out on the new branch?
p.s. I'm using Spacemacs, don't know if that matters here.
# Answer
> 1 votes
(Disclaimer: I don't know if this is how Magit and Spacemacs actually work, but it fits my hypothesis.)
When you `magit-checkout` a remote branch, magit can't know if the current file you have open in the buffer also exists in the remote branch. However, `git-checkout` changed the file, so a workaround (pointed out in a comment by MTS) is to *revert* the file (as in, revert to the version that changed on disk) using `M-x revert-buffer RET`.
Once you've reverted the file once, checking out the previous branch again (or checking out a new branch) will automatically revert the file going forward.
At least, this occurs on my system (Spacemacs with the `Global-Auto-Revert` minor mode enabled).
So the modified workflow is:
1. edit `a.txt`
2. `magit-checkout` remote branch `feature`
3. if the file does not update, force it using `revert-buffer`
4. `a.txt` will be the version from `feature`
5. subsequent checkouts will revert automatically
---
Tags: spacemacs, magit
---
|
thread-16792
|
https://emacs.stackexchange.com/questions/16792
|
Easiest way to check if current line is "empty" (ignoring whitespace)?
|
2015-09-21T13:35:54.543
|
# Question
Title: Easiest way to check if current line is "empty" (ignoring whitespace)?
I just want to check if the current line is empty or not (if it contains only whitespace, then I still consider it empty).
Here is my initial version:
```
(defun strip-text-properties(txt)
(set-text-properties 0 (length txt) nil txt)
txt)
(defun is-current-line-empty ()
(interactive)
(setq c-line (thing-at-point 'line))
(string-match "^\s*$" (strip-text-properties c-line)))
```
What is the easiest way to check if current line is empty?
# Answer
> 27 votes
Would something like this be "easier"?
```
(defun current-line-empty-p ()
(save-excursion
(beginning-of-line)
(looking-at-p "[[:blank:]]*$")))
```
# Answer
> 12 votes
A simple method, close to what you have:
```
(defun current-line-empty-p ()
(string-match-p "\\`\\s-*$" (thing-at-point 'line)))
```
# Answer
> 5 votes
```
(defun blank-line-p (&optional pos)
"Returns `t' if line (optionally, line at POS) is empty or
composed only of whitespace."
(save-excursion
(goto-char (or pos (point)))
(beginning-of-line)
(= (point-at-eol)
(progn (skip-syntax-forward " ") (point)))))
```
# Answer
> 3 votes
`current-indentation` gives you the column following leading blanks, which can be compared against the column at the end of line:
```
(defun blank-line-p ()
(= (current-indentation)
(- (line-end-position) (line-beginning-position))))
```
# Answer
> 2 votes
Here is another simple solution for it, taken from `comment-dwim-2` package
```
(defun is-empty-line-p ()
(string-match-p "^[[:blank:]]*$"
(buffer-substring (line-beginning-position)
(line-end-position))))
```
# Answer
> 1 votes
I suggest:
```
(defun blank-line-p ()
(and (progn (skip-chars-backward " ") (bolp))
(progn (skip-chars-forward " ") (eolp))))
```
(Note that the `progn`s are in fact unnecessary because the skip functions never return nil). As Dan does in his answer, `skip-syntax-*` could also be used instead.
# Answer
> 1 votes
This is a modification of what PythonNut answered which did not work for me (why?):
```
(defun current-line-blank ()
(= 0 (string-match-p "^\\s-*$" (thing-at-point 'line))))
```
`string-match-p` returned the index of the next line whenever the current line wasn't blank. So I checked that the return value is 0.
---
Tags: whitespace
---
|
thread-37765
|
https://emacs.stackexchange.com/questions/37765
|
How to use org-drill to memorize org-drill?
|
2017-12-28T10:24:36.090
|
# Question
Title: How to use org-drill to memorize org-drill?
Say I want to memorize the cloze deletion syntax of org-drill by this topic,
The problem here is when the answer is revealed the text is only displayed partially like it's been interpreted as a cloze deletion.
Any tricks or suggestions on this kind of "meta" stuff ?
# Answer
> 2 votes
As I learn more about Org mode, I'm able to answer this question myself.
Org provides Latex-like syntax for special symbols. To make the example in question works, we could write the answer as
```
[answer\vert\vert{}optional hint]
```
or
```
[answer\vbar\vbar{}optional hint]
```
Curly braces are used to terminate a symbol. Before drill sessions, `(org-toggle-pretty-entities)` or `C-c C-x \` to render these notations into UTF-8 characters.
---
Tags: org-mode, org-drill
---
|
thread-52616
|
https://emacs.stackexchange.com/questions/52616
|
automatic indentation with space like visual studio
|
2019-09-11T06:11:53.203
|
# Question
Title: automatic indentation with space like visual studio
Is there any package that covers indentation with space like visual studio?
like,
```
if(a==b) ==> if(a<space>==<space>b)
for(int i=0;i<N;i++) ==> for(int i<space>=<space>0;<space>i<space><<space>N;<space>i++)
```
similar question is already asked but it was uploaded almost 2 years ago, then I re-ask it. (Automatically insert a space in some C expressions)
thank you in advance :-)
# Answer
> 2 votes
See electric-operator \- minor mode to automatically add spacing around operators
---
Tags: indentation, package, whitespace
---
|
thread-51712
|
https://emacs.stackexchange.com/questions/51712
|
Org-capture template with deadline of one month from today
|
2019-07-18T20:14:13.090
|
# Question
Title: Org-capture template with deadline of one month from today
As it seems, org-mode capture templates mechanism maybe have changed? I'm using:
Org mode version 9.2.4 (9.2.4-10-g3b006f-elpaplus)
What I'm trying to do is to have a capture template that will create a heading with a DEADLINE, it would prompt for a date, but would use +1m as a default date. So If I do something like this:
```
("s" "Someday" entry (file+headline "~/Dropbox/org/tasks.org" "Tasks")
"* TODO %?\nDEADLINE: %^t\n")
```
This works, but the calendar prompt appears with cursor on Today's date, I want it to be +1m, so if I press `RET` \- it will be a month from today. That possible, right?
# Answer
> 3 votes
You can check `org-insert-time-stamp` and `org-read-date`.
```
("s" "Someday" entry (file+headline "~/Dropbox/org/tasks.org" "Tasks")
"* TODO %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+1m\"))\n")
```
Edit: Having the template contain nested %( elements causes each to be evaluated and the result of the inner one is a list, but the engine expects a string or nil
---
Tags: org-mode, org-capture
---
|
thread-52629
|
https://emacs.stackexchange.com/questions/52629
|
is there a way to sort only on second level headlines in org mode?
|
2019-09-11T15:57:13.500
|
# Question
Title: is there a way to sort only on second level headlines in org mode?
is there a way to sort only on second level headlines in org mode?
i am outlining a novel with top level headline being the chapter number and the second level headline being the timeline of the events in that chapter starting with a number = YYYYMMDD. the top level headline starts with a number representing the chapter. i have made the top level headline chapters high numbers in a hundreds sequence for ease of interpolating new chapters later, e.g., adding a chapter between 200 and the next chapter, 300, only requires adding at the end of the outline the new chapter with a top level headline of 250 and then resorting numerically. the second level headline is a different (chronological) number since chapter 300 may be a flashback occurring earlier in time than, say, chapter 100.
(see examples below)
if i could have two different ways of sorting (by chapter and by timeline), i could visualize the narrative more easily as i progress.
i have done some searching online for a solution and have considered tags and properties and functions but although i have been using emacs for about 5 years now (mainly as a text editor with .txt and .org and .markdown) formats, i am a writer with no programming or coding skills.
example of sorting by chapters (top level headline):
```
* 100 stranger comes to town
** 20190911
* 200 stranger meets chanteuse
** 20190925
* 300 stranger tells chanteuse a childhood story
** 19900525
```
example of sorting by timeline (second level headline):
```
* 300 stranger tells chanteuse a childhood story
** 19900525
* 100 stranger comes to town
** 20190911
* 200 stranger meets chanteuse
** 20190925
```
thanks for any help. i am not committed to org mode. any help will be appreciated. i could do this via a spreadsheet or a database manager, i realize, and have done so in the past, but would like to stay with emacs, which i use as aquamacs on an apple laptop.
# Answer
As we have already discussed in the comments second level headings are probably the wrong structural means for an alternative sorting of the first level headings. There could be two subheadings 2.1, 2.2 below the second top-level heading 2. If the natural order of the subheadings is 2.1, 1.1, 2.2 the subheadings do not define an order-relation on the top-level headings. Thereby, your personal convention of only using one subheading per heading does not really play a big role. The ordering of the top-level headings w.r.t. the subheadings does not fit Org's structure. Therefore, you will have no special support for that purpose.
Org can sort headlines with respect to timestamps. That should perfectly fit your purpose.
Consider the following org file:
```
* 1
CLOCK: [2019-09-11 Wed]
Body of the first heading.
* 2
CLOCK: [2019-08-01 Thu]
Body of the second heading.
* 3
CLOCK: [2019-07-01 Mon]
Body of the third heading.
```
Select the whole file with `C-x h` and call `M-x` `org-sort` with choice `t` (standing for `[t]ime`) the file is modified as follows:
```
* 3
CLOCK: [2019-07-01 Mon]
Body of the third heading.
* 2
CLOCK: [2019-08-01 Thu]
Body of the second heading.
* 1
CLOCK: [2019-09-11 Wed]
Body of the first heading.
```
Side note: Trailing empty lines belong to the previous section. So if you have empty lines at the end of the file those move together with heading 3. Avoid such newlines to get a uniform appearance of the file sorted w.r.t. time.
> 3 votes
---
Tags: sorting
---
|
thread-50357
|
https://emacs.stackexchange.com/questions/50357
|
How to use Ansible layer in Spacemacs?
|
2019-05-05T20:32:23.833
|
# Question
Title: How to use Ansible layer in Spacemacs?
How to use Ansible layer in Spacemacs?
---
I am trying to understand how to write Ansible roles and test them using this layer. I added `ansible` to `dotspacemacs-configuration-layers`, restarted Spacemacs and checked *Messages* to see what is loaded.
```
Loading /home/anatoli/.emacs.d/layers/+tools/ansible/packages.el (source)...done
Loading /home/anatoli/.emacs.d/layers/+tools/ansible/layers.el (source)...
Loading /home/anatoli/.emacs.d/layers/+lang/yaml/packages.el (source)...done
Loading /home/anatoli/.emacs.d/layers/+tools/ansible/layers.el (source)...done
...
Loading /home/anatoli/.emacs.d/layers/+tools/ansible/funcs.el (source)...done
...
Loading /home/anatoli/.emacs.d/layers/+tools/ansible/config.el (source)...done
```
I still don't see anything. `SPC m h a` from documentation doesn't work - resulting in `SPC m is undefined`. Spacemacs shows `/YAML\` at the bottom near the filename. I don't see that Spacemacs detected YAML file as an Ansible playbook - I don't get any hints or errors displayed on the screen. Perhaps I need to change mode from YAML to Ansible somehow. If so - how do I do this?
# Answer
> 2 votes
For the Ansible layer to take action, your buffer filename must match one of `main.yml`, `site.yml`, `roles/.+\.yml`, `group_vars/.+`, *etc.* See the regex at the bottom of ansible/config.el (`v0.200.13`) for exact patterns.
**EDIT:** I added some additional paths to the regex above in PR #12726, which will go into Spacemacs `v0.300.x`.
In Emacs, you can manually enable `ansible-doc-mode` for the current buffer with `M-x ansible-doc-mode RET`. You'd probably also want to enable the company back-end with `M-: (add-to-list 'company-backends 'company-ansible) RET`. Then use `M-x ansible RET` to toggle the Ansible minor mode, which provides syntax highlighting, completion, vault functions, etc.
Unfortunately, it's not a slam dunk to use Emacs *file variables* to enable this minor mode explicitly (for files that don't match the regex linked above); this is a separate conversation. See Specifying File Variables in the Emacs manual for more information. I use the following at the bottom of my files:
```
# Local Variables:
# eval: (ansible-doc-mode 1)
# eval: (add-to-list (quote company-backends) (quote company-ansible))
# eval: (ansible 1)
# End:
```
( P.S. Regarding your comment about *testing* Ansible roles with this Spacemacs layer, I don't think that is directly supported as a feature, but you could likely find ways to run test-kitchen or similar from Emacs. )
---
Tags: spacemacs
---
|
thread-52635
|
https://emacs.stackexchange.com/questions/52635
|
How to get all full path list by a folder name?
|
2019-09-12T11:01:58.297
|
# Question
Title: How to get all full path list by a folder name?
I want to get all the full path by a folder name called autoload, in my config i had split it like this file structure.
```
├── init.el
├── packs
│ ├── +completion
│ │ ├── ivy
│ │ │ ├── autoload
│ │ │ │ ├── evil.el
│ │ │ │ ├── hydras.el
│ │ │ │ └── ivy.el
│ │ │ └── config.el
│ ├── +editor
│ │ ├── fold
│ │ │ ├── autoload
│ │ │ │ ├── fold.el
│ │ │ │ └── hideshow.el
```
so i want get all autoload folders path list, this function will return a list like `("/User/xxxx/.emacs.d/packs/+completion/ivy/autoload/","/User/xxxx/.emacs.d/packs/+editor/fold/autoload/")`. thanks!
# Answer
> 2 votes
```
(cl-remove-if-not #'file-directory-p (directory-files-recursively "name-of-directory" "autoload" t))
```
`directory-files-recursively` seems not well-known for some reason. See Directories for a fuller explanation.
---
Tags: directory
---
|
thread-52310
|
https://emacs.stackexchange.com/questions/52310
|
Sending `C-c C-c` to the process window without swithcing to it
|
2019-08-23T19:33:45.180
|
# Question
Title: Sending `C-c C-c` to the process window without swithcing to it
In ESS mode, I sometimes send some code to the process buffer and want to cancel it using `C-c C-c`. Can I do this without actually switching to the process window from the script window?
# Answer
You'll need to write your own function for doing this.
You'll want to read up on the functions `get-buffer-process` and `signal-process` to learn about how to send the right signal to the ESS process.
Here is an example: An interactive function that sends a SIGINT to a buffer of your choosing.
You can modify this function to target whatever ESS buffer you want or keep it as is.
```
(defun interrupt-buffer-process (buffer)
"Send a SIGINT to BUFFERs process."
(interactive (list
(completing-read
"Buffer: "
(mapcar 'buffer-name (remove-if-not 'get-buffer-process (buffer-list))))))
(signal-process (get-buffer-process buffer) 'sigint))
```
> 5 votes
# Answer
You can do `M-x ess-interrupt`.
> 3 votes
# Answer
Sorry not sure how to paste this as a comment, this works for ESS:
```
(defun my-interrupt-ess-buffer-process ()
"Send a SIGINT to script's iESS process."
(interactive)
(signal-process (ess-get-process-buffer) 'sigint))
```
> 2 votes
---
Tags: window, ess, comint
---
|
thread-52166
|
https://emacs.stackexchange.com/questions/52166
|
Use magit to find out who wrote the line at point and when
|
2019-08-15T18:30:36.653
|
# Question
Title: Use magit to find out who wrote the line at point and when
Someone showed me how to do this with "ruby mine" but I don't use ruby mine so hoping emacs / magit can do this.
A file in a git repository is opened up in emacs. Point is at line 23, and you want to quickly find out some "extra info" about this line, such as, who authored this line of code, and when was it last touched upon by someone.
# Answer
> 2 votes
The activity you are describing is commonly called "blaming". Magit's manual contains a section about blaming.
The easiest way to show such information is to type `C-c M-g b` in a file-visiting buffer, but there are alternative approaches as described in the manual.
---
Tags: magit
---
|
thread-35105
|
https://emacs.stackexchange.com/questions/35105
|
How can I make occur's regexp matching case-sensitive?
|
2017-08-24T17:04:48.410
|
# Question
Title: How can I make occur's regexp matching case-sensitive?
By default, occur uses the passed regexp to match lines in a case-insensitive way. Is there a way to make this matching case-sensitive?
For example, if I run `M-x occur ^function RET`, occur will match lines that start with both `function` and `Function`. I want it to only match `function`.
For reference, this is how I am currently using occur to generate a "table of contents" for Perl and other languages:
```
(defun toc ()
"Show a 'Table of Contents' for the current file using occur"
(interactive)
(let (regexp)
(if (derived-mode-p 'cperl-mode) ;; for perl
(setq regexp "^\\(sub\\|has\\|=head1\\|requires\\) ")
(setq regexp "^function ")) ;; for everything else
(occur regexp)))
```
# Answer
By default `occur` searches are case-insensitive. To force them to be case sensitive, you need to set the variable `case-fold-search` to nil. Note that this is a buffer-local variable. If you set it for one buffer, it won't change it's value for other buffers.
In your function, adding the form `(case-fold-search nil)` to your `let` statement should work:
```
(defun toc ()
"Show a 'Table of Contents' for the current file using occur"
(interactive)
(let (regexp
(case-fold-search nil))
(if (derived-mode-p 'cperl-mode) ;; for perl
(setq regexp "^\\(sub\\|has\\|=head1\\|requires\\) ")
(setq regexp "^function ")) ;; for everything else
(occur regexp)))
```
> 4 votes
# Answer
You may (globally) toggle the behaviour with `M-x toggle-case-fold-search`. For more information see http://ergoemacs.org/emacs/elisp\_list\_matching\_lines.html (dunno why the emacs wiki is less comprehensive on this topic).
> 2 votes
---
Tags: occur
---
|
thread-14582
|
https://emacs.stackexchange.com/questions/14582
|
Syntax highlighting fails on clone-indirect-buffer-other-window
|
2015-08-08T13:21:04.287
|
# Question
Title: Syntax highlighting fails on clone-indirect-buffer-other-window
I normally use indirect buffers while I edit python code in python-mode, I create them by running `clone-indirect-buffer-other-window`. While the syntax highlighting of the main buffer looks just fine, sometimes it is wrong in the indirect one. Specifically, it seems like some closing quotes are ignored adn so big chunks of my code are coloured as if they were part of long literal string.
I have not found references of this elsewhere, and have not clue why it could be happening. Does anybody know why this is and/or how to solve it?
This question could be related, be he does not mention indirect buffers (I only have this problem with those), and also my indirect buffer do **not** refresh to proper syntax highlighting even if a wait several minutes.
# Answer
You can try Just Another Cloning package.
**Installation:** Put `jac.el` into any directory from your `load-path` and put
```
(autoload 'jac "jac")
```
into your init file.
**Usage:** With the buffer you want to clone type `M-x` `jac` `RET`.
It copies the buffer content of the original buffer and synchronizes text modifications of both buffers but does not touch text properties. That way fontlock can do its work in both buffers independently. That makes different major modes inclusively highlighting possible.
Maybe, it also avoids the bug with the highlighting of different regions of a phyton file. (Just try it.)
> 1 votes
# Answer
Indirect buffers suck. They may look like "just what I need", but it's *very* rarely the case, and then sooner or later you bump into problems. IOW, I think they are an *attractive nuisance*.
I recommend you try and figure out why you want to use indirect-buffers and then try to look for other ways to get the same result.
E.g. you say:
```
indirect buffers are more useful if I want to keep two fixed places
of a long buffer open after switching my windows to other buffers
```
There are many other ways which are a lot less intrusive than using indirect buffers. E.g. using *registers*, *bookmarks*, or maybe with a package which tries to remember which *point* was used for your buffers individually in each window. E.g. in Emacs's master branch we have now enabled `switch-to-buffer-preserve-window-point` by default, which should provide some of the behavior you were looking for via indirect buffers.
> 0 votes
---
Tags: python, syntax-highlighting, indirect-buffers
---
|
thread-44565
|
https://emacs.stackexchange.com/questions/44565
|
Track arbitrary progress in Org-mode
|
2018-09-05T16:10:46.597
|
# Question
Title: Track arbitrary progress in Org-mode
If I'm reading a book, that has 500 pages, and I'm in the page 253. I want to track that progress in Org-mode as %, is there a way to do it that is already built in (or, if is not the case, is there a plugin that allows what I want)?
Currently the ways to track progress that I know are by number of tasks done in a subtree. But in this case I won't create a task for each page, that wouln't be efficient.
# Answer
You can try to make a spreadsheet like this
```
| Book | Page | Current | Percentage |
|-----------+------+---------+------------|
| This Book | 500 | 233 | 47 |
#+TBLFM: $4=round($3*100/$2)
```
The 'Percentage' column is calculated automatically when you input new data, then press 'C-c \*' to apply the formula.
> 2 votes
---
Tags: org-mode
---
|
thread-17965
|
https://emacs.stackexchange.com/questions/17965
|
Company mode popup closes after C-n
|
2015-11-09T23:01:38.423
|
# Question
Title: Company mode popup closes after C-n
Company-mode gives me a popup with options, but once I press C-n to navigate through the options, the popup disappears (I can still cycle through the options , but they are shown inline). I want the popup to remain open until I make my selection. Is this a customizable behavior (for instance, this screencast shows a company-mode popup which remains open while he cycles through values)?
Could some other mode be interfering and closing the popup (e.g., evil-mode)? How would I go about debugging that (I'm new to emacs)? Thanks!
# Answer
> 11 votes
`company-mode` does not rebind `C-n` or `C-p` probably to minimize interference with normal editing commands. To cycle through options, Company uses `up`, `down`, `M-n`, and `M-p` by default.
Use `C-h f` `company-mode` to peruse the mode specific documentation for Company. It will show the available bindings for the company popup when it is active.
However if you do want `C-n` and `C-p` in addition to the existing bindings the following elisp should help.
```
(define-key company-active-map (kbd "C-n") 'company-select-next-or-abort)
(define-key company-active-map (kbd "C-p") 'company-select-previous-or-abort)
```
# Answer
> 3 votes
With `use-package`, this becomes:
```
(use-package company
:hook
(after-init . global-company-mode)
:bind (:map company-active-map
("C-n" . company-select-next-or-abort)
("C-p" . company-select-previous-or-abort)))
```
---
Tags: company-mode
---
|
thread-52653
|
https://emacs.stackexchange.com/questions/52653
|
In gui, font looks thicker than usual
|
2019-09-14T07:00:11.580
|
# Question
Title: In gui, font looks thicker than usual
I started using Emacs a few days ago and facing the problem. I use "M+ 1mn" for programming so I set this for Emacs. But It looks thicker than usual.(in Geany, VSCode, Xfce Terminal ...)
How do I fix that?
Relevant part from init.el
```
(when (member "M+ 1mn" (font-family-list))
(add-to-list 'default-frame-alist '(font . "M+ 1mn-12")))
```
https://pastebin.com/4ducG3PH This is my init.el.
Left is Emacs and right is Neovim with Alacritty.
* Version: 26.3
* OS: ArchLinux (kernel: 4.19.72-1-lts)
* WM: i3wm
# Answer
> 2 votes
I found a .el file for M+ 1mn in Gist. https://gist.github.com/makotoy/3929218
And changed my init.el like
```
;;(when (member "M+ 1mn" (font-family-list))
;; (add-to-list 'default-frame-alist '(font . "M+ 1mn-12")))
(create-fontset-from-ascii-font "M+ 1mn:pixelsize=16:weight=normal:slant=normal:spacing=m" nil "mplus1mn")
(set-fontset-font "fontset-mplus1mn" 'unicode
(font-spec :family "M+ 1mn" :spacing 'm :size 16)
nil 'prepend)
(add-to-list 'default-frame-alist '(font . "fontset-mplus1mn"))
```
(I changed the size because I found that 12 is too small for me)
now It looks same to other application.
Thank you.
---
Tags: init-file, fonts
---
|
thread-41830
|
https://emacs.stackexchange.com/questions/41830
|
Shell mode: moving through the command history
|
2018-06-04T05:37:10.190
|
# Question
Title: Shell mode: moving through the command history
In a shell in a terminal (`Gnome Terminal` \+ `bash`), the up and down keys allow me to browse through my command history.
In `shell-mode` inside `emacs`, the up and down keys move around the buffer, which is bit strange (but I admit can be useful in order to copy-paste parts of the buffer).
How can I browse the command history in `shell-mode`?
# Answer
`M-p` and `M-n` let you navigate through the shell history. You can try `C-up` and `C-down` too.
There are other ways, as explained in Shell History on the manual.
> 3 votes
# Answer
Note `C-up` and `C-down` will not work on Mac OSX. And for those of you who use OSX at home and Linux (e.g. Debian, Ubuntu, CentOS) at work, you will want some degree of consistency in your Emacs. Consequently, `M-p` is the better choice. Note `M-p` will take you up to the previous command in history in the Emacs shell. But what if you want to search for a command in history? You would use:
```
M-r
```
You will receive a prompt in the shell (not the mini buffer) that says:
```
Regexp history I-search backward
```
Begin typing and it will invoke previous commands you use. Press ENTER to select the desired command in the history buffer.
> 0 votes
---
Tags: shell-mode, history
---
|
thread-52656
|
https://emacs.stackexchange.com/questions/52656
|
How can I make emacsclient use an existing window in the current frame?
|
2019-09-14T18:25:55.020
|
# Question
Title: How can I make emacsclient use an existing window in the current frame?
I'm on MS Windows, if that makes a difference.
My desired behavior:
1. There is only *one* frame visible at any time.
2. Visiting a file should use an existing window in that frame.
(This is the default behavior for Notepad++ as well as most browsers, though with tabs instead of buffers.)
To accomplish this using Emacs' client-server mode, I have this in my `.emacs`:
```
(require 'server)
(unless (server-running-p) (server-start))
```
And I have an *Edit with Emacs* context menu item that uses a registry key with this value:
`"C:\Users\FriendOfFred\emacs-26.2-x86_64\bin\emacsclientw.exe" "%1"`
That worked fine yesterday. Today, after a system restart, `emacsclientw` opens a new frame whenever I open a file from Windows Explorer or the command line, along with a message about the desktop file already being in use.
Last time I had an issue like this, as I recall, it was because the desktop file was too old, and restarting Emacs refreshed it. That doesn't seem to be the issue now.
What are some other possible causes of this issue? How can I figure out what's going on?
# Answer
> along with a message about the desktop file already being in use
Emacsclient does not attempt to process the desktop file, so you are clearly starting a *new* instance of Emacs.
If `emacsclient` can't connect to the server, but you either passed it `-a ''` or `--alternate-editor=''` or else have the `ALTERNATE_EDITOR` environment variable set to an empty string, then it would try to start a new server and connect to that; so this is a potential explanation.
> 1 votes
---
Tags: window, debugging, microsoft-windows, frames, emacsclient
---
|
thread-15228
|
https://emacs.stackexchange.com/questions/15228
|
org-mode table exports centered - change to left?
|
2015-09-01T02:48:31.017
|
# Question
Title: org-mode table exports centered - change to left?
I'm exporting a simple org-table through LaTeX to PDF:
```
| a | b | c |
| 1 | 2 | 3 |
```
After export with `C-c C-e l o` the PDF contains a centered table, and I'd rather have it on the left (to be clear, I'm referring here to the *table as a whole*, not the positioning of elements in individual cells).
I'm not an expert at LaTeX. I've looked at `:float` and `:placement` in the Org manual here and haven't been able to affect the outcome. How could I accomplish this?
# Answer
`#+ATTR_LaTeX: :center nil` will cancel centering (by default LaTeX tables inherit alignment from the document)
This is how the table would be exported with default settings:
```
\begin{center}
\begin{tabular}{rrr}
a & b & c\\
1 & 2 & 3\\
\end{tabular}
\end{center}
```
This is how it would be exported without centering:
```
\begin{tabular}{rrr}
a & b & c\\
1 & 2 & 3\\
\end{tabular}
```
If you need to move it even further to the left, you could add
```
#+BEGIN_LaTeX
\hspace{-3cm}
#+END_LaTeX
```
before the table.
> 9 votes
# Answer
To make it global, applied to all tables, you can also customize this variable
`M-x``customize-variable``org-latex-tables-centered`
and look into *options \> customize emacs \> specific group \> org-export-latex* for more.
> 1 votes
---
Tags: org-export, org-table
---
|
thread-20476
|
https://emacs.stackexchange.com/questions/20476
|
Line number (linum, nlinum) grow margin with increase in font size
|
2016-02-21T19:21:46.383
|
# Question
Title: Line number (linum, nlinum) grow margin with increase in font size
When I turn on `linum-mode` or `nlinum-mode`and increase the font size via `C-x C-+` it does not increase the size of the "margin" where the line number is displayed, so only part of the line number is visible. Is there a way to configure either of these modes so that the entire line number is always visible regardless of font size? Tested using emacs 24.5 on OS X and emacs 24.3.1 on ubuntu 14.04
# Answer
> 2 votes
This is what I put in my `init.el` file to fix the problem. It's a hack, at some sizes the left margin is a bit off but so far this is the best solution I've found to this problem.
```
(defun adjust-left-margin-hook ()
(let ((new-margin (+ 1 text-scale-mode-amount)))
(setq left-margin-width (if (< new-margin 0) 0 new-margin))
(set-window-buffer nil (current-buffer))))
(add-hook 'linum-before-numbering-hook 'adjust-left-margin-hook)
(add-hook 'text-scale-mode-hook 'adjust-left-margin-hook)
```
The function `adjust-left-margin-hook` performs the following commands:
* sets `new-margin` to 1 more than the current `text-scale-mode-amount`
* sets `left-margin-width` to `new-margin` (or 0 if it's below the minimum). You can play around with this variable to adjust based on your preferences but take note, that `left-margin-width` must be a positive integer
* redisplays the buffer so the margin width changes are applied
Then the two hooks are there for the function to be called whenever the left margin needs to be adjusted. That is, before the linum or nlinum packages start numbering the lines or whenever you change the scale of the text manually.
My Emacs version is 27.0.50, but it should work on earlier versions starting from 23 as well.
---
Tags: linum-mode
---
|
thread-52666
|
https://emacs.stackexchange.com/questions/52666
|
How do you automatically enable writeoom-mode when org-mode starts?
|
2019-09-15T15:04:52.367
|
# Question
Title: How do you automatically enable writeoom-mode when org-mode starts?
I want to enable writeroom-mode whenever I startup org-mode because I don't really ever want writeroom-mode to be disabled if I'm using org-mode.
# Answer
If you're using `use-package` just add the following to your`~/.emacs` file:
```
(use-package writeroom-mode
:ensure t
:init (add-hook 'org-mode-hook 'writeroom-mode)
:after org)
```
If you're not using `use-package` then just put the following line somewhere in your `~/.emacs` file:
```
(add-hook 'org-mode-hook 'writeroom-mode)
```
> 2 votes
---
Tags: org-mode, major-mode, minor-mode, writing
---
|
thread-52638
|
https://emacs.stackexchange.com/questions/52638
|
Trouble binding C-return: C- must prefix a single character
|
2019-09-12T15:40:12.647
|
# Question
Title: Trouble binding C-return: C- must prefix a single character
This is what I have:
```
(add-hook 'magit-status-mode-hook
(lambda ()
(local-set-key (kbd "<C-return>") 'magit-diff-visit-file-other-window)))
```
Opening a magit-status buffer fails with "C- must prefix a single character, not return".
There are several related questions, but their solutions (for example moving the `<>` around `return` instead of the whole string) don't work. Using `RET` instead of `return` doesn't work either.
Emacs 26.1
# Answer
> 3 votes
In the comments we established that the problem wasn't the code shown in the question:
```
(add-hook 'magit-status-mode-hook
(lambda ()
(local-set-key (kbd "<C-return>") 'magit-diff-visit-file-other-window)))
```
The problem was the use of this pattern:
```
(add-hook 'HOOK (lambda ...))
```
When that pattern is used, updating the code of that `(lambda...)` function necessitates explicitly *removing the original/bad lambda from the hook variable* before adding a new updated version -- otherwise *both* functions will be called when the hook runs.
So the problem was that an earlier attempt (with a bad key binding syntax) was still being executed.
Inspecting `C-h``v` `magit-status-mode-hook` showed that the old lambda was still present.
---
The better pattern is:
```
(add-hook 'magit-status-mode-hook 'my-magit-status-mode-hook)
(defun my-magit-status-mode-hook ()
"Custom `magit-status-mode' behaviours."
(local-set-key (kbd "<C-return>") 'magit-diff-visit-file-other-window))
```
As the named function can subsequently be updated without also needing to touch the hook variable.
# Answer
> 1 votes
I had this issue as well when I was trying to use `C-<return>` for another command in elpy. I managed to resolve it by first looking up the global key binding for `C-<return>` (try `C-h k` then type `C-<return>` to see what Emacs thinks is assigned to that key). In my situation, `C-<return>` was bound to CUA mode.
Then go into your configuration file and first set that binding to `nil`. In my situation, it looked like this:
```
;; Add keybindings for python that override CUA mode rect
(define-key cua-global-keymap [C-return] nil)
(global-set-key (kbd "C-RET") 'elpy-shell-send-statement-and-step)
```
---
Tags: key-bindings, keymap
---
|
thread-13489
|
https://emacs.stackexchange.com/questions/13489
|
How do I get Emacs to recognize my python 3 virtual environment
|
2015-06-27T15:43:27.467
|
# Question
Title: How do I get Emacs to recognize my python 3 virtual environment
My system is macOS and I have both python 2 and 3 installed. I am currently working on a side project for which I want to use Django 1.8 and python 3.4.
I have created a virtual environment with the python 3 command `pyvenv venv` in the parent folder of my project (I prefer to have my python project folders to be self contained).
At the moment, I cannot get Emacs to recognise and therefore limit all code related assist to the virtual environment.
In addition, is it possible to setup per-project settings such that I can have different projects use different python versions and environment? The ideal scenario will be, when I change into a project directory and start Emacs, it will pick all it's environment settings from that project directory according to some local settings file.
# Answer
There is a package called pyvenv to manage virtual environmnets in emacs. Try installing it with
```
`M-x package-install RET pyvenv RET`
```
Now You to activate env in your emacs, You can run
```
M-x pyvenv-activate RET <path-to-venv>
```
Checkout: https://github.com/jorgenschaefer/pyvenv
For per project management, You can use hooks to activate venv automatically.
> 9 votes
# Answer
I am using https://github.com/jorgenschaefer/pyvenv as well, and I set it up like so:
```
(use-package pyvenv
:ensure t
:config
(pyvenv-mode 1))
```
This `pyvenv-mode 1` part is essential. This will automatically make the venv activate when the variable pyvenv-activate is changed.
So, now leverage `.dir-locals.el` to set that for my projects.
```
((nil . ((pyvenv-activate . "~/repos/my_proj/.venv"))))
```
Now when I open a file in my project, that virtual environment is activated!
> 5 votes
---
Tags: python
---
|
thread-26565
|
https://emacs.stackexchange.com/questions/26565
|
Exiting emacs without confirmation to kill running processes
|
2016-08-25T09:42:06.143
|
# Question
Title: Exiting emacs without confirmation to kill running processes
It turned out not to be the same problem as Kill process buffer without confirmation?: emacs asks for different kind of confirmations when exiting and when just killing a buffer.
How to specify for all or specific processes (e.g. one launched with `run-scheme`) to be killed without confirmation on exiting emacs?
# Answer
Following my own suggestion (second comment on the question), here's an answer which avoids the prompting altogether:
```
(require 'auto-answer)
(let ((auto-answer '(("\\`Active processes exist; kill them and exit anyway\\? \\'" t))))
(save-buffers-kill-emacs))
```
This uses `auto-answer.el`, available at https://github.com/YoungFrog/auto-answer/blob/master/auto-answer.el (it requires dash.el from your favourite package store, and nadvice.el which is available at least in 24.4).
**Edit:** If you only want to avoid the prompt for *some* (specific) processes, the documented way to do it is to set its query-on-exit flag to `nil` using `set-process-query-on-exit-flag` when creating the process.
> 4 votes
# Answer
Emacs 26.1 added the `confirm-kill-processes` variable. To disable confirmation to kill processes on Emacs exit, add to your init file:
```
(setq confirm-kill-processes nil)
```
Documentation:
> Non-nil if Emacs should confirm killing processes on exit. If this variable is nil, the value of `process-query-on-exit-flag` is ignored. Otherwise, if there are processes with a non-nil `process-query-on-exit-flag`, Emacs will prompt the user before killing them.
> 11 votes
---
Tags: process, exit
---
|
thread-52680
|
https://emacs.stackexchange.com/questions/52680
|
In MacOS, is there any way to have native Mac layout for ‘option-something’ special symbols in quoted-insert?
|
2019-09-16T12:39:55.823
|
# Question
Title: In MacOS, is there any way to have native Mac layout for ‘option-something’ special symbols in quoted-insert?
With `quoted-insert` (`C-q`) I can enter ‘Option-something’ extended characters, but Emacs apparently understands them as ISO 8859-1. Meanwhile, MacOS has its own layout for these characters (changed with the input language or custom layouts), and there's a cheatsheet in the form of ‘Keyboard viewer.’
Is there any way to make Emacs use the same layout for `M-something` in `quoted-insert` as native applications do?
I could conceivably edit a keymap by hand to reflect the system one, but 1) I don't see a mention of a special keymap for `quoted-insert`, and 2) I'd prefer not to.
Apparently Emacs does receive native characters if `Option` keys aren't set up as `Meta`, however I don't have an abundance of modifier keys on my keyboard so I'd prefer to keep `Option` as `Meta` and use `quoted-insert` when needed.
# Answer
As I learned that Emacs enters native special symbols if Option isn't mapped to Meta, I went ahead and made a wrapper for `quoted-insert` that does the unmapping:
```
(defun my/quoted-insert-wrapper (arg)
"For quoted-insert, unmap Option from Meta so special symbols can be entered with the native Mac layout"
(interactive "*p")
(let ((mac-option-modifier 'none))
(quoted-insert arg)))
;;; this should work for non-Evil setups, but haven't tested it
;; (global-set-key (kbd "C-v") #'my/quoted-insert-wrapper)
(define-key evil-insert-state-map (kbd "C-v") #'my/quoted-insert-wrapper)
```
Works like a charm so far, even for diacritic modifiers. Users of non-Latin layouts will probably also want to add a mapping for keys in their language on the same location as Latin `C-v`.
However, I'm not sure whether hijacking the option with `let` would work if lexical binding is enabled—but that's a different issue. Presumably I still could `setq` the option and then revert it after `quoted-insert`.
> 1 votes
---
Tags: keyboard-layout
---
|
thread-52669
|
https://emacs.stackexchange.com/questions/52669
|
In markdown-mode cursor goes to beginning of line when I type certain characters
|
2019-09-15T19:05:46.863
|
# Question
Title: In markdown-mode cursor goes to beginning of line when I type certain characters
In markdown-mode the cursor goes to the beginning of a line whenever I type any of `(),[]{};:`, this happens in both GUI and command-line emacs, this only happens in markdown-mode.
How do I stop this from happening?
Emacs version: GNU Emacs 26.1
# Answer
> 1 votes
The problem was a line in my init file that was loading funda-haxe-mode
---
Tags: markdown, markdown-mode
---
|
thread-52048
|
https://emacs.stackexchange.com/questions/52048
|
Drop rows with zero time in org-mode agenda clockreport
|
2019-08-07T19:25:36.793
|
# Question
Title: Drop rows with zero time in org-mode agenda clockreport
I recently found `org-agenda-clockreport`. Because I keep all my `.org` files in a single directory (indexed by `deft`), including files with notes and no tasks, I get a table with tens of rows, with only one or two that have any time logged. Is there any way to drop any rows in the clockreport that have zero time?
# Answer
I found the answer by searching for variables with "agenda" and "clock" and "report" using Helm.
The variable `org-agenda-clockreport-parameter-plist` can be modified with the following key/value pairs:
```
:stepskip0 t
:fileskip0 t
```
I modified the variable using Emacs' customize screen, but then I moved it from custom.el to my own init.el, and this works for me:
```
(setq org-agenda-clockreport-parameter-plist '(:stepskip0 t :link t :maxlevel 2 :fileskip0 t))
```
The other two keys (`:link` and `:maxlevel`) were already set in `org-agenda-clockreport-parameter-plist`. You may wish to modify only the keys `:setpskip0` and `:fileskip0` but I don't know how to do that in Emacs lisp (yet) :)
If you have clock reports *outside* of the agenda, the same parameters work. For example:
```
#+BEGIN: clocktable :scope agenda :maxlevel 3 :block today :stepskip0 t :fileskip0 t :link t
#+END
```
Press Ctrl-C Ctrl-C on the above code block to get a clock report outside of the agenda.
See section 8.4.2 "The Clock Table" in Org-mode's info section: https://www.gnu.org/software/emacs/manual/html\_node/org/The-clock-table.html
```
:stepskip0’
When non-‘nil’, do not show steps that have zero time.
:fileskip0’
When non-‘nil’, do not show table sections from files which did not
contribute.
```
Thanks, --Nate
> 3 votes
---
Tags: org-mode, org-agenda
---
|
thread-1
|
https://emacs.stackexchange.com/questions/1
|
Are there any advantages to using ~/.emacs.d/init.el instead of ~/.emacs?
|
2014-09-23T18:18:10.547
|
# Question
Title: Are there any advantages to using ~/.emacs.d/init.el instead of ~/.emacs?
I've normally used `~/.emacs` for my config file, but I've noticed others using `~/.emacs.d/init.el`. Are there advantages to the `init.el` location? Any disadvantages?
# Answer
> 116 votes
Yes, there are. Quoting lunaryorn on Reddit:
> * It keeps the `$HOME` directory uncluttered, because all of Emacs' files are neatly contained in a single directory. For the same reason, all modern Emacs packages write their caches, histories, etc. into `~/.emacs.d/`.
> * It makes version control easier, especially if you split your init.el into different files in `~/.emacs.d`. You can just commit `init.el` like every other file, and `git clone /my/emacs/config.git ~/.emacs.d` on a new system gives you all of your Emacs configuration, without having to link a file into `$HOME`.
# Answer
> 39 votes
One additional advantage: if everything is in `.emacs.d`, you can keep your Emacs configuration on Dropbox (or an alternative) and symlink the whole configuration to your home directory. That makes syncing across computers trivial.
# Answer
> 25 votes
If all you need to set up Emacs the way you like is an init file, it doesn't make a difference if it's `~/.emacs` or `~/.emacs.d/init.el`. But it makes sense to create a directory the moment you start splitting your init file, or adding Emacs-related configs, a Cask file for example. Also, it's the place where you'll save the file with abbrev definitions, the file for custom options (`M-x customize`), etc.
Keep everything neatly tucked in `~/.emacs.d`.
# Answer
> 10 votes
Emacs 27 will introduce a new initialisation file `early-init-file` under `user-emacs-directory`, namely at `~/.emacs.d/early-init.el`. So a further benefit to using `~/.emacs.d/init.el` instead of `~/.emacs` for `user-init-file` is that the former will place both initialisation files under the same roof, for consistency.
Until Emacs 27 is released, you can find the documentation for this new feature in the following files of the Emacs source tree:
# Answer
> 3 votes
Not sure if this really makes a difference in terms of speed, but you can byte-compile your setup more easily if your configuration is in `.emacs.d/init.el`(i.e. create `.emacs.d/init.elc`)
# Answer
> 3 votes
You use `~/.emacs.d/init.el` and just symlink that file to `~/.emacs`, just in case some other programs / plugins expect to find .emacs.
On a macOS or GNU/Linux system, the command would be:
```
ln -s ~/.emacs.d/init.el ~/.emacs
```
This way you get all the benefits of VC of your `~/emacs.d` directory structure and you'll be able to use a shorter name when you need to edit the init.el file through `~/.emacs` instead of typing `~/emacs.d/init.el`
---
Tags: init-file
---
|
thread-32693
|
https://emacs.stackexchange.com/questions/32693
|
How do I page when "ESC - (1 of n) [C-h paging/help]" shows in the emacs status bar?
|
2017-05-09T20:07:57.443
|
# Question
Title: How do I page when "ESC - (1 of n) [C-h paging/help]" shows in the emacs status bar?
I am an Emacs newbie having some problems navigating around when using the terminal, but pressing the `ESC` key brings up a huge list of key options which gives me the option of paging down and possibly select the right one, but any key I press seems to do the wrong thing.
I have 2 questions
1. How can I page down through the options?
2. For the option such as `M-(` I can effect them simply by pressing the key after the dash eg `(`, but how can I effect those preceded with the `C-`, eg `C-M-\`? What does the `C-M` mean?
Because I am using Spacemacs I assume that Spacemacs cannot capture the `SPC` key as the terminal requires. Is the menu with this menu with `C-M-` and they `M-` the standard Emacs menu/keybinding?
PS. What is the proper name of the area the menu is displayed?
# Answer
What you're looking at is the Emacs notation for describing keybindings. A key binding like `C-x` means "hold down control and press x", and `M-x` means "hold down meta and press x". Of course, modern keyboards don't actually have a meta key, so we use alt instead. Additionally, keybindings that use meta can also be activated with escape. Thus `M-x` can also be activated by first pressing escape, and then pressing x.
I don't use Spacemacs, so I've never seen this particular menu. It seems pretty straight forward though. It only comes up when you hit escape, and then don't go on to finish the sequence, so it's just just showing you what's available. You can activate the `M-(` option by just typing `(`, because you've already typed the "meta". Thus it seems reasonable that you would be able to activate `C-M-\` by just typing `C-\`. You could also have typed it by holding down both control and alt, then pressing the `\` key.
`C-h` is the key used for all help functions. On it's own it's another prefix key like escape, you press `C-h` and then some other key or key combination to activate various help functions. For example, `C-h i` brings up the Info system, which lets you view a large set of hypertext manuals about Emacs and related subjects. In this case, it's being used as a context-sensitive command to bring up help about the menu itself. Likely that help will include instructions for scrolling the menu, amongst other things.
> -1 votes
# Answer
I had this same problem and asked for help in Github.
https://github.com/syl20bnr/spacemacs/issues/10509#issuecomment-376314380
I was able to narrow the problem to my terminal software, I couldn't press `C-h` which usually is `Ctrl-h`
To see if you have the same problem, press `SPC h d k` and then press `C-h` (Ctrl-h) and see what pops up, it should describe `C-h`, if it doesn't, it means something is interfering with your ability to press `C-h`.
If `C-h` your works, to scroll/page it's simply `C-h n`.
> 1 votes
# Answer
Since this question was from a Spacemacs user, I assume it is using the `which-key` package. `C-h n` and `C-h p` for paging does work in this case for getting the next key entries and the previous ones, respectively.
The user is asking specifically how to page when the prefix key used is `ESC`. In this case `C-h` might do something else. In my case, for example,
```
C-M-h (translated from <escape> C-h) runs the command mark-defun
```
so there is no way to run `C-h p` and `C-h n` for paging.
The `which-key` readme does specify a method to change (or add?!) a prefix key besides or in place of `C-h` \[1\], specifically for the cases like the above (the `ESC` prefix).
> **Method 2: Bind your own keys**
>
> Essentially, all you need to do for a prefix like C-x is the following which will bind to the relevant command.
>
> (`define-key which-key-mode-map (kbd "C-x <f5>") which-key-C-h-dispatch)`
>
> This is completely equivalent to
>
> `(setq which-key-paging-prefixes '("C-x"))` `(setq which-key-paging-key> "<f5>")`
>
> where the latter are provided for convenience if you have a lot of prefixes.
Unfortunately, I could not make it work. It rebinds `C-x` in the global map making Emacs unusable.
I'll leave this here as a pseudo-answer for future me or for anyone who can figure it out and provide a better answer than the current ones.
\[1\] https://github.com/justbur/emacs-which-key#paging-options
> 0 votes
---
Tags: key-bindings, spacemacs, term, multi-term, menus
---
|
thread-52662
|
https://emacs.stackexchange.com/questions/52662
|
company-mode doesn't work on latex environment
|
2019-09-15T02:54:05.897
|
# Question
Title: company-mode doesn't work on latex environment
I've installed the company package in order to get an auto-completion functionality. It works well in my ESS environment, but no in latex. In fact, no completions are showed in latex buffers when I activate `M-x company-mode`. What could be the problem?
Here it is my `.emacs` config for latex
```
(setq TeX-parse-self t)
(setq-default TeX-master nil)
;;
;;ispell config
;;
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "es_ES") ;; Change dictionaries here!
(setq ispell-local-dictionary-alist
'(("es_ES" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil nil nil utf-8)))
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)
(setq TeX-output-view-style
(quote
(("^pdf$" "." "evince -f %o")
("^html?$" "." "iceweasel %o"))))
```
UPDATE:
Removing auto complete configuration for other environments from the init file and adding the following line solves the problem.
```
;;
;; COMPANY
;;
(use-package company
:ensure t
:config
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 2)
(global-company-mode t)
)
```
# Answer
As an alternative, if you use lsp-mode (https://github.com/emacs-lsp/lsp-mode), there is recent support for LaTeX via the Digestif LaTeX language server (https://github.com/astoff/digestif).
> 1 votes
---
Tags: latex, auctex, company-mode
---
|
thread-52699
|
https://emacs.stackexchange.com/questions/52699
|
How to change what modeline displays, based on major mode?
|
2019-09-17T15:45:05.590
|
# Question
Title: How to change what modeline displays, based on major mode?
i know i can change what info to display in modeline in `mode-line-format` variable. But how to display `mode-line-position` for one mode, but not display it for another?
# Answer
> 1 votes
Use `(setq-local mode-line-position nil)` in the mode-hook.
Example:
```
(define-derived-mode my-mode nil "my") ;; Our playground.
(defun remove-mode-line-position () ;; That's the thing you actually need.
"Set `mode-line-position' buffer-locally to nil."
(setq-local mode-line-position nil))
(add-hook 'my-mode-hook #'remove-mode-line-position) ;; Usage example.
```
If you create a new buffer with `C-x b` `*mybuf*` `RET` and call `M-x` `my-mode` `RET` the position info in the modeline disappears for buffer `*mybuf*` but for no other buffer.
---
Tags: mode-line
---
|
thread-52706
|
https://emacs.stackexchange.com/questions/52706
|
Can magit pull hunks from another commit into my branch?
|
2019-09-17T19:19:01.610
|
# Question
Title: Can magit pull hunks from another commit into my branch?
I have a big commit on another git branch. I'd like to "cherry-pick" some hunks from that commit into my current branch. I bet magit can do that, but I'm not sure how. Anyone? (I've seen ways to cherry-pick whole commits, but I want to do it hunk by hunk.)
# Answer
Wow, it's almost too easy. Just go to the other commit in the log buffer, show it, and use "a" to apply each change to the current working dir.
> 5 votes
---
Tags: magit, git
---
|
thread-52708
|
https://emacs.stackexchange.com/questions/52708
|
how to enable pager like behavior in a shell buffer?
|
2019-09-17T19:54:18.510
|
# Question
Title: how to enable pager like behavior in a shell buffer?
I can't believe I'm saying this, but one thing that is "nice" about windows cmd is the pager. When I do `man grep` in a bash shell inside emacs buffer it spits out the entire content at once. Is there a way/mode to have emacs buffer to halt outputting text and ask if I want to see more.
Running `GNU Emacs 26.1 (build 1, x86_64-w64-mingw32) of 2018-05-30` on "ON NOOO! But can't run anything else" --\> Windows 10.
here is what I have for running a bash shell buffer.
```
;;git bash
(defun git-bash () (interactive)
(let ((explicit-shell-file-name "d:/Installed_progs/Git/bin/bash.exe"))
(call-interactively 'shell)
(setq explicit-bash.exe-args '("--noediting" "--login" "-i"))))
```
To make it more concrete, here is what I see if I run `man grep`
The command output filled the entire screen and keeps going until the end of the text.
Here is what I see when I run the same command in win cmd
Pages shows only what fits in one screen and waits. Is there any way to have that type of behavior in a bash shell in emacs?
# Answer
> 1 votes
If you are using EShell the following works: `man grep`: Add `"man"` to the list value of `eshell-visual-commands` and use `*man grep` instead of `man grep` at the command line of Eshell.
Background:
* The commands in `eshell-visual-commands` are started in `term-mode` which allows paging if the command does do that.
* `man` has an Eshell-own Elisp implementation `eshell/man` which calls the usual `man` command of Emacs. If an Elisp version of a command exists you can enforce calling the external command by prefixing it with a star. Therefore, you need to call `*man` instead of `man` in Eshell.
---
`git log`: Follow the instructions in the documentation of the variable `eshell-visual-subcommands`:
> An alist of the form
>
> ((COMMAND1 SUBCOMMAND1 SUBCOMMAND2...) (COMMAND2 SUBCOMMAND1 ...))
>
> of commands with subcommands that present their output in a visual fashion. A likely entry is
>
> ("git" "log" "diff" "show")
>
> because git shows logs and diffs using a pager by default.
---
Tags: buffers, shell
---
|
thread-52705
|
https://emacs.stackexchange.com/questions/52705
|
Can't view anything in org-agenda: Wrong number of arguments: (0 . 0), 2
|
2019-09-17T17:52:31.007
|
# Question
Title: Can't view anything in org-agenda: Wrong number of arguments: (0 . 0), 2
Whenever I try to view my org-agenda, I get a blank buffer with "Wrong number of arguments: (0 . 0), 2" in the minibuffer. I've followed dozens of tutorials and bug reports and nothing applies. Can anyone help me?
I'm using Emacs 26.2, with Spacemacs 0.200.13.x, with no org preferences in my .emacs or .spacemacs files. The issue is only present when running as Spacemacs, with plain Emacs it works fine.
I launch agenda with `M-x org-agenda-file-to-front`, then `M-x org-agenda a`. It launches an agenda buffer that begins populating, but errors as soon as it hits an actual TODO item.
# Answer
Adding the org layer to Spacemacs solved the issue, things work just fine now.
> 1 votes
---
Tags: org-mode, org-agenda
---
|
thread-52709
|
https://emacs.stackexchange.com/questions/52709
|
How to unpack a tuple from org-sbe evaluating a python code block into multiple columns of a org-table?
|
2019-09-17T22:46:40.857
|
# Question
Title: How to unpack a tuple from org-sbe evaluating a python code block into multiple columns of a org-table?
I often encounter situations where I can easily think of python code that, given some input values, computes multiple output values at once. As an example, consider the following simple code-block that converts the real and imaginary part (a and b) of a complex number to its polar representation (radius and phase). In an org-mode file I would write:
```
#+name: radius_phase_conv
#+begin_src python :exports none :var a=2. :var b=2.
from cmath import polar
from math import degrees
num = complex(a,b)
r, phi = polar(num)
phi_deg = degrees(phi)
return round(r,5), round(phi_deg,5)
#+end_src
#+RESULTS: radius_phase_conv
| 2.82843 | 45.0 |
```
Now I want to use such a code on a table in org-mode that contains the columns with the input values. In above example, we might have a table with a and b.
```
| a | b |
|--------+---------|
| 1 | 0 |
| 1 | 1 |
```
Putting the line
```
#+TBLFM: $3='(org-sbe "radius_phase_conv" (a $1) (b $2)
```
below the table, will produce a 3rd column that contains the tuples with the radius and the phase.
```
| a | b | |
|--------+---------+--------------------|
| 1 | 0 | (1.0 0.0) |
| 1 | 1 | (1.41421 45.0) |
#+TBLFM: $3='(org-sbe "radius_phase_conv" (a $1) (b $2))
```
How do I need to alter the `#+TBLFM:` \+ `org-sbe` statement in order to produce two columns in the final table, i.e. the desired result would be
```
| a | b | | |
|---+---+----------+-------|
| 1 | 0 | 1.0 | 0.0 |
| 1 | 1 | 1.41421 | 45.0 |
#+TBLFM: ???
```
# Answer
> 1 votes
How about breaking it into two functions and have
`$3='(org-sbe radius...)::$4='(org-sbe phase...)`
Or keeping one function but passing in a 3rd argument that tells it what value you want returned? Not ideal...
Or don't use `TBLFM`? What about calling `radius_phase_conv` and passing in the `a|b` table (after you `NAME` it), and then having Python print out the four-column table for you?
---
Tags: org-mode, python, org-table, literate-programming
---
|
thread-52697
|
https://emacs.stackexchange.com/questions/52697
|
Why does a let-bound huge list survive garbage collection after the let form?
|
2019-09-17T14:46:58.137
|
# Question
Title: Why does a let-bound huge list survive garbage collection after the let form?
Note that the following original test is errorneous and has been superseded by the EDITED version below.
```
(progn
(message "Before: %S" (memory-use-counts))
(let ((x (make-list 100000000 0)))
(message "Use: %S" (memory-use-counts)))
(message "Garbage Collect: %S" (garbage-collect))
(message "After: %S" (memory-use-counts)))
```
The message output after running the `progn` form is:
```
Before: (1974893 657 3944364 16613 2025974 923 92307)
Use: (101974903 658 3944364 16613 2026125 923 92310)
Garbage Collect: ((conses 16 100008801 10478) (symbols 48 2200 4) (strings 32 2545 1051) (string-bytes 1 82237) (vectors 16 3935) (vector-slots 8 69235 13732) (floats 8 11 12) (intervals 56 57 163) (buffers 992 7))
After: (101975693 659 3944734 16613 2029800 923 92506)
```
One clearly recognizes the huge list of 100000000 conses in the cons counter of the memory-use-counts.
Obviously the `garbage-collect` after the `let`-form does not free the memory for the conses of the huge list. **Why?**
`emacs-version`:
`GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-08-16`
and
`GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-04-12`
---
**EDIT**:
User legoscia was so kind notify me about an error in my test with his answer.
Nevertheless, we can correct the test (with some self-check at the end) and the result of the new test still acknowledges that the memory for the huge list is not freed:
```
(progn
(message "Before: %S" (garbage-collect))
(let ((x (make-list 100000000 0)))
(message "Use: %S" (garbage-collect)))
(message "After: %S" (garbage-collect))
(message "Let's check again: %S" (garbage-collect)))
```
The output of this test is:
```
Before: ((conses 16 8012 7551) (symbols 48 2200 4) (strings 32 2533 939) (string-bytes 1 82159) (vectors 16 3912) (vector-slots 8 68701 11716) (floats 8 10 8) (intervals 56 26 21) (buffers 992 7))
Use: ((conses 16 100008064 733) (symbols 48 2200 4) (strings 32 2558 914) (string-bytes 1 83293) (vectors 16 3913) (vector-slots 8 68847 11570) (floats 8 10 8) (intervals 56 26 21) (buffers 992 7))
After: ((conses 16 100008106 691) (symbols 48 2200 4) (strings 32 2559 913) (string-bytes 1 83491) (vectors 16 3913) (vector-slots 8 68847 11570) (floats 8 10 8) (intervals 56 26 21) (buffers 992 7))
Let’s check again: ((conses 16 100008062 735) (symbols 48 2200 4) (strings 32 2559 913) (string-bytes 1 83495) (vectors 16 3913) (vector-slots 8 68847 11570) (floats 8 10 8) (intervals 56 26 21) (buffers 992 7))
```
The doc string of `garbage-collect` says that the `(nth 2 (assq 'conses (garbage-collect))))` is the number of conses found live in memory. So, this time the test should be valid.
Relevant part of the doc string of `garbage-collect`:
> Reclaim storage for Lisp objects no longer needed. Garbage collection happens automatically if you cons more than `gc-cons-threshold` bytes of Lisp data since previous garbage collection. `garbage-collect` normally returns a list with info on amount of space in use, where each entry has the form (NAME SIZE USED FREE), where:
> \- NAME is a symbol describing the kind of objects this entry represents,
> \- SIZE is the number of bytes used by each one,
> \- USED is the number of those objects that were **found live in the heap**,
> \- FREE is the number of those objects that are not live but that Emacs
> keeps around for future allocations (maybe because it does not know how
> to return them to the OS).
# Answer
From the docstring of `memory-use-counts`, emphasis mine:
> Return a list of counters that measure how much consing there has been.
> Each of these counters increments for a certain kind of object.
> The counters wrap around from the largest positive integer to zero.
> **Garbage collection does not decrease them.**
So this is the expected output. I couldn't find any function that tells you how many cons cells are currently in use.
> 3 votes
---
Tags: let-binding, garbage-collect
---
|
thread-36706
|
https://emacs.stackexchange.com/questions/36706
|
How to force 'Ctrl-X, Ctrl-B' to always split vertically?
|
2017-11-08T08:38:02.603
|
# Question
Title: How to force 'Ctrl-X, Ctrl-B' to always split vertically?
Once upon a time, Choose Window (invoked by `C-x C-b`) used to always split the window vertically.
Starting from a certain Emacs version (I can't recall which one), that split is now either vertical or horizontal, depending on the containing windows **aspect ratio**.
Is there a way to force `C-x C-b` to always split vertically?
# Answer
> 2 votes
You can overwrite that keybinding with a hack like that:
```
(global-set-key (kbd "C-x C-b")
(lambda ()
(interactive)
(let ((display-buffer-overriding-action ;; force window
'((display-buffer-reuse-window
display-buffer-same-window)
(inhibit-same-window . nil))))
(split-window-horizontally) ;; split window
(other-window 1) ;; change it
(list-buffers))))
```
In general I prefer use `ibuffer` instead of `list-buffers`, but now is your call. Use whatever you think that is better :)
# Answer
> 0 votes
Credit - How to change the default split-screen direction?
The code below worked for me.
```
$ cat ~/.emacs
;;
;; https://stackoverflow.com/questions/7997590/how-to-change-the-default-split-screen-direction
;; C-x C-b
;; splits the window vertically
;;
;; Use (setq split-width-threshold nil) for vertical split.
;; Use (setq split-width-threshold 1 ) for horizontal split.
;; (setq split-width-threshold 1 )
(setq split-width-threshold nil)
```
---
Tags: window-splitting
---
|
thread-52724
|
https://emacs.stackexchange.com/questions/52724
|
Melpa packages are not indexed before manually listing packages
|
2019-09-18T20:23:54.083
|
# Question
Title: Melpa packages are not indexed before manually listing packages
I recently switched from sublime text 3 to emacs so I still don't quite understand everything. When I launch emacs and run `package-install`, I can not look up packages from Melpa to install, e.g., `projectile`. Although once I have ran `package-list-packages` the list of available packages is refreshed and the packages from Melpa are indexed. Then if I run `package-install` again, I can find more packages including the ones from Melpa (hence `projectile`). I have this in my `.emacs` settings file:
```
(setq package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
;; ("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
```
`emacs --version` returns:
```
GNU Emacs 25.2.2
Copyright (C) 2017 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
```
I am running this on Ubuntu 18.04.3 LTS.
# Answer
Until `package-refresh-contents` is called, Emacs doesn't know about packages in package archives. Its documentation:
> Download descriptions of all configured ELPA packages.
>
> For each archive configured in the variable ‘package-archives’, inform Emacs about the latest versions of all packages it offers, and make them available for download.
>
> Optional argument ASYNC specifies whether to perform the downloads in the background.
So, if you want to load the list of available packages, make that call in your init file. You could even give it the `async` argument, so Emacs doesn't block until it comes back:
`(package-refresh-contents t)`
> 0 votes
---
Tags: package-repositories, list-packages
---
|
thread-52726
|
https://emacs.stackexchange.com/questions/52726
|
How to set key binding for read-only-mode? in order to simplify cursor movement
|
2019-09-18T20:53:30.903
|
# Question
Title: How to set key binding for read-only-mode? in order to simplify cursor movement
moving point command: `next-line`, `previous-line`, `forward-char`, `backward-char`, etc.
How to omit `Ctrl` key in `read-only-mode`?
How can I combine with read-only-mode-hook to automatically enable keybind when opening a file with read-only permissions?
# Answer
The following minor-mode `wo-ctrl-c-mode` frees all active keybindings from the `control` modifier insofar there are no other modifiers such as `meta` or `shift` and the resulting key-binding is not already occupied.
That minor mode is activated along with `read-only-mode` and when opening files without write-permission with `find-file`.
At least in Emacs 26.2 one needs to treat `find-file` separately since that function (more exactly `find-file-noselect`) sets the `buffer-read-only` flag directly and not through the function `read-only-mode`.
```
(defun wo-ctrl-c-map ()
"Return a keymap freeing keys from control-modifier."
(let ((newmap (make-sparse-keymap)))
(mapc
(lambda (map)
(map-keymap
(lambda (event binding)
(let ((basic-event (vector (event-basic-type event))))
(when (and (equal (event-modifiers event) '(control))
(equal (key-binding basic-event) #'self-insert-command)
(null (lookup-key newmap basic-event)))
(define-key newmap basic-event binding))))
map))
(current-active-maps))
newmap))
(defvar-local wo-ctrl-c-mode-active nil
"If `wo-ctrl-c-mode' is active it sets this variable to a non-nil value.
This is a protection against consecutive calls of (wo-ctrl-c-mode 1).
The value is actually a list containing the original local map as element.")
(define-minor-mode wo-ctrl-c-mode
"Bind all keys with control modifier also directly."
:lighter " α"
(if wo-ctrl-c-mode
(unless wo-ctrl-c-mode-active ;;< protection against two consecutive calls of (wo-ctrl-c-mode 1)
(setq wo-ctrl-c-mode-active (list (current-local-map)))
(let ((map (wo-ctrl-c-map)))
(set-keymap-parent map (car wo-ctrl-c-mode-active))
(use-local-map map)))
(when wo-ctrl-c-mode-active
(use-local-map (car wo-ctrl-c-mode-active))
(setq wo-ctrl-c-mode-active nil))))
(defun wo-ctrl-c-when-read-only ()
"Activate `wo-ctrl-c-mode' when buffer is read-only."
(if buffer-read-only
(wo-ctrl-c-mode)
(wo-ctrl-c-mode -1)))
(add-hook 'read-only-mode-hook #'wo-ctrl-c-when-read-only)
;; `find-file-noselect' sets `buffer-read-only' directly:
(add-hook 'find-file-hook #'wo-ctrl-c-when-read-only)
```
Tested with
`emacs-version`: `GNU Emacs 26.2 (build 2, i686-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-04-12`
> 2 votes
---
Tags: key-bindings, minor-mode, read-only-mode
---
|
thread-8309
|
https://emacs.stackexchange.com/questions/8309
|
Change local holiday calendar
|
2015-02-17T05:09:41.677
|
# Question
Title: Change local holiday calendar
Org-mode's agenda view can display local holidays after enabling it in `org-agenda-include-diary`. This however displays US holidays (such as President's Day). What is the simplest way to configure it to show Canadian holidays?
Per Emacs manual,
> The general holidays are, by default, holidays common throughout the United States. In contrast, holiday-local-holidays and holiday-other-holidays are both empty by default.
So, how would I use use either of those variables to replace the US holidays with Canadian holidays?
The manual further gives an example of adding a *single* holiday:
> (setq holiday-other-holidays '((holiday-fixed 7 14 "Bastille Day")))
How would I go about adding all of the Canadian holidays? Are there no predefined lists I can use?
# Answer
> 1 votes
You can use e.g. netherlands-holidays as a template. Afterwards, this is what I do:
```
(setq calendar-holidays (append calendar-holidays holiday-netherlands-holidays))
```
# Answer
> 1 votes
I was on a similar boat. Assuming that you have your favorite calendar on google,
* Go to google calendar and download i.e. click on "Export Calendars"
* Unzip calendar, which should give you a .ics file
* In your .emacs file, do the following
```
(icalendar-import-file "~/wherethefileis/calendar.ics"
"~/diary")
```
You should comment out the above import command after your first load of .emacs file. Otherwise, every time you open your emacs, the .ics file will be imported to your diary and your diary would have multiple entries for same day.
# Answer
> 1 votes
To add more than one *single* date, my approach is to add in your configuration file the following code (this example is for Madrid, Spain, so change the example to your needs):
```
(setq holiday-other-holidays
'((holiday-fixed 1 1 "Año Nuevo")
(holiday-fixed 1 6 "Día de Reyes")
(holiday-fixed 3 19 "San José")
(holiday-fixed 5 1 "Fiesta del Trabajo")
(holiday-fixed 5 2 "Fiesta de la Comunidad de Madrid")
(holiday-fixed 5 15 "Fiesta de San Isidro")
(holiday-fixed 10 12 "Día de la Hispanidad")
(holiday-fixed 11 1 "Día de Todos los Santos")
(holiday-fixed 12 6 "Día de la Constitución")
(holiday-fixed 12 8 "Día de la Inmaculada")))
```
For every local holiday include a line as per the following example:
```
(holiday-fixed month-number day-number "Name of the local event")
```
---
Tags: diary
---
|
thread-52731
|
https://emacs.stackexchange.com/questions/52731
|
How can I represent a 4 spaces indent width as 2 spaces?
|
2019-09-19T04:41:36.577
|
# Question
Title: How can I represent a 4 spaces indent width as 2 spaces?
For clarity: I mean indents as represented by individual spaces, not tab characters.
I'm working with a friend on a javascript project, and while I'm an 80col zealot, he wants to have 4 space indent. It's not the end of the world, but it bothers the heck out of my eyes.
I know about the `.dir-locals.el` trick, so I'll just stick the tab width in there, but I was wondering if there was a display hook or extension that would print any block identation as 2 spaces? For example, show this block
```
function greet(name) {
return `Hello, ${name}`
}
```
as this one
```
function greet(name) {
return `Hello, ${name}`
}
```
while actually writing 4 spaces into the file on disk. We already use prettier, so I can chuck in anything without having to worry what comes out on the other end, but I'd prefer to have a solution that just changes the display of the buffer in emacs. I don't really want to hassle with changing the real file contents every time I open a file.
# Answer
You can (ab)use `prettify-symbols-mode` for this.
```
(push '(" " . ?\ ) prettify-symbols-alist)
```
followed by `M-x prettify-symbols-mode`
> 1 votes
# Answer
If the indentation is spaces rather than tabs, give redshift-indent a try. I failed to follow up on some upstream text-property enhancements which are needed to make this idea work in all situations, and consequently tabs can cause problems<sup>1</sup>; but if your indentation is spaces, then this will probably still work fine.
See the library Commentary for details, and use the `M-x` `redshift-indent` command to try it out:
```
Invoke `redshift-indent-mode' with a buffer-local cosmological constant.
With no prefix ARG, `redshift-indent-mode' is toggled.
If ARG is positive, `redshift-cosmological-constant' is set to ARG.
If ARG is negative, `redshift-cosmological-constant' is set to 1.0 / (abs ARG).
If ARG is C-u, `redshift-cosmological-constant' is prompted for interactively.
e.g.:
With prefix arg 2, indentation will appear 2 times its normal width.
With prefix arg -2, indentation will appear 0.5 times its normal width.
```
---
<sup>1</sup> In a local copy (with the same code), I have a more specific note that "The current implementation unavoidably breaks for tabs which are visually narrower than `tab-width`."
> 0 votes
---
Tags: indentation
---
|
thread-52743
|
https://emacs.stackexchange.com/questions/52743
|
How to automatically press the Tab key to execute minibuffer-complete after executing imenu?
|
2019-09-20T00:34:57.787
|
# Question
Title: How to automatically press the Tab key to execute minibuffer-complete after executing imenu?
I first set up this key binding : `(global-set-key (kbd "<f4>") (lambda () (interactive) (other-window -1)))`
When I use imenu I always have to perform the following steps:
Step 1: Press `M-x`
Step 2: type `imenu` , Press `RET`
Step 3: Press `TAB` ;; run `minibuffer-complete`
Step 4: Press `f4` ;; run `(other-window -1)` for switch to `*Completions*` buffer
Step 5: Press `C-s` ;; run `isearch-forward`
I want to use a function to perform the above 5 steps.
Is this possible? This is useful when there are a lot of functions.
Similarly, if want to display struct, need to insert between the second and third steps:
Step 3: type `Class` , Press `RET`
My current solution is to use xdotool:
show struct list: `(global-set-key (kbd "<f8>") (lambda () (interactive) (shell-command "xdotool key alt+x && xdotool type 'imenu' && xdotool key Return && xdotool type 'Class' && xdotool key Return && xdotool key Tab && xdotool key F4 && xdotool key ctrl+s")))`
show function list: `(global-set-key (kbd "<f9>") (lambda () (interactive) (shell-command "xdotool key alt+x && xdotool type 'imenu' && xdotool key Return && xdotool key Tab && xdotool key F4 && xdotool key ctrl+s")))`
I want to quickly locate the item by fuzzy search in `*Completions*` buffer, Instead of pressing Tab key complete in the minibuffer
# Answer
> 1 votes
I'm not really sure what you're trying to do, but maybe this will help:
```
(defun foo ()
"..."
(interactive)
(minibuffer-with-setup-hook #'minibuffer-complete
(call-interactively #'imenu)))
(global-set-key (kbd "<f4>") 'foo)
```
---
Tags: completion, minibuffer, imenu
---
|
thread-52745
|
https://emacs.stackexchange.com/questions/52745
|
Yasnippets: How to add if statements that check for regex?
|
2019-09-20T04:46:50.683
|
# Question
Title: Yasnippets: How to add if statements that check for regex?
I would like to replicate some of the snippets shown in this blog post
Some of the snippets shown in that post involved if statements that check for regexp in snippet fields as well as checking for regex before a snippet
Can yasnippets do the same? If yes, then how?
I did not see anything like that in the documentaion
# Answer
> 2 votes
Yasnippets can execute arbitrary lisp code writing it inside back quotes
In your case you can write something like
```
`(if (re-search-forward "regex" nil t)
"some text"
"another one")`
```
---
Tags: latex, yasnippet
---
|
thread-52752
|
https://emacs.stackexchange.com/questions/52752
|
How to use unbound keys as “non-sticky” modifier keys
|
2019-09-20T13:06:04.290
|
# Question
Title: How to use unbound keys as “non-sticky” modifier keys
I would like to setup keyboard shortcuts with other keys that traditional modifier keys, as modifier keys.
example : bind `"f1-left"` ( so `F1`+) to a command.
But not bind the sequence `F1` to the command like explained in this answer : Using function keys as "sticky" modifier keys
is that something possible in emacs ?
I see commands such as
`(define-key function-key-map [f8] 'event-apply-super-modifier)` but is there a command binding on press and on release events ? like a "define-key-press" "define-key-release" ? If so we could bind a command `event-apply-super-modifier` when f1 is pressed and `event-release-super-modifier` when f1 is released.
# Answer
You currently cannot do that within Emacs (at least, not without changing Emacs's C code).
We could expose the "press" and "release" events on keyboard keys, but we don't do that so far.
OTOH, you can do it outside of Emacs with `xmodmap` (or its more modern replacement, IIRC it'd be something like `setxkbmap`).
E.g. something like:
```
xmodmap -e 'add mod4 F1'
```
after which you can do
```
(global-set-key [H-left] 'my-favorite-command-for-f1-left)
```
> 1 votes
---
Tags: key-bindings
---
|
thread-52755
|
https://emacs.stackexchange.com/questions/52755
|
How to discover (standard) function names?
|
2019-09-20T15:27:13.593
|
# Question
Title: How to discover (standard) function names?
When programing emacs (or common) lisp, how to discover (standard) function names (using emacs and working offline)?
*Example:* Let's say you want to shift bits of an integer, but you don't now the name of the function, which can do this (hint: the name is `ash`, but you don't know, yet).
`apropos` isn't helping you, because it does not list `ash` when asking for `shift`.
# Answer
> 10 votes
Apropos help in Emacs is by no means limited to function `apropos`.
1. `M-x apropos documentation`. It lets you match keywords or a regexp against doc strings. Very helpful when you don't know how the function might be named but you might be able to guess some words used in its doc.
For example, `M-x apropos-documentation RET shift bit RET` shows you the names and doc for just the functions `lsh` and `ash`. Simple, effective.
```
lsh
Function: Return VALUE with its bits shifted left by COUNT.
If COUNT is negative, shifting is actually to the right.
In this case, zeros are shifted in on the left.
(fn VALUE COUNT)
----------------
ash
Function: Return VALUE with its bits shifted left by COUNT.
If COUNT is negative, shifting is actually to the right.
In this case, the sign bit is duplicated.
(fn VALUE COUNT)
```
2. There are also these other Apropos commands:
```
apropos-command
apropos-follow
apropos-function
apropos-library
apropos-local-value
apropos-local-variable
apropos-option
apropos-value
apropos-variable
```
See also **`apropos-fn+var.el`**.
3. The Emacs manual (`C-h r`), `i`, is your friend. Likewise, the Elisp manual (`C-h i`, choose Elisp).
4. Icicles apropos support -- including documentation-apropos commands, which provide the functionality of `apropos-documentation`, but which let you match against both the function name (e.g. parts of it) and the doc string.
In answer to your question in the comments, I don't really know how to find similar info for Common Lisp. Perhaps someone else will have a good answer about that. But:
* You can certainly use `i` in the CL Info manual provided by Emacs.
* Googling "common lisp docstring" turned up this StackOverflow question as the first hit. Perhaps it will help.
---
Tags: help, documentation, apropos
---
|
thread-52739
|
https://emacs.stackexchange.com/questions/52739
|
How can I prevent org-mode reading agenda files when started?
|
2019-09-19T19:30:53.877
|
# Question
Title: How can I prevent org-mode reading agenda files when started?
My org-mode agenda files are on a remote machine, accessed via ssh using tramp. When org-mode starts it *always* reads this file, which is inconvenient as it makes opening any org file very slow. I would prefer for it to read the agenda files only when I actually look at the agenda. Is there a way to do this?
My `.emacs` currently sets the agenda location in this way:
```
(setq org-agenda-files '("/-:somehost:somefile.org"))
```
# Answer
> 2 votes
I'd use `use-package`, treat org-agenda as separate package, defer its loading and declare `org-agenda-files` there. It should load the variable just before the agenda is loaded.
Alternatively I guess that you can exclude that file from your init file, and use `add-to-list` in `org-agenda-mode-hook`or any other convenient place you'll call before loading agenda-mode. This way will allow you to set conditional statements conveniently.
# Answer
> 0 votes
The solution I settled on was to remove the setting for `org-agenda-files` from my `.emacs` and instead to set `org-agenda-files` within some file local variables in the org-mode files that were actually relevant to the agenda. i.e. a block of code like this at the end of those files:
```
# Local Variables:
# eval: (setq org-agenda-files '("/-:somehost:somefile.org"))
# End:
```
---
Tags: org-mode, org-agenda
---
|
thread-52757
|
https://emacs.stackexchange.com/questions/52757
|
Remove key binding from `ess-extra-map`
|
2019-09-20T17:02:11.793
|
# Question
Title: Remove key binding from `ess-extra-map`
Related:
There is a default key binding in ESS that I accidentally trigger periodically: `C-c C-e r` calls `inferior-ess-reload` which kills and restarts my running R process. (It is close-enough to `C-c C-e w ess-execute-screen-options` that my finger might tap the `R` key.)
I know the map to which it is assigned (https://github.com/emacs-ess/ESS/blob/master/lisp/ess-mode.el#L115). I'm trying to add an unbind to a package hook, either of
```
(define-key ess-extra-map "\C-c\C-er" nil)
(define-key ess-extra-map (kbd "C-c C-e r") nil)
```
but after running those commands, `C-h b` and `C-h C-k C-c C-e r` confirm that it is still bound.
A third option would be to just comment-out those lines in `ess-mode.el`, but that won't survive updates.
Is there a better way to do it?
```
GNU Emacs 26.2 (build 1, x86_64-w64-mingw32) of 2019-04-13
ess-version: 18.10.3snapshot [elpa: 20190814.1054] (loaded from c:/Users/r2/.emacs.d/elpa/ess-20190814.1054/)
```
---
## Update 1
From Drew's suggestion, here is the relevant portion of `C-h b`, filtering for `C-c C-e`:
```
Key translations:
key binding
--- -------
...
C-c C-b ess-eval-buffer
C-c C-c ess-eval-region-or-function-or-paragraph-and-step
C-c C-d ess-doc-map
C-c C-e ess-extra-map
C-c C-f ess-eval-function
...
C-c C-e C-c Prefix Command
C-c C-e C-d ess-dump-object-into-edit-buffer
C-c C-e C-e ess-execute
C-c C-e TAB ess-install-library
C-c C-e C-l ess-load-library
C-c C-e C-r inferior-ess-reload
C-c C-e C-s ess-set-style
C-c C-e C-t ess-build-tags-for-directory
C-c C-e C-w ess-execute-screen-options
C-c C-e / ess-set-working-directory
C-c C-e C Prefix Command
C-c C-e d ess-dump-object-into-edit-buffer
C-c C-e e ess-execute
C-c C-e i ess-install-library
C-c C-e l ess-load-library
C-c C-e r inferior-ess-reload
C-c C-e s ess-set-style
C-c C-e t ess-build-tags-for-directory
C-c C-e w ess-execute-screen-options
...
Global Bindings:
key binding
--- -------
...
C-c C-e Prefix Command
...
```
I'm not certain why `C-c C-e` is shown in both "Key translations" and "Global Bindings", is that an issue?
# Answer
I think you are looking for this:
```
(define-key ess-extra-map "r" nil)
```
Not this:
```
(define-key ess-extra-map (kbd "C-c C-e r") nil)
```
`C-c C-e` is bound to a *keymap*. In that keymap, `r` is bound to `inferior-ess-reload`.
> 4 votes
---
Tags: key-bindings, ess
---
|
thread-52761
|
https://emacs.stackexchange.com/questions/52761
|
Why is my Python indentation set to 8 locally by default?
|
2019-09-21T01:46:49.633
|
# Question
Title: Why is my Python indentation set to 8 locally by default?
I'm running Emacs 25.2.2 on Ubuntu 18.04 for WSL. I launch `emacs -q` and open a new Python file, `test.py`. As soon as I hit the Tab key, I notice the indentation is 8 spaces instead of 4. I don't like that.
I run `describe-variable` to check on `python-indent` and I see:
```
python-indent is a variable defined in ‘python.el’.
Its value is 8
Local in buffer test.py; global value is 4
This variable is an alias for ‘python-indent-offset’.
This variable is obsolete since 24.3;
use ‘python-indent-offset’ instead.`
[...]
```
As for the preferred variable:
```
python-indent-offset is a variable defined in ‘python.el’.
Its value is 4
[...]
```
Am I correct to think that this is a major bug in the default Python mode? What's the simplest fix or workaround?
# Answer
> 5 votes
The default is 4 spaces:
```
(defcustom python-indent-offset 4
"Default indentation offset for Python."
...
```
But python-mode **guesses the spaces when opening a file and overwrites the default locally**. That's probably what happens in your case as only the local value is set to 8 and the global (default) is still 4.
Try it with a new empty file and check the value of the variable again.
You can also disable this feature:
```
(setq python-indent-guess-indent-offset nil) ; default is t
```
# Answer
> 1 votes
I cannot reproduce this using "emacs-24.2 -q ", where the default is correct at the value 4. I suggest you update your emacs, or perhaps there is something odd about your file test.py if it is an already existing python file.
---
Tags: python, indentation
---
|
thread-52763
|
https://emacs.stackexchange.com/questions/52763
|
How to align the source code block when export to PDF in Org-mode?
|
2019-09-21T04:39:01.363
|
# Question
Title: How to align the source code block when export to PDF in Org-mode?
While using org-mode to export source code to PDF files, the source code is not aligned with the indentation of the text.
The .org file are as follow:
And the output result looks like this:
Would there be a way to align the indentation of the code block, or to center it?
# Answer
> 2 votes
The line "The following pre" is the first line of its paragraph (it's the only line of its paragraph), and is thus indented. Try a longer paragraph before the source block to see that it does match the indentation of the subsequent lines of the paragraph, just not the first one.
If you don't want the first line of the paragraph indented change it to:
```
\noindent The following pre
```
If you don't want any first line of any paragraph to be indented, add this to the top of your Org mode document:
```
#+LATEX_HEADER: \setlength{\parindent}{0pt}
```
If you want the source block horizontally centered, put it inside a center block:
```
#+begin_center
#+begin_src sql
CREATE TABLE STAT_Asump(
...
#+end_src
#+end_center
```
---
Tags: org-mode, latex
---
|
thread-52767
|
https://emacs.stackexchange.com/questions/52767
|
Auto-add BCC address to notmuch/message-mode messages
|
2019-09-21T15:56:06.933
|
# Question
Title: Auto-add BCC address to notmuch/message-mode messages
I use GNUs for most of my email needs, but also have notmuch for rapid search of my inbox. Trouble is, when I choose a message in that notmuch search, it doesn't open it with gnus but with its own whatever message-mode spinoff called `Message[Notmuch]`. In GNUS I have an automatically added BCC address (my "sent-mail" inbox, which is downloaded across devices to sync what I've sent). How can I get the same automatic BCC added to anything I send in reply with `Message[Notmuch]`?
# Answer
> 1 votes
I found a working answer by using `customize-variable` `message-default-mail-headers` and adding: `"Bcc: address@place.com
"`
It looks like this in the end (in my emacs-custom.el):
```
'(message-default-mail-headers "Bcc: address@place.com"
")
```
Note that it is required for each mail header line to end in a newline.
---
Tags: gnus, email, notmuch
---
|
thread-52769
|
https://emacs.stackexchange.com/questions/52769
|
How to call `replace-string` with specific strings from code?
|
2019-09-21T16:41:28.220
|
# Question
Title: How to call `replace-string` with specific strings from code?
Sometimes I want to replace `[$]` with `\(` and `[/$]` with `\)` either in the region or in the whole buffer. `replace-string` works well for that, except for requiring me to type the strings I want to replace. I would like to call it with these specific strings from an elisp function. How can I do that?
# Answer
> 2 votes
From `replace-string` documentation:
> This function is for interactive use only; in Lisp code use `search-forward` and `replace-match` instead.
---
Tags: replace
---
|
thread-51049
|
https://emacs.stackexchange.com/questions/51049
|
How can I quit from multiple-cursor mode by ESC
|
2019-06-15T13:23:08.063
|
# Question
Title: How can I quit from multiple-cursor mode by ESC
I want to bind `ESC` to quit from multiple-cursor mode.
This code doesn't work:
```
(define-key mc/keymap (kbd "<ESC>") 'mc/keyboard-quit)
```
How can I do it?
# Answer
> -1 votes
I have solved the problem by changing `<ESC>` to `<escape>`:
```
(define-key mc/keymap (kbd "<escape>") 'mc/keyboard-quit))
```
EDIT: Also need to check in `.mc-lists.el` `keyboard-escape-quit` should be in
```
(setq mc / cmds-to-run-for-all
'(
keyboard-escape-quit))
```
# Answer
> 1 votes
In order to use `define-key` you should try using the snippet below:
```
(with-eval-after-load 'multiple-cursors-core
(define-key mc/keymap (kbd "<ESC>") 'mc/keyboard-quit))
```
so that the `mc/keymap` is defined by the file `multiple-cursors-core.el/elc` *before* a new keyboard shortcut is added thereto.
If the solution above does not work you can assign temporarily a custom keybind except ESC in order not to break other commands with the snippet below
```
(global-set-key (kbd "some keybind") 'mc/keyboard-quit)
```
---
Tags: key-bindings, multiple-cursors
---
|
thread-52655
|
https://emacs.stackexchange.com/questions/52655
|
Config is broken when I use load-user-file
|
2019-09-14T17:54:18.040
|
# Question
Title: Config is broken when I use load-user-file
This is my config for org-babel:
```
(use-package org
:mode (("\\.org$" . org-mode))
:ensure org-plus-contrib
:config
(org-babel-do-load-languages 'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(shell . t)
(jupyter . t))))
```
It works when it is located in my `init.el`. However when I relocate it in another file `org.el` and load it in `init.el` with: `(load-user-file "org.el")` I have got the error:
```
Symbol's value as variable is void: org-src-lang-modes
```
Also I have the line `;;; -*- lexical-binding: t -*-` and the same encoding in both files (`init.el`,`org.el`). So, could you explain me what happens?
UPDATE.
Just for clarification this is my `load-user-file` :
```
(defun load-user-file (file)
(interactive "f")
"Load a file in current user's configuration directory"
(load-file (expand-file-name file user-init-dir)))
```
# Answer
> 2 votes
The name `org.el` is a bad name for your file, because it conflicts with the `org.el` file that is part of Org mode. When emacs is asked to load `org.el`, which one will be loaded is determined by how emacs's `load-path` variable is defined, but in any case you will not be able to load *both*, so either your functionality will be missing or Org mode might be broken.
The solution is to rename your file to a unique name that will not cause a conflict.
---
Tags: org-mode, init-file, org-babel
---
|
thread-48905
|
https://emacs.stackexchange.com/questions/48905
|
Modifying the size of an asymptote image in latex export
|
2019-04-13T19:33:52.867
|
# Question
Title: Modifying the size of an asymptote image in latex export
I have been using Asymptote to make pictures that can be included in Latex documents. I recently discovered that Org mode plays well with Asymptote
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-asymptote.html#orgbded9e5
I was able to successfully compile a Latex document with embedded Asymptote code as follows.
```
#+TITLE: Test Document
#+AUTHOR: A. U. Thor
#+latex_class_options: [10pt]
#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
#+LATEX_HEADER: \usepackage{parskip}
#+LATEX_HEADER: \usepackage{graphicx}
#+LATEX_HEADER: \usepackage{asymptote}
#+OPTIONS: toc:nil
#+BEGIN_SRC asymptote :file test.pdf
include graph;
size(1inch);
filldraw(circle((0,0),1),yellow,black);
fill(circle((-.3,.4),.1),black);
fill(circle((.3,.4),.1),black);
draw(arc((0,0),.5,-140,-40));
#+END_SRC
```
This generates the document as in the screenshot below.
How can I adjust the instructions in the header of the code-chunk above, to be able to manipulate the size and placement (left/right/center) of the image? Right now the image is just too big.
***Note***: If it helps, the generated \LaTeX source file, exported from the Org file looks like this
```
% Created 2019-04-13 Sat 15:26
% Intended LaTeX compiler: pdflatex
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{minted}
\usepackage[margin=0.5in]{geometry}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{asymptote}
\author{A. U. Thor}
\date{\today}
\title{Test Document}
\hypersetup{
pdfauthor={A. U. Thor},
pdftitle={Test Document},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 26.1 (Org mode 9.1.9)},
pdflang={English}}
\begin{document}
\maketitle
\begin{center}
\includegraphics[width=.9\linewidth]{test.pdf}
\end{center}
\end{document}
```
# Answer
If you include this answer based on "#+ATTR\_LATEX" between your #+END\_SRC and #+RESULTS block, you should be able to resize the image through LaTeX export. Your code would look like this.
```
#+BEGIN_SRC asymptote :file test.pdf
<<Your Asymptote code here.>>
#+END_SRC
#+ATTR_LATEX: :width 0.2\textwidth
#+RESULTS:
<<The image Asymptote generated here.>>
```
Note that the "0.2" factor happened to work well with the document I was just working on; you might have to adjust it for your own use.
> 1 votes
---
Tags: org-mode, latex
---
|
thread-28367
|
https://emacs.stackexchange.com/questions/28367
|
Get word at point
|
2016-11-03T09:48:00.293
|
# Question
Title: Get word at point
It's a simple thing. My cursor is over a word and I want to get the word so that I can do something with it. I see a few different ways to do this but want to avoid reinvention and use a standard method.
# Answer
> 22 votes
You can use the function `thing-at-point` and tell it to return the `word` at point and not return any text properties (unless you need them). Example buffer contents (| is the cursor):
> Hello wor|ld
Calling `(thing-at-point 'word 'no-properties)` returns "world".
# Answer
> 6 votes
```
(current-word &optional STRICT REALLY-WORD)
```
> Return the word at or near point, as a string. The return value includes no text properties.
---
Tags: words
---
|
thread-36366
|
https://emacs.stackexchange.com/questions/36366
|
Disable auto id generation in org-mode html export
|
2017-10-23T11:01:17.220
|
# Question
Title: Disable auto id generation in org-mode html export
How can I disable inclusion of `id`s when exporting file as html
Say for example, in the following file I have disabled `toc`
```
#+TITLE: Using org-mode
#+HTML_DOCTYPE: html5
#+OPTIONS: toc:nil html-style:nil html-scripts:nil
* Where to start
** Let’s begin here
```
Now if I export it with `M-x` `org-html-export-to-html`, I get the following output:
```
...
<div id="outline-container-org0c7ecf1" class="outline-2">
<h2 id="org0c7ecf1"><span class="section-number-2">1</span> Where to start</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-orga4a6d26" class="outline-3">
<h3 id="orga4a6d26"><span class="section-number-3">1.1</span> Let’s begin here</h3>
</div>
</div>
...
```
I would like to not add the `id` attribute at all unless a `CUSTOM_ID` property is set or `toc` is enabled.
These randomly generated `id`s break when regenerated and thus make it less useful as an `id` that can be linked from some other source.
As a side note, this results in unnecessary noise in commits (that's the primary reason I'm trying to avoid this).
# Answer
This isn't *exactly* what you asked for, but it does solve:
> These randomly generated ids break when regenerated and thus make it less useful as an id that can be linked from some other source.
>
> As a side note, this results in unnecessary noise in commits (that's the primary reason I'm trying to avoid this).
I was having the same problems, so I came up with this: https://github.com/alphapapa/unpackaged.el#export-to-html-with-useful-anchors
> 3 votes
# Answer
As others have said, it seems there is no out-of-the-box solution to this problem. Here is a hacky solution that uses an output filter and a regex to remove the `id` attributes from the final HTML output:
```
(require 'ox-md)
(defun html-body-id-filter (output backend info)
"Remove random ID attributes generated by Org."
(when (eq backend 'html)
(replace-regexp-in-string
" id=\"[[:alpha:]-]*org[[:alnum:]]\\{7\\}\""
""
output t)))
(add-to-list 'org-export-filter-final-output-functions 'html-body-id-filter)
```
> 2 votes
# Answer
This can't be done out of the box, but there is a feature request for it at the Github repo: Feature request: More "Vanilla" HTML
> 0 votes
---
Tags: org-mode, org-export
---
|
thread-52777
|
https://emacs.stackexchange.com/questions/52777
|
No `emacsclient` binary when building from source
|
2019-09-22T04:09:22.960
|
# Question
Title: No `emacsclient` binary when building from source
I have built Emacs from source and, after `make` ends successfully, no `emacsclient` binary is present in the output (`./src`) directory. What is the recommended way to get the `emacsclient` binary in this situation to have it work with the built version?
EDIT:
Info: Ubuntu 16.04, building Emacs 26.3, build settings: `./configure --with-modules CC=clang` (to avoid existing dynamic modules bug with gcc).
# Answer
That's correct. The emacsclient binary is not present in the source src directory. It is however present in the lib-src directory. So do a `make install`, if you have not already done so, to put the emacsclient binary in your build directory, wherever you have chosen that to be.
> 5 votes
---
Tags: emacsclient, build
---
|
thread-52780
|
https://emacs.stackexchange.com/questions/52780
|
Replace placeholder by incremental value
|
2019-09-22T09:36:30.733
|
# Question
Title: Replace placeholder by incremental value
Windows 10 Emacs 26.1
I has the next text
```
[
{
"id": N,
"name": "Agent#N",
"address": "N Tabernacle St, London EC2A 4DD, UK"
},
{
"id": N,
"name": "Agent#N",
"address": "N Tabernacle St, London EC2A 4DD, UK"
},
{
"id": N,
"name": "Agent#N",
"address": "N Tabernacle St, London EC2A 4DD, UK"
}
]
```
I need to replace **N** in every node by incremental integer value. The result must be like this:
```
[
{
"id": 1,
"name": "Agent#1",
"address": "1 Tabernacle St, London EC2A 4DD, UK"
},
{
"id": 2,
"name": "Agent#2",
"address": "2 Tabernacle St, London EC2A 4DD, UK"
},
{
"id": 3,
"name": "Agent#3",
"address": "3 Tabernacle St, London EC2A 4DD, UK"
}
]
```
Is it possible?
# Answer
You could use keyboard macros, but the easiest approach in this case is probably to `query-replace-regexp` this:
```
"id": N,
"name": "Agent#N",
"address": "N Tabernacle St, London EC2A 4DD, UK"
```
with this:
```
"id": \#,
"name": "Agent#\#",
"address": "\# Tabernacle St, London EC2A 4DD, UK"
```
The counter is zero-based, so either add a dummy record at the start, or else use `\,(1+ \#)` instead of plain `\#`
---
n.b. There are no regexp-special characters in this text, so nothing needs escaping in the search pattern.
If, however, this is just one example amongst many, then there's a trick you can employ to automatically escape characters in the pattern as necessary:
* Copy the text to search for.
* `C-M-s` to run `isearch-forward-regexp`.
* `C-y` to yank the copied text as the search pattern. Emacs will automatically escape any regexp-special characters.
* `C-M-%` to begin a `query-replace-regexp` for the isearch pattern.
* `C-y` to again paste the original copied text, this time as the replacement text.
* Edit the pasted replacement text to use the `\#` counter.
* Submit the replacement text, and begin replacing the matches as required...
> 3 votes
---
Tags: text-editing
---
|
thread-52772
|
https://emacs.stackexchange.com/questions/52772
|
How to make markdown-live-priview-mode use pandoc?
|
2019-09-21T18:27:41.040
|
# Question
Title: How to make markdown-live-priview-mode use pandoc?
I'm having a problem where in `markdown-live-preview-mode` tables are not correctly converted to HTML from markdown. I'm using markdown-mode. I've tried using pandoc to create the HTML and pandoc correctly produces the table. I would like to set markdown-mode to use pandoc to create the HTML file for the live preview.
I get this from current markdown-live:
```
| Page Type | Description | |:-----------:|:---------------------------------------------------------:| | Stand-alone |
about or static text | | Referance | Index lookup page wit likns of all blog pasts or products | |
periodical | Blog posts or writing column, any series |
```
If I do `M-!` \[return\] `pandoc -s -o filename.html filename.md` \[return\]. \[position cursor on `eww` buffer\] `g`.
```
<table>
<thead>
<tr class="header">
<th style="text-align: center;">Page Type</th>
<th style="text-align: center;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">Stand-alone</td>
<td style="text-align: center;">about or static text</td>
</tr>
<tr class="even">
<td style="text-align: center;">Referance</td>
<td style="text-align: center;">Index lookup page wit likns of all blog pasts or products</td>
</tr>
<tr class="odd">
<td style="text-align: center;">periodical</td>
<td style="text-align: center;">Blog posts or writing column, any series</td>
</tr>
</tbody>
</table>
```
*It doesn't work on stackexchange; markdown tables. After running `pandoc` the output is correct in `filename.html`*
I'm thinking there is a way to customize the command that markdown-mode uses to convert markdown to HTML in emacs init file.
# Answer
> 0 votes
Here are the settings I use:
```
(setq markdown-command
(concat
"/usr/local/bin/pandoc"
" --from=markdown --to=html"
" --standalone --mathjax --highlight-style=pygments"
" --css=pandoc.css"
" --quiet"
" --number-sections"
" --lua-filter=lua.lua"
" --metadata-file=metadata.yml"
" --metadata=reference-section-title:'References & Further Reading'"
" --filter pandoc-citeproc"
" --bibliography=bibfile.bib"
))
```
This lets me open an html file that is generated via pandoc
---
Tags: customize, markdown-mode, pandoc
---
|
thread-52785
|
https://emacs.stackexchange.com/questions/52785
|
Specific file for pooling tags in org folder
|
2019-09-22T17:38:00.747
|
# Question
Title: Specific file for pooling tags in org folder
I'm trying to organize tags among many org files.
I have a few tags defined in `init.el` through `org-tag-alist` and other tags placed at top of files.
I would like to set a `tags.org` file for tags in folder `project` (in order to tag any entry regardless which `.org` file from `project` is concerned).
Setting `#+TAGS:` at top of file make org-mode searching `init.el` tags but doesn't load tags from `tags.org`.
Any idea?
# Answer
This sounds like a case for a directory-local variable for `org-current-tag-alist`. Something like this in a .dir-locals.el file might be what you need.
```
((org-mode
(org-current-tag-alist
("tag1")
("tag2"))))
```
Note though, if you also want file local ones, you will have to overwrite them with
```
# Local Variables:
# org-current-tag-alist: (("aa") ("bbbb") ("cccc"))
# End:
```
> 0 votes
---
Tags: org-mode, org-tags
---
|
thread-50137
|
https://emacs.stackexchange.com/questions/50137
|
Show Apple Calendar events in org-mode
|
2019-04-24T18:41:56.943
|
# Question
Title: Show Apple Calendar events in org-mode
Is there a way to show Apple Calendars in org-mode? All I need is to be able to see them in org-mode, I am not (currently) interested in syncing or anything like that. Ideally, the Apple Calendars should show up as a Readonly buffer (or diary, or whatever the term ends up being).
There is org-mac-iCal, but it is severely out of date and does not work any more. I suppose the way to do it is to parse the Calendar files and put them where org-mode would see them, but I am curious if this is done already by somebody?
# Answer
> 1 votes
Here are the settings I use for diary loaded into org-mode. You need to get urls for the apple calendars you want to show in org.
I found the discussion by Adolfo Villafiorita very helpful.
You'll also probably want to set up some sort of script to automate checking your calendars for new entries. I think the easiest way to do this is to run a script for emacs in batch mode.
```
(setq diary-file (concat cpm-local-dir "diary-files/diary"))
(setq diary-location (concat cpm-local-dir "diary-files/"))
(setq org-agenda-include-diary t)
(setq diary-display-function 'diary-fancy-display)
(add-hook 'diary-list-entries-hook 'diary-include-other-diary-files)
(add-hook 'diary-list-entries-hook 'diary-sort-entries t)
; calendars you want to download
; each item links to a remote iCal calendar
(setq calendars
'(("work" . "https://path/to/work/cal")
("gcal" . "https://path/to/gcal")
("family" . "https://path/to/fam/cal")
))
(defun cpm--getcal (url file)
"Download ics file and add it to file"
(let ((tmpfile (url-file-local-copy url)))
(icalendar-import-file tmpfile file)
(kill-buffer (car (last (split-string tmpfile "/"))))))
(defun cpm/getcals ()
"Load a set of ics calendars into emacs diary files"
(interactive)
(mapcar #'(lambda (x)
(let ((file (concat diary-location (car x)))
(url (cdr x)))
(message (concat "Loading " url " into " file))
(find-file file)
;; (flush-lines "^[& ]") ;; if you import ical as non marking
(erase-buffer) ;; to avoid duplicating events
(cpm--getcal url file)
))
calendars)
;; send everything to a diary file
(shell-command-to-string "cat work family gcal > diary"))
```
# Answer
> 1 votes
Thanks for mentioning org-mac-iCal and I found someone forked and update the repo, here is the new repo link: https://github.com/ndw/org-mac-iCal.
I tested and it worked. Although I don't know why a certain calendar did not show even I specified the name of it.
---
Tags: org-mode, ical
---
|
thread-51360
|
https://emacs.stackexchange.com/questions/51360
|
Gnus: Applying splits to old messages
|
2019-07-02T20:15:34.500
|
# Question
Title: Gnus: Applying splits to old messages
I am migrating my email workflow to gnus. I want to use splitting to keep things organized and for the splits to take effect on the server. I think my splits are working for incoming mail, but I want to sort my old mail too.
```
(setq gnus-select-method '(nnimap "outlook.office365.com"
(nnir-search-engine imap)
(nnimap-stream starttls)
(nnimap-split-download-body t)
(nnimap-split-predicate "UNDELETED")
(nnimap-split-fancy (| ("MailScanner4-SpamCheck" "spam" "spam\.detected")
(from ".*@spammer.com" "mail\.custom\.spams")
(from ".*acm.org" "mail.acm")
"mail\.misc"))))
```
# Answer
> 2 votes
3 steps:
1. Select your mails:
```
M P b
```
2. Respool them:
```
B r RET RET
```
3. Be happy
---
Tags: gnus
---
|
thread-52798
|
https://emacs.stackexchange.com/questions/52798
|
macOS not-terminal: why "S-" is translated away from S-RET?
|
2019-09-23T12:23:40.450
|
# Question
Title: macOS not-terminal: why "S-" is translated away from S-RET?
I am trying to bind `S-RET` to something, but it's getting ignored. If I do `C-h k S-RET`, I see `RET (translated from <S-return>) runs...` \- which seems to suggest that Emacs sees the `S-` in `S-RET` just fine, but then decides to drop the `S-` part for some reason. How do I find that reason and, preferably, remove it?
This is a macOS GUI build from https://emacsformacosx.com. Googling finds multiple instances of similar issue of Emacs on terminals, but in this case it is not a terminal. I have also tried looking at the translation keymap variables, I don't fully understand their contents, but at least they don't grep for anything starting with `S-R...` or `S-r...`.
# Answer
> 2 votes
You didn't show us how you're attempting to bind `S-RET`, but one way is:
```
(local-set-key (kbd "S-<return>") (lambda () (interactive)
(message "hello")))
```
---
Tags: key-bindings, keymap, prefix-keys
---
|
thread-52807
|
https://emacs.stackexchange.com/questions/52807
|
How to add a right-aligned menu item to menu-bar?
|
2019-09-24T08:27:15.683
|
# Question
Title: How to add a right-aligned menu item to menu-bar?
I hide the window title bar, so I can't use the close window button in the top right corner.
I want to add a menu item with no drop-down menu on the far right side of menu-bar, which can only be clicked as close window button.
A more detailed explanation of the problem added after Drew’s answer:
Close button should be close to the right edge of the window, There should be a space separator in the middle to isolate the close button from other menu items.
# Answer
> 1 votes
`C-h v menu-bar-final-items`:
> **`menu-bar-final-items`** is a variable defined in `C source code`.
>
> Its value is `(help-menu)`
>
> Documentation:
>
> List of menu bar items to move to the end of the menu bar.
>
> The elements of the list are event types that may have menu bar bindings.
Create a "menu" that acts like a button to do what you want, and add that menu after `help-menu` in the list value of **`menu-bar-final-items`**.
For example, supposing your command to close the window is `close-the-gui-window`:
```
(define-key global-map [menu-bar close-gui-window]
'(menu-item
"Close Window" close-the-gui-window
:help "Close GUI window"))
(defun close-the-gui-window (&rest _args) ; Just an example.
"Delete selected frame by clicking a menu item bound to this command."
(interactive)
(delete-frame))
(add-to-list 'menu-bar-final-items 'close-gui-window 'append)
```
---
I use this approach, for example, in library ToolBar+ (`tool-bar+.el`.
Whenever `tool-bar-pop-up-mode` is enabled and the tool bar is not shown (`tool-bar-mode` is not active) the menu-bar shows a "menu" named **Buttons**, which has no menu items.
Clicking **Buttons** pops up the tool bar, and removes **Buttons**, for the duration of one command (either a tool-bar use or any other action). Then **Buttons** is shown again.
---
Tags: menu-bar
---
|
thread-52802
|
https://emacs.stackexchange.com/questions/52802
|
How to display org time segment in mini-buffer when logging time into a logbook drawer?
|
2019-09-23T17:29:07.720
|
# Question
Title: How to display org time segment in mini-buffer when logging time into a logbook drawer?
I use org-mode and log time into a drawer (`(setq org-clock-into-drawer t)`). I often clock in and out in succession and have to go into the `LOGBOOK` drawer to see how much time I spent.
How can I display that time in the mini-buffer after clocking out?
# Answer
> 1 votes
Org mode saves a variable `org-last-inserted-timestamp`. I save this value into another variable after clocking in, which I subtract from the new value of `org-last-inserted-timestamp` after clocking out. Then I make calculations similar to the source code (in lines 1580-1588 of `org-clock.el`, except that I used `let*` and local variables instead of `setq`, and avoided reassigning the same variable `s`) to compute the elapsed time, and display it, and display it as a message.
Add this in your Emacs initialization file, e.g. `~/.emacs`:
```
(defun org-compute-timestamp-difference (later-timestamp earlier-timestamp)
"Computes the difference in string timestamps as a float."
(-
(float-time (apply #'encode-time (org-parse-time-string later-timestamp)))
(float-time (apply #'encode-time (org-parse-time-string earlier-timestamp)))))
(defun org-float-time-diff-to-hours-minutes (diff)
"Returns a float time difference in hh:mm format."
(let* ((hours (floor (/ diff 3600)))
(diff_minus_hours (- diff (* 3600 hours)))
(minutes (floor (/ diff_minus_hours 60))))
(format "%2d:%02d" hours minutes)))
(defun org-save-clock-in-timestamp ()
(setq org-last-clock-in-timestamp org-last-inserted-timestamp))
(defun org-show-last-clock-duration ()
(let ((diff (org-compute-timestamp-difference org-last-inserted-timestamp org-last-clock-in-timestamp)))
(message (concat "Last clocked duration: " (org-float-time-diff-to-hours-minutes diff)))))
(add-hook 'org-clock-in-hook #'org-save-clock-in-timestamp)
(add-hook 'org-clock-out-hook #'org-show-last-clock-duration)
```
If you don't see the result in the mini-buffer, you may have other functions in the hook that overwrite the message, such as `save-buffer`. In this case, either silence the output from those functions, e.g. `(setq save-silently t)` for `save-buffer`, add the above function to the hook before all the others (the first function added to the hook is the last to run), or wrap all functions to be called by the hook in a single function (my preferred solution, as it's more robust to moving lines of code):
```
(defun org-clock-out-functions ()
(save-buffer)
(org-show-last-clock-duration))
(add-hook 'org-clock-out-hook #'org-clock-out-functions)
```
Thank you to @NickD, whose answer pointed me to this solution.
# Answer
> 1 votes
There is an `org-clock-out-hook` that you can attach a function to:
```
(defun my-org-clock-out ()
(message org-clock-duration-last-clock))
(add-hook 'org-clock-out-hook #'my-org-clock-out)
```
Unfortunately, there is no variable like `org-clock-duration-last-clock` so the above won't work. After having a quick look, I found no plausible candidate for such a variable, nor an easy way to calculate it. So I modified `org-clock.el` :-) Here's the diff, if you decide to go this way, but as usual, having your own modifications is fraught with peril:
```
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index a6eb49e1c..d1a2a4962 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1185,6 +1185,7 @@ so long."
(defvar org-clock-current-task nil "Task currently clocked in.")
(defvar org-clock-out-time nil) ; store the time of the last clock-out
+(defvar org-clock-duration-last-clock nil) ; store the duration of the last clock
(defvar org--msg-extra)
;;;###autoload
@@ -1600,7 +1601,8 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
(org-time-string-to-time ts)))
h (floor s 3600)
m (floor (mod s 3600) 60))
- (insert " => " (format "%2d:%02d" h m))
+ (setq org-clock-duration-last-clock (format "%2d:%02d" h m))
+ (insert " => " org-clock-duration-last-clock)
(move-marker org-clock-marker nil)
(move-marker org-clock-hd-marker nil)
;; Possibly remove zero time clocks. However, do not add
```
It adds a global variable `org-clock-duration-last-clock` and sets it to the string "HH:MM" that is inserted in the CLOCK line in the drawer. That can then be used by the hook function as described above.
I don't know if there is demand for this feature, but you might want to suggest it as an enhancement on the Org mode mailing list. Who knows? Somebody there (or perhaps here) might have a better way of doing it, without having to make modifications to Org mode.
---
Tags: org-mode
---
|
thread-5293
|
https://emacs.stackexchange.com/questions/5293
|
How to force an org-babel session to reset or initialize?
|
2014-12-11T13:56:14.997
|
# Question
Title: How to force an org-babel session to reset or initialize?
If I run the following babel shell blocks
```
#+BEGIN_SRC sh :session one :results output
ssh staging
#+END_SRC
#+BEGIN_SRC sh :session one :results output
hostname
#+END_SRC
```
Org creates a shell buffer called `one`, runs `ssh staging` and then after connecting, executes `hostname` on staging. However, if I tweak the ssh command and run it again it attempts to run it from within session one, from the staging host. If I close the buffer `one` it resets the session as the next time any command is run with that session name it recreates it. What I haven't been able to find is a method to force a particular babel block to always initialize a new session.
I'm aware that for some languages (elisp in particular) this would not be possible. I suppose I could prepend the session with an elisp block containing `(kill-buffer "one")`, but would rather this was a header argument if possible. I'm also aware that for this example I could simply combine the two into a single block with no session, but I'm interested in more complicated sequences.
Is there a `:prologue` command or some other special argument to `:session` that forces that block to initialize a new shell on every invocation?
# Answer
> 5 votes
**Try this**
Force an org-babel session to *reset or initialize* by using an elisp conditional statement to dynamically set the value of the :session header on the first code block.
e.g. `:session (if (get-buffer "one") (if (kill-buffer "one") (print "one") (print "one")) (print "one"))`
In the above code, get-buffer function checks if buffer named *one* exists. If true, the kill-buffer function **kills** the *one* buffer then returns a value of `t` or `nil` which is passed to the `if` statement. In this specific example, the nested `if` statement will *always return a value of one*. Please note, I'm still learning elisp.
Below is the updated example code:
```
#+BEGIN_SRC sh :session (if (get-buffer "one") (if (kill-buffer "one") (print "one") (print "one")) (print "one")) :results output
ssh staging
#+END_SRC
#+BEGIN_SRC sh :session one :results output
hostname
#+END_SRC
```
Each time the first code block is executed, emacs will ask to kill the *one buffer*, so you can reset the session when you desire.
> **EDIT**
>
> **Oops** missed part that you *always* wanted buffer killed, i.e. no prompting. Execute this block first to temporarily turn off prompting to kill buffer.
```
#+BEGIN_SRC elisp
(setq kill-buffer-query-functions
(remq 'process-kill-buffer-query-function
kill-buffer-query-functions))
#+END_SRC
```
Hope that helped!
Note: This code was tested using the following versions of emacs and org-mode.
```
GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
Org-mode version 8.2.10 (8.2.10-29-g89a0ac-elpa)
```
In conclusion, I found **technical inspiration** for this answer on the org-scraps website and this kill-buffer example code on stackoverflow.
# Answer
> 3 votes
Inspired by @Melioratus.
Currently, org-babel provides a hook called `org-babel-after-execute-hook`. I extended the supported arguments of org-babel src block by using it:
(I'm using org-babel for elixir. If you want supports of other languages, extend `cond` by yourself.)
```
(add-hook 'org-babel-after-execute-hook 'semacs/ob-args-ext-session-reset)
(defun semacs/ob-args-ext-session-reset()
(let* ((src-block-info (org-babel-get-src-block-info 'light))
(language (nth 0 src-block-info))
(arguments (nth 2 src-block-info))
(should-reset (member '(:session-reset . "yes") arguments))
(session (cdr (assoc :session arguments)))
(session-process
(cond ((equal language "elixir") (format "*elixir-%s*" session))
(t nil))))
(if (and should-reset (get-process session-process))
(kill-process session-process))))
```
After evaluating above code, you can write src block like this:
```
#+begin_src elixir :session-reset yes
IO.puts("HELLO WORLD")
#+end_src
```
After evaluating src block, org-babel will cleanup the corresponding session.
---
Tags: org-babel, shell
---
|
thread-48092
|
https://emacs.stackexchange.com/questions/48092
|
Org-mode: how to collapse or merge contiguous clock time intervals
|
2019-02-27T11:00:32.253
|
# Question
Title: Org-mode: how to collapse or merge contiguous clock time intervals
I use Org-mode in Emacs to keep track of time. I sometimes clock in and out of the same task back-to-back, leading to two contiguous clock time intervals, such as:
```
CLOCK: [2019-02-27 Wed 10:21]--[2019-02-27 Wed 10:24] => 0:03
CLOCK: [2019-02-27 Wed 08:40]--[2019-02-27 Wed 10:21] => 1:41
```
To reduce clutter and disk space, I would like to combine them into a single interval such as:
```
CLOCK: [2019-02-27 Wed 08:40]--[2019-02-27 Wed 10:24] => 1:44
```
Can Org-mode automatically collapse or combine clock times together?
**Update**: this question refers to clocks under the same heading, and so is different and simpler than Merging clock logs together in org-mode, which merges clocks from sub-headings to the parent heading.
# Answer
> 2 votes
Building on @Heikki's answer, I coded the functions below. The main benefit is that I call this function automatically after clocking out and it merges if the time discrepancy is zero, so I don't need to move point to the last clock-out line. If called interactively, it prompts the user to approve a merge where the discrepancy is not zero and shows the time difference in human-readable format. I also added a regression test with the Emacs Regression Testing (ERT) framework (`(require 'ert)`) to ensure that one function works as expected.
```
(defun my-org-get-clock-segment-timestamps (line)
"Parses a clock segment line and returns the first and last timestamps in a list."
(let* ((org-clock-regexp (concat "CLOCK: " org-ts-regexp3 "--" org-ts-regexp3))
(t1 (if (string-match org-clock-regexp line)
(match-string 1 line)
(user-error "The argument must have a valid CLOCK range")))
(t2 (match-string 9 line)))
(list t1 t2)))
(ert-deftest org-timestamp-test ()
(should (equal
(my-org-get-clock-segment-timestamps "CLOCK: [2019-09-26 Thu 00:29]--[2019-09-26 Thu 01:11] => 0:42")
'("2019-09-26 Thu 00:29" "2019-09-26 Thu 01:11"))))
(defun my-org-compute-timestamp-difference (later-timestamp earlier-timestamp)
"Computes the number of seconds difference in string timestamps as a float."
(-
(float-time (apply #'encode-time (org-parse-time-string later-timestamp)))
(float-time (apply #'encode-time (org-parse-time-string earlier-timestamp)))))
(defun my-org-float-time-diff-to-hours-minutes (diff)
"Returns a float time difference in hh:mm format."
(let* ((hours (floor (/ diff 3600)))
(diff_minus_hours (- diff (* 3600 hours)))
(minutes (floor (/ diff_minus_hours 60))))
(car (split-string (format "%2d:%02d" hours minutes)))))
(defun my-org-clock-merge (&optional skip-merge-with-time-discrepancy)
"Merge the org CLOCK line with the next CLOCK line. If the last
timestamp of the current line equals the first timestamp of the
next line with a tolerance of up to 2 minutes, then merge
automatically. If a discrepancy exists, prompt the user for
confirmation, unless skip-merge-with-time-discrepancy is
non-nil."
(interactive "P")
(let* ((first-line-start (line-beginning-position))
(first-line (buffer-substring
(line-beginning-position) (line-end-position)))
(first-line-timestamps (my-org-get-clock-segment-timestamps first-line))
(first-line-t1 (pop first-line-timestamps))
(first-line-t2 (pop first-line-timestamps))
(first-line-t2 (match-string 9 first-line))
(second-line (progn
(forward-line)
(buffer-substring
(line-beginning-position) (line-end-position))))
(second-line-timestamps (my-org-get-clock-segment-timestamps second-line))
(second-line-t1 (pop second-line-timestamps))
(second-line-t2 (pop second-line-timestamps))
(diff (my-org-compute-timestamp-difference first-line-t1 second-line-t2)))
;; ignore discrepancies of 2 minutes or less
(when (> diff 120)
(when skip-merge-with-time-discrepancy
(error "Skipping clock-merge"))
(unless (yes-or-no-p (concat (my-org-float-time-diff-to-hours-minutes diff)
" discrepancy in times to merge. Proceed anyway?"))
(user-error "Cancelled my-org-clock-merge")))
;; remove the two lines
(delete-region first-line-start (line-end-position))
;; indent
(org-cycle)
;; insert new time range
(insert (concat "CLOCK: [" second-line-t1 "]--[" first-line-t2 "]"))
;; generate duration
(org-ctrl-c-ctrl-c)))
(defun my-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
(my-org-clock-merge t)
(error))
))))
(add-hook 'org-clock-out-hook #'my-org-try-merging-last-clock-out)
```
For details on testing with the Emacs Regression Testing (ERT), see this answer on StackOverflow.
# Answer
> 2 votes
This function works if the two timestamps are the same and lets the user override a timestamp difference with a universal argument:
```
(defun org-clock-merge (arg)
"Merge the org CLOCK line with the next CLOCK line.
Requires that the time ranges in two lines overlap, i.e. the
start time of the first line and the second time of the second
line are identical.
If the testing fails, move the cursor one line down.
Universal argument ARG overrides the test and merges
the lines even if the ranges do not overlap."
(interactive "P")
(let* ((org-clock-regexp (concat "CLOCK: " org-ts-regexp3 "--" org-ts-regexp3))
(first-line-start (line-beginning-position))
(first-line (buffer-substring
(line-beginning-position) (line-end-position)))
(first-line-t1 (if (string-match org-clock-regexp first-line)
(match-string 1 first-line)
(progn
(forward-line)
(user-error "The first line must have a valid CLOCK range"))))
(first-line-t2 (match-string 9 first-line))
(second-line (progn
(forward-line)
(buffer-substring
(line-beginning-position) (line-end-position))))
(second-line-t1 (if (string-match org-clock-regexp second-line)
(match-string 1 second-line)
(user-error "The second line must have a valid CLOCK range")))
(second-line-t2 (match-string 9 second-line)))
;; check if lines should be merged
(unless (or arg (equal first-line-t1 second-line-t2))
(user-error "Clock ranges not continuous. Override with universal argument"))
;; remove the two lines
(delete-region first-line-start (line-end-position))
;; indent
(org-cycle)
;; insert new time range
(insert (concat "CLOCK: [" second-line-t1 "]--[" first-line-t2 "]"))
;; generate duration
(org-ctrl-c-ctrl-c)))
```
---
Tags: org-mode
---
|
thread-52747
|
https://emacs.stackexchange.com/questions/52747
|
mu4e or mu cannot find a search term with a period
|
2019-09-20T07:39:29.780
|
# Question
Title: mu4e or mu cannot find a search term with a period
I use `mu4e` and sometimes I cannot find a message with a search term including a period. For example, if I search for `Google.org`, I see:
```
No matching messages found
```
but if I search for `"impact challenge"`, I see a message with `Google.org` in the subject line:
```
8660 28/06/2019 PS noreply@withgoo... Google.org Impact Challenge on Safety: Submission Received
```
I am able to find messages when the period is in the email address, e.g. the above message when I search for `withgoogle.com`.
The documentation on searching does not mention a special role for periods.
Am I missing something or is this a bug?
**Update**: here is the raw message with headers up to the body, replacing emails, IP addresses, signatures, and the like with `<>`. The period is in the `From` header.
```
Return-Path: <>
Delivered-To: unknown
Received: from <> (<>) by <> with
POP3-SSL; 17 Jun 2019 15:41:16 -0000
Delivered-To: <>
Received: from <> ([10.2.0.17])
by <> (Dovecot) with LMTP id O82AO0mkB10uMQAAZlJlVA
for <>; Mon, 17 Jun 2019 15:37:08 +0100
Received: from <> ([127.0.0.1])
by <> (Dovecot) with LMTP id RUIOEYJjB13EOAAAqE/zKQ
; Mon, 17 Jun 2019 15:37:08 +0100
Received: from localhost (localhost [127.0.0.1])
by <> (Postfix) with ESMTP id 5284020143
for <>; Mon, 17 Jun 2019 15:37:08 +0100 (BST)
X-Quarantine-ID: <XZvr36t3mmiF>
X-Virus-Scanned: Debian amavisd-new at <>
Authentication-Results: <> (amavisd-new);
dkim=pass (2048-bit key) header.d=google.com
Received: from <> ([127.0.0.1])
by localhost (<> [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id XZvr36t3mmiF for <>;
Mon, 17 Jun 2019 15:37:07 +0100 (BST)
Received: from <> (<> [209.85.222.173])
by <> (Postfix) with ESMTPS id BD3D75F99A
for <>; Mon, 17 Jun 2019 15:37:05 +0100 (BST)
Received: by <> with SMTP id r6so6322105qkc.0
for <>; Mon, 17 Jun 2019 07:37:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=google.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=<>;
b=<>
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=<>
b=<>
X-Gm-Message-State: <>
X-Google-Smtp-Source: <>
X-Received: by 2002:a37:696:: with SMTP id <>;
Mon, 17 Jun 2019 07:37:04 -0700 (PDT)
MIME-Version: 1.0
References: <>
In-Reply-To: <>
From: "Google.org Impact Challenge on Safety" <safety-challenge@google.com>
Date: Mon, 17 Jun 2019 15:36:27 +0100
Message-ID: <>
Subject: Re: Scope of the safety challenge
To: Miguel Morin <>, safety-challenge@google.com
Content-Type: multipart/alternative; boundary="0000000000000bc240058b85ee74"
--0000000000000bc240058b85ee74
Content-Type: text/plain; charset="UTF-8"
```
# Answer
As you can see in this issue those characters are problematic in some cases. The problem there is:
> Searching for domain names "abc.domain.com" or IP addresses "10.20.30.40" fails even though the messages are indexed and can be found by searching for other english words in them. It seems searching for strings containing dots, slashes, etc. fail without error (just return no results)
and the author replied:
> Sadly, due to the way the Xapian indexing / querying works (which mu uses), searches for such strings are problematic... not much I can do about that. ... Using spaces might help indeed; xapian sees the '.' as a word-separator.
So you can search using the words and avoiding the dots, i.e. `from:google org` in your example.
> 2 votes
---
Tags: search, mu4e
---
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.