text:
Yasnippet increment function name
I have a small snippet like this:
# -*- mode: snippet -*-
# name: options
# key: vop
# --
var options = {
    target:        '#$1',
    beforeSubmit:  showRequest,
    success:       showResponse
}$0

What I would like to do is to increment function name for each insertion. Like this:
var options1 = {
  target:        '#',
  beforeSubmit:  showRequest,
  success:       showResponse
}

var options2 = {
  target:        '#',
  beforeSubmit:  showRequest,
  success:       showResponse
}

etc... Is there a way to achieve this?

Yes, in yasnippet you can use elisp code, so it's easy:
# -*- mode: snippet -*-
# name: options
# key: vop
# --
var options`(if (boundp 'vop-count) (setq vop-count (1+ vop-count)) (setq vop-count 1) ) (vop-count)` = {
    target:        '#$1',
    beforeSubmit:  showRequest,
    success:       showResponse
}$0

If you wanna reset the counter, run (setq vop-count 0)

Thank you. But since I've less than 15 reputation I guess I can not choose it as accepted answer.

@Erdem really? I didn't know that. It seems stupid since the this site should welcome newcomers. Anyway, glad to help :)

@Erdem 15 reputation is the threshold for upvoting, you should still be able to accept the answer. http://emacs.stackexchange.com/help/someone-answers, http://emacs.stackexchange.com/help/privileges

@npostavs after your post I recognized the accept answer button. But it looks faint so I couldn't recognize it until now.


text:
Translate TAB with C-q TAB
I'm an amateur in Emacs and I would like to change TAB with C-q TAB. I used the code:
(define-key key-translation-map (kbd "TAB") (kbd"C-q TAB"))
But by doing so, I need to press TAB twice in order to get a indent and under the screen it shows C-q TAB TAB.
Why would this happen? How can I get the indent only by pressing TAB once?

What is it that you are really trying to do? If you want TAB to just insert a TAB character then bind TAB to self-insert-command. But be aware that various modes bind TAB in other ways, so you may need to either bind it to what you want in those modes or define a minor mode where you bind it to what you want, and then turn on that minor mode.

@Drew that's what I want. Can you tell me how to achieve it exactly?

Then the answer you want is here. And really this question should probably be closed as a duplicate of that one (or nearly duplicate - at least that answer is what you're looking for).

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
OS X emacs: difference between X11 vs NS vs Cocoa?
I believe, there are three ways to build emacs on osx --- x11, ns (nextstep?), and cocoa. Can anyone explain what the build options mean / the difference between these three are?

It has been a few months since I built the x11 version on OSX, but it took me a little bit of time to figure out that it was necessary to use --with-ns=no --with-x as part of the command line options.  I mention this just in case anyone else is interested in building the x11 version on OSX.  I would imagine that the accepted answer will include a mention of the materials needed for a successful build -- e.g., XQuartz (The X Window System), etc.

@lawlist ah, good to know! one of the reasons for me asking this question is because I was looking to build emacs with x11 (for xwidgets) on osx, but I was wondering if I would lose anything from going from NS to x11.

See this related thread entitled "Compile emacs with xwidget under OSX?":  http://emacs.stackexchange.com/questions/25037/compile-emacs-with-xwidget-under-osx  The custom keyboard shortcuts that I rely upon in the GUI version of Emacs built --with-ns don't work in the x11 version, so I haven't really been able to use the x11 productively yet.  I would need to learn how to configure alternative keyboard shortcuts in x11 -- the Linux users would probably be right at home with the x11 version, but I'm kind of lost.

There are a number of Emacs versions for macOS, including:

The official Emacs on macOS is build using the "NS" port, also known as the "cocoa" port. As the name suggests, this port of Emacs originates in Emacs for the NextSTEP operating system and has been the official Emacs GUI on macOS since Emacs 23.
Mitsuharu Yamamoto-san maintains the "Mac port" of Emacs. It provides an alternative GUI with a different feature set compared to the NS port. This originates from the Emacs port to Mac OS 8/9 and the "Carbon" port of Emacs 22. (This port is also referred to as the "railway cat" Emacs, as this is where the brew recipe is hosted.)
Aquamacs is based on the NS port of Emacs and contains a number of enhancements making it behave more like traditional macOS applications.
X11: It is possible to build Emacs with the same GUI as used on X11 system, however it requires a X11 server to run. Unfortunately, the end result will not have macOS look and feel -- things like menus looks as though you were running on a unix-like system. In fact, this is not one GUI but a family of GUI:s as it's possible to build using different X11 support libraries like GTK+.
Terminal only. This gives you an Emacs that only can run in a terminal window, much like a GUI Emacs behaves when passed the -nw option.

So, which should you pick?
If you are lazy, pick the official Emacs -- you can download a prebuilt version from https://emacsformacos.com.
If you want to spend some time on getting the best Emacs for you, try both the official Emacs and the "mac" port. Overall, they are fairly similar but provides a slightly different feature set.
Generally, I would not recommend using the X11 port as you wont get macOS look and feel, however in some situations it might be of interest:

You want a feature only available in the X11 port, like support for xwidget
You are accustomed to X11 and want the exact same look and feel when using Emacs on macOS
You want a "reference" implementation of Emacs, e.g. when contributing to the NS port of Emacs.

you might also need the x11 variant if you are installing it on a remote host you're ssh-ing into :-)

What about Doom Emacs or Spacemacs ? Could you update the post to include them ?

@LudovicKuty, unfortunately no, since I don't know anything about them. However, I think that they are independent of the Emacs variant used and only change things on the lisp-side.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Set a buffer/file local variable in elisp like a file local variable
I'm looking for a way to set a variable that isn't buffer local in such a way that it will act like one.
It's possible to do it with file local variables, but I haven't found a way to set a variable in this way from elisp.
I don't want to rely on defining file local variables with comments inside of them.

If you want to set a buffer-local value for a variable, use setq-local.
Depending on what you are actually trying to accomplish, you may also want to look at the help for make-local-variable and make-variable-buffer-local. These functions do not actually set a value, but arrange for a variable to have a buffer-local value when set.

Neither make-local-variable nor make-variable-buffer-local "set[s] a buffer-local value for a variable."


text:
No company mode found in packages list
I want to install the company mode, but searching in the M-x list-packages i find no company mode found, but a bunch of company backends for different languages. How should i install company?
PS: This is my init.el file beginning:
(require 'package)

(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
             '("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; elpy
(add-to-list 'package-archives
         '("elpy" . "http://jorgenschaefer.github.io/packages/") t)
(when (< emacs-major-version 24)
  ;; For important compatibility libraries like cl-lib
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))

(package-initialize)

company-mode should be part of GNU Emacs, i.e. there is no need to install it separately. What version of Emacs are you using (M-x emacs-version)?

I have Emacs 24.4.1. So it suffices to add (add-hook 'after-init-hook 'global-company-mode) to the init.el file?

Yes, that should work. Also consider using the sharp quote (#') for functions like global-company-mode.

"company-mode should be part of GNU Emacs" No, it isn't.

@Dmitry The company.el file says ;; This file is part of GNU Emacs.

@TianxiangXiong Do you see which directory this file is in?

@TianxiangXiong Company is available from ELPA, which is the official package repository and is enabled by default. The license text is required as part of submitting to ELPA. It is still necessary to actually install the package to use it.

Got it, thanks. I was under the impression that the blurb was required only for code shipped with Emacs.

The bit of configuration you provided does not actually evaluate, so I suspect your package list is not configured correctly. (Try it: copy your add-to-list code above in to a scratch buffer and then call M-x eval-buffer to see the error.)
Use C-h v package-archives to check the value. Or try the Customize interface, with: M-x customize-option package-archives.
Note that company is not part of the standard Emacs distribution and must be installed. However, it is available in the GNU ELPA repository, which should already be configured in the default package-archives. So you should be able to start Emacs without any custom configuration and use package-install to install it.
See: https://elpa.gnu.org/packages/company.html

I tried to install company with package-install, there are only company-backends as choice. I cannot see any company to install

Did you try removing your package archives configuration or checking what the actual value is? As I noted one can start a clean installation of Emacs with no customization and install as described, so there must be a non-default configuration here that is causing problems.

'package-archives is a list of dotted pairs. So your code should be:
(setq package-archives
      '(("elpy" . "http://jorgenschaefer.github.io/packages/")
        ("melpa" . "https://melpa.org/packages/")
        ("gnu" . "http://elpa.gnu.org/packages/")
        ("melpa-stable" . "https://stable.melpa.org/packages/")))


text:
How to search in multiple files with Emacs without grep?
There is a folder with many sub-folders, files and I would like to search for a given piece of text in all of these files with Emacs on a Windows 10 machine. (I know about M-x grep, but it does not work in Windows environment.)
Is there any way to start such recursive search from within Emacs on Windows 10 without installing additional software or extensions?
(The question marked as a "possible duplicate" is different. My question is about searching in files' contents. The another question is about searching for files.)

M-x grep works just fine in Windows if you install grep. In general, Emacs works best with certain Unix-y command line tools installed as well. If you have no issue installing Emacs, I can't imagine why you'd have an issue with installing the additional software that Emacs wants to be able to use.

Agreed. The emacs experience on windows is improved dramatically with something like msys2.

If you only need to know if a regular expression is present in files, then you can use the % g command in dired.

I don't have time to check now, but this smells like a duplicate. I'm pretty sure there are other questions about searching a set of files etc.

Possible duplicate of How to search for files from a root directory and get the results as a dired buffer?

Phils, InHarmsWay, thank you. Sure, I can install some additional software, I just wanted to find out if it is possible without those extra tools. I'm absolutely grateful to have your answers. Should I consider closing this question and asking "what tools to install on Windows 10 to get a unix-like environment around Emacs"?

You can try elgrep.

M-x grep works fine without additional tool on windows 10. Do followings:
M-x grep enter
then minibar shows: grep  -nH --null
Change it to: grep -nHR -e searchText
then enter.
source: https://stackoverflow.com/a/1332102/4466255

The Elisp package elgrep is a swiss army knife for searching files.
It is available on melpa.
There are no dependencies on external tools as long as you do not search the contents of pdf documents.
Only an excerpt of the features:

By default you can do a simple regexp search in the files of the specified directory.
You can recurse into subdirectories. The minimal and maximal recursion depth can be set.
You can specify a regexp for the names of the files that should be searched.
You can specify a regexp for the names of the files that should be excluded from the search.
You can split files into records by regular expressions. By default the full file is one record. You can also use Elisp functions for finding the beginning and/or end of a record.
You can specify multiple search expressions as preconditions that must be present in the record to generate matches for the first regular expression.
Preconditions can be negated by a leading !. A negated precondition must not occur in the record to be selected for output.
The search function can be changed. E.g., with cexp-search-forward from the library cexp you easily get a powerfull BibTeX database query.
You can display the search results with specified context.
Example: The buffer is narrowed to a record when that record is searched. So you can specify elgrep/point-min and elgrep/point-max as context boundaries to display the full record if it matches.
By default only the line with the match is shown.
You can edit the search results and write the edited stuff back to the corresponding files if the files are editable in Emacs.
Search queries are automatically saved. They are preserved in the elgrep-call-list if you name them. This list is saved to disk at exiting Emacs and reloaded when elgrep is loaded.

Example of the buffer with the search results:

The Elgrep menu settings that returned these search results (only a few are modified):

You can use Windows' builtin findstr command with M-x rgrep:
(when (eq system-type 'windows-nt)
  (with-eval-after-load 'grep
    ;; findstr can handle the basic find|grep use case
    (grep-apply-setting 'grep-find-template
                        "findstr /S /N /D:. /C:<R> <F>")
    (setq find-name-arg nil)))

It's not as versatile as grep, but it's fine for searching for fixed strings.  Also note that Emacs sometimes suggests globs like *.[ch] but you need to use *.c *.h instead (use C-q SPC to enter the space).

you can try the xah-find package.
https://github.com/xahlee/xah-find
it is pure elisp, and designed just for emacs without external grep tools.

404 not found

You could try Emacs Helm which is available to install from MELPA Stable. The Helm framework allows you to easily and intuitively work with files, directories and buffers. Moreover, it provide simple access to common Helm commands such as grep, find, locate, etc...

If you don't have grep (or similar) installed, I don't imagine helm is going to help?

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Can emacs emulate zgrep -a in zrgrep?
Currently I can grep (in command line) the gzip files I receive using the command zgrep -a something logs.tar.gz it outputs every line inside the logs.tar.gz but without the file where it was found, so is 80% useful.
Then I turned to emacs but when I do the equivalent command zrgrep I get only the Binary file ./logs.tar.gz matches, when I click it opens the tar.gz file, but I don't see the matches.  I tried to visualise it by installing ascii with el-get without success and read over the different greps. Unfortunately I didn't find any clue on how to grep the open gz file in the buffer, it always refers to a physical dir. So currently I need to uncompress it and do the regular grep (that works well)
Is it possible to have the possibility to pass the command -a to get it in ascii text?
or
Is there any possibility to run a grep (or equivalent command) on the buffer I have the gz file open?

See some useful answers here: http://stackoverflow.com/questions/2407111/performing-grep-operation-in-tar-files-without-extracting unfortunately, zgrep cannot do what you want.

@wvxvw thanks for the info, I also landed in that question before. Find it a pity that you can't run the grep against the buffer. I guess is not that trivial to  use the buffer as a fs to grep over the files that are there. It would be helpful as you face no IO constrains.

Well, you'd need to extend tar-mode with an ability to, say, mark entries and then you could run zgrep -Hna plus a wc -l on each of the archived files to figure out what offset relates to what file... but this sound like quite a bit of coding...


text:
elpy [No match] when installing package
I'm trying to follow the instructions in the README of this repo: https://github.com/jorgenschaefer/elpy . Everything goes smoothly until I get to the point where I am to install the package. After typing elpy and pressing enter I get a [No match] result. Any thoughts?
Here is what happens in detail. I copy and paste:
(require 'package)
(add-to-list 'package-archives
             '("elpy" . "https://jorgenschaefer.github.io/packages/"))

into my scratch buffer. I then type M-x ev-b RET and see no response in the minibuffer. I then type M-x package-refresh-contents RET and see a few quick messages fly by including what seems to be a connection to the github repo and culminates in a 'Package refresh done' message. Finally, when running M-x package-install RET elpy RET I receive a 'No Match' message and a prompt for 'Install package:'.
After all this, upon running C-h v package-archives I get:
package-archives is a variable defined in ‘package.el’.
Its value is (("gnu" . "http://elpa.gnu.org/packages/"))
This variable may be risky if used as a file-local variable.
Documentation:
An alist of archives from which to fetch.
The default value points to the GNU Emacs package repository.
Each element has the form (ID . LOCATION).
 ID is an archive name, as a string.
 LOCATION specifies the base location for the archive.
  If it starts with "http:", it is treated as a HTTP URL;
  otherwise it should be an absolute directory name.
  (Other types of URL are currently not supported.)
Only add locations that you trust, since fetching and installing
a package can run arbitrary code.
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 24.1 of Emacs.
[back]

It sounds like you haven't properly added the elpy repository from the previous step. What does Emacs tell you after C-h v package-archives?

Please specify precisely/concretely what you've done in order to get to the point of typing "elpy".  Just saying that you followed some instructions is not enough (because those instructions may be different/disappeared when this page is read, and because you may have misunderstood those instructions).

@Tyler when I run M-x ev-b I see no result in the minibuffer. When I run M-x package-refresh-contents it seems to go smoothly and ends with a "Package refresh done" . The first hint of something wrong is at the M-x package-install stage

@Stefan I tried to be more specific above

You haven't answered my question - what is the value of package-archives? You also haven't addressed Stefan's question - please include the exact steps you have taken here, don't just link to another page.

@Tyler I added output of C-h package-archives to my question

Ok. That tells us that you haven't actually correctly followed the steps on the page you've linked to. That's why it's important that you list the steps you actually did take here. Otherwise, we're just guessing at what you've done.

@Tyler I copied and pasted the text into the scratch buffer and typed M-x ev-b RET. Then M-x package-refresh-contents RET. then M-x package-install RET elpy RET which is when I see the No match

Again, please edit the question to include each step you have taken, what you expected to happen, and what actually happened.

@Tyler I edited the question and have described the steps. I cannot be more specific unless you have a particular question. Thanks for the help

Use melpa which is the most popular elpa in the community. https://melpa.org/#/getting-started

The add-to-list form you show above should have the effect of adding the elpy repository to your package-archives. So C-h v package-archives should tell you:

package-archives is a variable defined in ‘package.el’.
  Its value is (("elpy" . "https://jorgenschaefer.github.io/packages/")
   ("gnu" . "http://elpa.gnu.org/packages/"))
Original value was
  (("gnu" . "http://elpa.gnu.org/packages/"))

The fact that this isn't happening suggests that add-to-list isn't getting executed properly. I'm not sure why this would be, given the steps you've described.
Another way to accomplish the same thing is to add the code (the require and add-to-list forms you quote) to your config file  (~/.emacs or ~/.emacs.d/init.el) and restart emacs. There's no harm in running those two lines every time you start emacs, and that should definitely set your package-archives properly.
At that point, you should be able to proceed with installing elpy: M-x package-refresh-contents followed by M-x package-install RET elpy RET.
It's a bit odd though, as what you've described should work.

Sorry for being 2 years late, but unless you already solved your question, the solution is simply to change https://jorgenschaefer.github.io/packages/ to http://jorgenschaefer.github.io/packages/ since the somewhat hacky nature of Emacs doesn't allow it to handle https correctly (at least not on Windows).


text:
Matching categories '\cX' and digit
The regex info material suggests that \\c6 should match digit characters.
In UTF-8 encoded buffers it doesn't; some of the other category letters work as expected (l, |, a).
Shouldn't \\c6* match 456 in test456test? What do I overlook, misunderstand?

It seems the main problem is that the ascii characters 0..9 aren't in the digit category, C-u C-x = shows category: .:Base, a:ASCII, l:Latin, r:Roman (it also has general-category: Nd (Number, Decimal Digit), but apparently that's not what \cC looks for).

Shouldn't \\c6* match 456 in test456test?

Also note that \\c6* matches the empty string.
(let ((str "test456test"))
  (list (progn (string-match "[0-9]*" str) (match-string 0 str))
        (progn (string-match "[0-9]+" str) (match-string 0 str)))) ;=> ("" "456")

What is general category? I cannot find regex syntax to specify Nd. [0-9] what I used instead as \c6 is not what it looks.

As far as I can tell, there isn't a regex syntax for general-category.


text:
In org-mode, can I include a horizontal separator in a result table generated by an Emacs Lisp code block?
I have some Emacs Lisp code blocks in an Org file which I evaluate to get tables of results.  It would be nice if I could include horizontal separators to separate individual lines of data from headers and summary lines, because that makes it easier to use org-sort.  Concretely, I have something like this:
#+BEGIN_SRC emacs-lisp
'((foo bar baz) (1 2 3) (4 5 6))
#+END_SRC

#+RESULTS:
| foo | bar | baz |
|   1 |   2 |   3 |
|   4 |   5 |   6 |

but it would be nice if I could make the output automatically format itself more like this:
#+RESULTS:
| foo | bar | baz |
|-----+-----+-----|
|   1 |   2 |   3 |
|   4 |   5 |   6 |

Is there an easy way to do this?  I thought that including nil in place of a row of results might do the trick, but it seems not to do the trick.

Looking at org-babel-get-colnames, the easiest way to do this probably is adding an hline as second element of your list:
#+BEGIN_SRC emacs-lisp
'((foo bar baz) hline (1 2 3) (4 5 6))
#+END_SRC

#+results:
| foo | bar | baz |
|-----+-----+-----|
|   1 |   2 |   3 |
|   4 |   5 |   6 |

Exactly what I was hoping for! Thanks.


text:
Magit + Emacs + Windows: 7 alert dialogs on first use?
Background
The first time I run magit-status after starting Emacs, I get a series of 7 alert dialogs popping up. Each one just says "emacsclient 25.1" and has an OK button. They don't seem to do anything at all.
Nothing in the *Messages* buffer seems to relate to this.
I saw some reference in the Magit manual about needing to locate emacsclient, so I did put C:\Emacs\bin into my path.
This only happens the first time. After that, magit-status works fine without any popups at all.
Edit More information... It looks like this is coming from within Magit's with-editor-locate-emacsclient.
I just tried running that function directly. Got the same bunch of dialogs. After confirming them all (they only have "OK" buttons, so confirm it is, I guess!) I get something in *Warnings*:

Warning (with-editor): Cannot determine a suitable Emacsclient
Determining an Emacsclient executable suitable for the current Emacs
  instance failed.  For more information please see
  https://github.com/magit/magit/wiki/Emacsclient. Warning
  (with-editor): Cannot determine a suitable Emacsclient
Determining an Emacsclient executable suitable for the current Emacs
  instance failed.  For more information please see
  https://github.com/magit/magit/wiki/Emacsclient.

It looks a lot like a path problem, even though the directory that has emacsclient.exe is on my path.
System Config

Magit 2.10.2
Windows 10
Emacs 25.1.1

Solved
Magit has a library called with-editor that attempts to locate a suitable emacsclient on the host machine.
For some reason, the emacsclient.exe in Emacs 25.1 for Windows doesn't report its version to the console. Instead it pops up the dialog box I've been seeing.
See https://github.com/magit/with-editor/issues/21 for another report of the same issue.
As suggested by the maintainer of Magit, I set with-editor-emacsclient-executable to nil, but only on Windows:
(if (eq system-type 'windows-nt)
    (setq with-editor-emacsclient-executable nil))

After that, no more popups.

I would recommend that, instead of using nil, you manually determine the path to the emacsclient executable and use the path to that as the value. Of course the downside is that the location may change, and then things break again, but you could counter that by checking whether the path is still valid and else falling back to nil.


text:
Wedding anniversaries with org-contacts
I successfully managed to add birthdays with org-contacts using the :BIRTHDAY: property, but what about some other kind of anniversaries such as wedding anniversaries? How can I set them? Can I use the :WEDDING: property for example?

That's the nice thing about org property drawers.  You can put nearly anything in them.  With respect to org-contacts.el: the anniversary(birthday) logic would need to be refactored to support generalized (i.e. labeled) anniversaries like describe.  FWIW: using :WEDDING: properties is be exactly where I would start :-)


text:
Gnus C-c C-c opens a blank browser window
I am not able to send any mail from gnus. Upon hitting C-c C-c after writing the mail a blank window opens up in my webbrowser and nothing more happens (in the echo-buffer emacs says Starting Firefox...).
Also the mails showing in the INBOX group is not complete and up to date.
How should i get gnus to send and get mails?

It sounds like you have conflicting key bindings. When I compose an email, C-c C-c is bound to message-send-and-exit. Use C-h k to see what yours is bound to; that should help you track down the problem.

This is not a conflict. Doing M-x message-send-and-exit results again in a blank browser window

I have the exact same problem. Have you found any solution since then?


text:
Searchably record meeting attendees
To aid minuting staff meetings in a small organisation, I considered creating a property called :Attendees: and defining the allowed values for that property, e.g.:
* Meetings
       :PROPERTIES:
       :Attendees_ALL: Amy Bob Joe Max Sam Zoe
       :END:

and then using them like this:
** Meeting 2017-05-17
       :PROPERTIES:
       :Attendees: Amy Joe Zoe
       :END:

However, I then spotted that "a property can only have one entry per Drawer." So, Org-mode properties might not be a suitable tool for this after all.
I could use a simple list, I suppose, but I want to easily be able to create sparse trees matching who was at a meeting.
Using tags is also an option, but would be quite intrusive: potentially quite a long list of tags for each meeting. And not easily extendable to "Apologies", i.e. people who could not attend.
What might be a better solution?

I haven't tried this, but it seems to me that if only one entry is allowed (and I'm taking your word for it), then one entry might be a list:  '(Amy Bob Joe Max Sam Zoe)?  I have no idea if we need double-quotes around each name, but I suspect it will be sufficient to use things like (format "%s") to convert when extracting to avoid things like a void variable, etc. ...  It may be fairly easy to treat everything in the property drawer as  one entry, but I haven't looked at the applicable code.

You can use exactly what you are trying to do like this.
Use regular expressions like this in your match expressions: Attendees={Joe\|Bob} to see meetings attended by Joe or Bob, or Attendees={Joe}-Attendees={Max} to see meetings attended by Joe and not Max.
Assuming you put an id like this in your heading with all the attendees (so you can retrieve them all later):
* Meetings
       :PROPERTIES:
       :CUSTOM_ID: main
       :Attendees_ALL: Amy Bob Joe Max Sam Zoe
       :END:

You can use a function like this:
#+BEGIN_SRC emacs-lisp
(require 'dash)
(defun absent ()
  "Determine who was absent from the meeting."
  (interactive)
  (message "%s"
       (-difference
        (save-excursion
          (org-open-link-from-string "[[#main]]")
          (org-entry-get-multivalued-property nil "Attendees_ALL"))
        (org-entry-get-multivalued-property nil "Attendees"))))
#+END_SRC

to find who is absent.

Thanks :) Unfortunately, in Spacemacs, M-x org-sparse-tree RET r Attendees={Joe\|Bob} RET yields 0 match(es) for regexp Attendees={Joe\|Bob}, even if the file contains entries with property drawers containing, e.g. Attendees: Amy Joe Bob. Was org-sparse-tree the command you had in mind for use with the match expressions you described?

You want =M-x org-sparse-tree RET m Attendees={Joe|Bob} RET=. The key is to do a "match" on the tags/properties. I think r probably does a regex match on the headings.


text:
comint-mode problem with C++ style comments (and quotes)?
This is a rephrase of my SO question https://stackoverflow.com/questions/44147993, which didn't receive much attention in SO.
Basically, I suspect that I enountered a problem with nodejs-repl.el (which is based on comint-mode) when C++ style comments are mixed with quotations.
For example, when evaluated using nodejs-repl-send-region, the following line:
var says = function ( ) {  return this.saying || ''; };

gives an error :
var says = function ( ) {  return this.saying   ''; };
SyntaxError: repl: Unexpected token, expected ; (1:48)
> 1 | var says = function ( ) {  return this.saying   ''; };

|| seems to have been dropped. There is no error if I replace || with +.
Another example:
var url = "http://www.ora.com:80/goodparts?q#fragment";

gives:
> var url = "http:/*www.ora.com:80/goodparts?q#fragment"; */
SyntaxError: repl: Unexpected token (1:56)
> 1 | var url = "http:/*www.ora.com:80/goodparts?q#fragment"; */

Here, http:// seems to be misinterpreted as http:/*, beginning a comment, despite the fact that // is in a quote.
In both cases, the error only occurs when the problem lines are sent from the buffer to the REPL using nodejs-repl-send-region. No error is returned if the line is evaluated directly in the REPL.
Can anyone please help explain how to fix my Emacs environment (maybe nodejs-repl.el or the underlying comint-mode)?
I have tested this under Emacs 24.5 (Ubuntu 16.04) with a minimal .emacs.d/init.el file below (as suggested by the nodejs-repl.el homepage):
$ cat .emacs.d/init.el
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

(require 'comint)
(add-to-list 'comint-preoutput-filter-functions
         (lambda (output)
           (let ((case-fold-search nil))
         (replace-regexp-in-string "\033\\[[0-9]+[A-Z]" "" output))))

(setq babel-repl-cli-arguments '("--presets"  "es2015" ))

;; Interactive commands
(eval-after-load 'js2-mode '(progn
  (define-key js2-mode-map (kbd "C-c C-b") 'babel-repl-send-buffer)
  (define-key js2-mode-map (kbd "C-c C-z") 'babel-repl)
  (define-key js2-mode-map (kbd "C-c C-r") 'babel-repl-send-current-region)

Other than the init.el, I have installed babel-repl using ELPA and its folder looks like:
elpa/babel-repl-20160504.1501/

-- EDIT --
@db48x Further info about my system:
emacs -Q works fine with a normal welcome screen. So does emacs --debug-init and emacs --debug-init -Q. emacs --version says GNU Emacs 24.5.1.
If tested with the following .js file:
$ cat test2.js
var says = function ( ) {  return this.saying || ''; };

the outcome is:
$ emacs --script test2.js
Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50mmm-mode.el (source)...
Loading /etc/emacs/site-start.d/50proofgeneral.el (source)...
Loading /usr/share/emacs24/site-lisp/proofgeneral/generic/proof-site.elc...
Loading /etc/emacs/site-start.d/50psvn.el (source)...
Loading /etc/emacs/site-start.d/50python-docutils.el (source)...
Symbol's value as variable is void: var

I can't reproduce the problem, with or without your configuration options. Does the problem still happen if you run emacs -Q? What about if you run emacs -Q but specifically run those two lines of your emacs configuration? Does the problem go away if you upgrade to Emacs 25?

run emacs -Q, then open up your init.el and use C-x C-e to execute just the lines you care about. Then you can compare the results after executing each one, and see (if) they're the cause.

@db48x Thanks. But when I use C-x C-e to evaluate init.el, the line (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) does not seem to have effect on .js files that I am opening (C-x C-f) for test. Nor is the babl-repl command available via M x. The init.el above is complete. Am I missing some other system wide configuration files that load e.g. elpa/?

Well, before we dive into that, what was the result with just emacs -Q? If the bug still occurs, then the problem is not your configuration.

@db48x I've added updated info about my emacs configuration. Please see the edit.


text:
How to get proper hostname instead of NETBIOS name
I'm using emacs 25.2.1 on Windows with spacemacs (0.200.9). I also start emacs as a service using emacsclientw.exe --daemon. I'm attempting to get the current host name using (system-name) as follows:
(defconst jp-hostname
  (car (split-string (system-name) "\\." t)))

Unfortunately, when I do this, the jp-hostname variable contains the NETBIOS name instead of the hostname. For example, my laptop's name is "jaundiced-outlook", but jp-hostname is set to "JAUNDICED-OUTLO".
Calling (system-name) after emacs is up and running returns what I would expect: "jaundiced-outlook".
By waiting until emacs is finished loading and executing the above code using eval-region, jp-hostname gets set correctly to "jaundiced-outlook".
Is there a reason for this behavior? Is there a way to get around this kind of thing?

How are you evaluating that using Emacs in the case where it returns the wrong value, if you are not doing that "after emacs is started"? It's not clear (to me) just what you are doing. You might want to provide a recipe, starting with no init file.

When I start emacs using -q, (message (system-name)) displays the NETBIOS name in the messages buffer. The "after emacs is started" would occur if I select the code in question and run eval-region. I'll clean up the question appropriately.

Eventually, the only reliable way I found to resolve the issue (how do I get the host name, not the NETBIOS name) was to shell out to the hostname command:
(defconst jp-hostname
  ;; This should use the following line, but it doesn't work for some reason
  ;; So, instead, we resort to shelling out
  ;; (car (split-string (system-name) "\\." t))
  (string-trim (with-output-to-string
    (call-process "hostname" nil standard-output nil))))


text:
Can't insert diary block entries
I am having problem with inserting diary block entries into my calendar. In the homepage i read that i b starts a block entry, pressing i b on the calendar mode however i see No mark set in this buffer in the echo erea. I also tried M-x and then diary-insert-block-entry in the calendar mode, got the same error.
Can anyone help?

The manual https://www.gnu.org/software/emacs/manual/html_node/emacs/Special-Diary-Entries.html#Special-Diary-Entries says that i b is for "Add a block diary entry for the current region (diary-insert-block-entry)."  Did you select a region beforehand?

@lawlist How can i select a region inside of calendar?

The doc-string for diary-insert-block-entry is insufficient (even for an intermediate Emacs user such as myself) and I needed to actually visit the code with M-x find-function to see what was going on.  I initially tried selecting a region with shift-arrow, but that didn't work.  Then, I tried selecting a region with a mouse in all different shapes and forms, and none of those worked.  Finally, I came up with this three-step approach:

Place the cursor on the beginning date and press C-SPC to set the mark.
With the arrow key, move to the ending date.
Press: i b


text:
Seeking an editing mode to ensure appropriate percolation of changes in function signatures
Function calls come in chains. f1 calls f2; f2 calls f3; etc.
When the signature of one function along the chain changes during refactoring, the change often percolates up and down the chain.
With stock Emacs one can simply use C-x 3 (split-window-right), but that means frequently bringing down the split (C-x 1, C-x 0), and continuously hunting down for the path/to/file along the chain of files.
A user interface that would make it possible to swipe to left/right along the chain would be nice. Can you suggest a mode that would facilitate this kind of interaction?

On a Mac, Desktops somewhat help, as in the picture below. Though this still requires a lot of synchronization between (Mac) Desktops, (Emacs) frames, and (Emacs) windows.

Ideally, C-x 3 would be within a special mode that is augmented with, say, push-window-vertically-on-right, followed by shift-windows-vertically-left/right. Does anything resembling this already exist?

The title of the question seems unrelated to the question itself. I suggest that you make this one a frame/window creation question and, if you like, ask a new one about refactoring.

It seems you want to be able to quickly move from one frame to another.
There are various ways to do that.

You can cycle among frames using command other-frame.
If you use Icicles then you can use command icicle-select-frame (C-x 5 o) to cycle (e.g. using the arrow keys) among frames, in various orders, or to select frames by their names, with completion.
If you use library Frame Move then you can use the arrow keys to move among frames.

See the Emacs Wiki Frames category page for more possibilities.
Others here will no doubt mention additional libraries/methods.


text:
Async shell command can't find command
I have installed the Rust programming language (Debian). Now i can compile and run programs from terminal (with the cargo build and cargo run commands), but not from inside emacs. The cargo compiler stays on my system in /home/me/.cargo/bin/cargo and emacs is not looking there to find the interpreter. I get this error /bin/bash: cargo: command not found by running M-x &, cargo build. So how can i tell emacs the address of cargo binary, or is it better to send the binary to the address emacs looks in?

I think you forgot to add export PATH="$HOME/.cargo/bin:$PATH" to your bashrc ? You should also try cargo.el.

export PATH="$HOME/.cargo/bin:$PATH" is already in bashrc. I have installed the cargo.el package, same error. Emacs can't find the cargo binary.

I set up the exec-path variable so that emacs finds the cargo binary at ~/.cargo/bin:
(setenv "PATH" (concat (getenv "PATH") ":" (expand-file-name "~/.cargo/bin")))
(setq exec-path (append exec-path (list (expand-file-name "~/.cargo/bin"))))


text:
Use several Emacs configurations/versions simultaneously
I want to use several emacs configurations/versions simultaneously so that no configuration disturbs each other, each with their own configuration directory and elpa repository.  I heard about the trick with symlinking ~/.emacs.d and ~/.emacs, but that is not what I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.
Is there any decent way to do this?

Related: How to start emacs with a custom user-emacs-directory.

I just did that using chemacs.
Considering you don't have an .emacs file in your home folder you can follow this instruction to install it:
Clone the Git repository, and run install.sh
$ git clone https://github.com/plexus/chemacs.git
$ cd chemacs
$ ./install.sh

you should get this message:
OK      Creating symlink ~/.emacs -> /home/arne/chemacs/.emacs

If you already have an .emacs file, rename or move it somewhere.
Next step, create  the file: .emacs-profiles.el in your home folder:
$ touch .emacs-profiles.el

Here is an example of the this file:
(("default" . ((user-emacs-directory . "~/.emacs.d")))
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs"))))

Mine looks like this:
(("default" . ((user-emacs-directory . "~/.emacs.d"))) ;; DoomEmacs, my default emacs
 ("prelude" . ((user-emacs-directory . "~/emacsprelude/.emacs.d"))) ;; Prelude
 ("goodemacs" . ((user-emacs-directory . "~/myemacs/.emacs.d")))    ;; my own config
 ("spacemacs" . ((user-emacs-directory . "~/spacemacs/.emacs.d")))) ;; Spacemacs

Here I create the file ~/myemacs/.emacs.d/init.el, for my own config.
Now to use a config, I run one of the following command:
$ emacs --with-profile
$ emacs --with-profile myemacs
$ emacs --with-profile prelude
$ emacs --with-profile spacemacs

Hope this help.
Update:
There is a newer version of chemacs called chemacs2.
Update 2:
Emacs 29 has now this feature built-in.

I wanted the same and stumbled across a tip at the Spacemacs Github site, so I came up with the following script, which assumes that alternate configurations are stored in ~/alternate-emacsen/NAME-OF-CONFIG. I use this eg. to test emacs26 pre-release while working with a plain emacs25 and being able to use spacemacs, doom emacs or any variant configuration whenever I want to.
The script resides in ~/bin and assumes that <name-of-config> and the name of the softlink which calls it are identical; eg. if you want to launch the config stored in ~/alternate-emacsen/deepin-emacs you need a softlink ~/bin/deepin-emacs.
Be sure to put .emacs.d inside the <name-of-config> directory since the latter is used as a fake home directory, so that the actual ~/.emacs.d and ~/.emacs do not get touched.
If you think this is useful or suits your needs, feel free to use it.
#!/bin/bash

# alternate-emacsen ––  A bash  script to launch  Emacs in  completely different
#                      configurations,   like   GNU   default,   Deepin   Emacs,
#                      Spacemacs, CL  server,… from  their own  config directory
#                      trees.
# Usage:
# – create  a  directory  $HOME/alternate-emacsen/name-of-config,  containing  an
#   .emacs.d with all the base configuration  inside it.  Put the init file into
#   <name-of-config> if necessary.
# – create a link  to this script, eg.
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/emacs-unstable
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/spacemacs
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/doom-emacs
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/deepin-emacs
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/prelude-emacs
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/emacsstarterkit
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/exwm
#           ln -s $HOME/bin/alternate-emacsen.sh $HOME/bin/clemacsd
# – set  $emacsbin below to   the  emacs  version  you  prefer/use.  or   set  it  to
#   /usr/bin/emacs  for  the  system's  default.   I  use  emacs-25.2  with  the
#   Athena/Lucid X widget set  as my default GUI (not GTK because  I do not like
#   it for several reasons), so it is set as default.
# – edit the  emacs2x entries to reflect  your preferences like in  the previous
#   step.

self="emacs config launcher";
emacsconfig=`basename -- "$0"`;
userhome=$HOME;
HOME=$HOME/alternate-emacsen/$emacsconfig;

test -d "$HOME" || { \
             echo >&2 "$self: ERROR –– $HOME does not exist!";
             exit 1;
};

# On my system, Emacs 23.2/GTK2 (in /usr/bin) is the default, but I prefer Emacs
# 25  with pure  X11  Lucid interface.   Also, the  system  default uses  partly
# incompatible ELisp packages (both to Emacs 23  and Emacs 25), so I ignore them
# by not using /usr/share/* at all (the  other Emacsen are compiled to reside in
# /usr/local and thus ignore the outer /usr tree).
emacsbin=/usr/local/bin/emacs-25.2-lucid;
sysdefaultemacs=/usr/bin/emacs;
emacs23=$sysdefaultemacs;
emacs24=/usr/local/bin/emacs-24.4-lucid;
emacs25=/usr/local/bin/emacs-25.2-lucid;
emacs26=/usr/local/bin/emacs-26;
emacstesting=$emacs26;

case $emacsconfig in
    spacemacs|deepin-emacs|clemacs|doom-emacs|prelude-emacs|emacsstarterkit)
       emacsbin=${emacs25};
       ;;
    exwm)
       emacsbin=${emacs24};
       ;;
    emacs-testing|emacs-unstable)
       emacsbin=${emacstesting};
       ;;
    *)
       HOME=$userhome;
       ;; # use emacsbin as defined in the settings
esac

export HOME;
unset userhome;
cd "$HOME";
if test -e "$emacsbin"; then
    $emacsbin "$@"
else
  echo >&2 "$self: ERROR –– not found: $emacsbin";
  exit 1
fi

I don't think an image is useful here, but if you want to put one, you can (and should) use the image upload button (or Ctrl+G) in the editor here. This uploads to a site that's associated with Stack Exchange so the images don't disappear when an image host goes under.

I was a bit hesitant, too, and still not convinced to do it.  But thanks for the key combo –– I didn't find anything except for the option of embedding an image link.

@gilles: thanks for the edit, by the way, with the right tags it looks much nicer (I admit that I was too lazy to try the code tag) ;-)

I would recommend using docker to setup multiple versions.  This would mean you need docker installed.  Docker is used to build containers, which are light-weight isolated virtual environment running on your machine.
Containers have complete isolation from your current machine therefore allowing you to set up isolated environments for each version of emacs.  If you are familiar with python virtual environment, it is the same but more generic and may require more technical understanding.  It may be worth the investment to learn docker.
Here is the link to dockerfile use to build images...
https://github.com/Silex/docker-emacs
Good luck!

Can you say why you recommend that? So far, the answer is essentially a link-only answer, so it risks being deleted. Please consider presenting specific reasons why your recommendation answers the question.


text:
Specifying python version in run-python
I'm trying to figure out how to specify which version of python to run when calling "run-python" (C-c C-p) in python-mode, and I've run into the following problem. These are the first few lines of the definition of run-python:

(defun run-python (cmd &optional dedicated show)
"Run an inferior Python process.
  Input and output via buffer named after
  `python-shell-buffer-name'.  If there is a process already
  running in that buffer, just switch to it.
With argument, allows you to define CMD so you can edit the
  command used to call the interpreter and define DEDICATED, so a
  dedicated process for the current buffer is open.  When numeric
  prefix arg is other than 0 or 4 do not SHOW.

I would like to specify the CMD argument so as to specify "python2" or "python3." For example, I've tried things like

M-: (run-python python2)
M-: (run-python (shell-command "/usr/bin/python2"))

but nothing works.
Edit: I figured out that if I supply 0 as a numeric argument, then there is a prompt where I can specify the python version. I would still like to know why neither of my attempts to specify CMD in the actual function call did not work though.

according to the contents of python.el (the source file of python mode) run-python's cmd defaults to a function which returns the path and parameters of the system's default python version, and in turn runs this via python-shell-make-comint, so simply setting an unquoted name (a nonexistant variable as ELisp sees it) or trying to run a shell command directly won't work.
What works, however, is M-: (run-python "python3"), using double quotes in comparison to your first variant.  It opens a new buffer with a python prompt, but does not necessarily get it to the front (ie., use C-x C-b and select the python buffer from the list).  You can see that it worked if „Shell native completion is enabled” appears in the status line.
Depending on which python version you usually run, it is even easier to set it in your ~/.emacs.d/init.el and run it via C-c C-p, or to add those two variables as file-locals in a comment block at the end of a python file (excerpt from python.el's header):
;; … .  You can change
;; your default interpreter and commandline arguments by setting the
;; `python-shell-interpreter' and `python-shell-interpreter-args'
;; variables.  This example enables IPython globally:
;; (setq python-shell-interpreter "ipython"
;;       python-shell-interpreter-args "-i")

Put (setq python-shell-interpreter "python3") into your .emacs.

Or by M-x customise[RET]python-shell-interpreter[RET] from inside emacs.

For recent Python versions (3.3 or newer), I would advise you use the pylauncher py, instead of calling directly Python with python or python3. The pylauncher does exactly the same, but lets you specify which version you want to use amongst those installed on your system.
You can test it inside a terminal, by typing py -3.9 to launch version 3.9 of python, py -3.7 to launch its version 3.7, and so on. Of course, this will only work if you installed both versions on your system.
For Emacs run-python, this translates in using the following:
    (setq python-shell-interpreter "py")
    (setq python-shell-interpreter-args "-3.9")

For Microsoft Windows users, that would be something along thoses lines:
(setq python-shell-interpreter "py")
(setq python-shell-interpreter-args "-3.9 -i c:/Users/YOUR_PROFILE_NAME/AppData/Local/Continuum/anaconda3/Scripts/ipython-script.py")

If you run a dedicated run process (C-u C-c C-p), you can also choose dynamically which version of Python you want to run for the buffer. That makes it very easy to use Python 3.7 (which currently supports tensorflow) on a particular file, while using 3.9 (which currently doesn't) on all the others.
Source: How to run multiple Python versions on Windows


text:
(delete-backward-char) needs an argument?
I have written a function to yank a selected region n times. I get a warning however because of the (delete-backward-char) although it seems to work. Does the (delete-backward-char) need an argument?
(defun yank-n-times ()
  "yanks the region n times"
  (interactive)
  (let ((n (string-to-number (read-string "Yank n times: "))))
    (dotimes (x n) (yank))
    (delete-backward-char)))

the updated function
(defun yank-n-times ()
  "yanks the region n times"
  (interactive)
  (let ((n (read-number "Yank n times: "))
    (txt (car kill-ring-yank-pointer)))
    (dotimes (x n) (yank))
    (when
    (or (string-suffix-p "\s" txt)
        (string-suffix-p "\n" txt)
        (string-suffix-p "\t" txt))
      (delete-char -1))))

(global-set-key (kbd "C-c C-n y") 'yank-n-times)

I suggest you use read-number.

Yes; delete-backward-char requires at least one argument.  Press C-h f and type "delete-backward-char" to read the docstring.  An excerpt:

(delete-backward-char N &optional KILLFLAG)
This function is for interactive use only; in Lisp code use
  ‘delete-char’ instead.

If the function already behaves as you expect, just remove the delete-backward-char instruction.  I imagine that might have been intended to remove a trailing newline.  If for some reason you do want the last character of the last yank deleted you could replace the instruction with (delete-char -1).

I updated my function, if you or any one finds something which could be made more idiomatic i would be gratful to know. My idea with the deletion of the last char was to remove it if it is a space or a new line or a tab from the end of the yankings.


text:
Using Emacs/Org to Create a Tagged, Searchable Collection with Images
Background
After exiting the Linux world for a few years to do the gaming PC thing, I have recently come back to the fold. For the most part, the transition has been easy, but there's one 'tool' I'm having problem replacing: Evernote.
As some of you may know, Evernote does not provide an official client for Linux, and the unofficial alternatives are... Pretty lacking. Currently, I have a pretty sweet setup when it comes to writing notes to Evernote in the form of Sublime Text + the Evernote plugin, but when it comes to viewing notes I'm stuck with the not-very-good web client. For that reason, I'm investigating Emacs + Org mode as a replacement.
I should also note that I'm not a total newcomer to Emacs. In fact, back before I switched to Windows I was one of those guys who was using Emacs for everything from note-taking and writing LaTeX documents to listening to music and emailing. That being said, I never figured out a way to do the one thing I do a lot in Evernote, and which is trivially easy on that platform, but not so easy in Emacs/Org: building up large collections of tagged, searchable notes with lots of images.
To give an example, I have a collection of favourite female actresses, musicians, models, and so on. Each of these is a single note with an image and one or more tags depending on the occupation of the persion in question, so that I can quickly view, say, actresses who are also singers:
I have similarly-structured collections for movies/tv shows, videogames, and books. All of these are quite large, and that's one of the areas where I begin to run into problems with Emacs and Org-mode.
For instance, I attempted to somewhat-replicate the above collection using a single Org file; the plan being to sift through said file using agenda views and tags/keywords. I created a directory for this agenda file to live, as well as the necessary image files, but this was about as far as I got before realizing that it was going to take me forever to select the images I wanted to use, copy each one into the folder, set the attribute to scale the image to a reasonable size, and then link the image itself---which I have to do manually at my current level of knowledge, otherwise Org opts for an absolute link that will present problems when viewing the file in clients on other machines from the synced folder (I'm using SpiderOak):
Other options I have looked at include Bookmarks+ and Image-dired. In fact, I remember using Bookmarks+ as a collection manager back when I was an Emacs obsessive, and am still referenced on the Emacswiki for the my somewhat-novel use of that particular plugin. The limitation I ran into then as now, though, is that Bookmarks+ doesn't do thumbnails, and I like to be able to 'see' and then read, instead of the other way around, if that makes sense.
Image-dired, on the other hand, does image thumbnails, and even supports tags, but I don't know of any way to 'save' certain tag views, and the process of marking/unmarking and then viewing is somewhat clunky compared to searching in Evernote or agenda views in Org-mode.
Question
So I know what I want to accomplish in Emacs is possible, but I'm uncertain as to whether it can be accomplished efficiently given the size of the collection/library I'll end up having. Is there an easy, relatively-straightforward-to-implement way of creating image-rich, tagged entities in Emacs which can be searched and sorted, and which would also be the sort of thing you could put in a sync folder without breakage occuring?
Also note that if you think there would be another application more suited for what I'm trying to do (yes, I know it's heresy to even entertain the notion that something should be done outside of Emacs), then I am definitely open to suggestions.
Oh, and if it's relevant, I'm using Spacemacs.

I suspect if you use the spacemacs tag some people assume the question is specific to spacemacs and ignore it if they're not a spacemacser.

Use Bookmark+ together with image-dired or Dired+.
Bookmark+ lets you create autofile bookmarks, which essentially means that you can treat files as bookmarks. In particular, you can tag them.
Image Dired (part of vanilla Emacs) lets you show image files using thumbnails in Dired.
Dired+ lets you show an image preview (aka thumbnail) in a tooltip when you mouseover an image-file name in Dired. Option diredp-image-preview-in-tooltip controls whether this happens and how (full-size image or thumbnail preview of whatever size). Examples.
Dired+ also provides special support for Bookmark+ autofiles.  Minor mode diredp-highlight-autofiles-mode highlights them for easy recognition, and you can easily mark them and do other things with them. And Bookmark+ lets you cycle through sets of bookmarks (e.g. image autofiles) - slideshows.
There are really quite a few possibilities.


text:
Key binding to a sequence of commands
I'm trying to define a key binding that executes a sequence of commands. I add this code to my ~/.emacs file
(require 'origami)
(defun open-close-node ()
  "Open/Close node origami mode"
  (interactive)
  ('origami-open-node)
  ('origami-close-node))

(define-key origami-mode-map (kbd "C-c C-f") 'open-close-node)

Emacs start with no errors, but when i try to use the key binding, shows this open-close-node: Invalid function: (quote origami-open-node)
EDIT:
What i really trying is to adapt this to my case.
By the way, I'm pretty new with lisp language.
I just want a fast key binding to open/close the nodes within origami-mode

Not sure what you're attempting to do with your function, but the errors you're getting are because you have a quoted symbol ('origami-open-node) within the parentheses where elisp is expecting an unquoted symbol.  I'd suggest you have a look at an elisp tutorial to get a better feel for how lisp syntax works.

@Dan: Please consider posting that as an answer, so the question doesn't remain unanswered.

@GabrielSandoval: Please explain why you wrote the code the way you did.    I.e. where did you find the ('origami-open-node) syntax?

@Stefan I'm really dumb with lisp language, i was trying to avoid the initial errors when emacs start.

It's not clear what you're attempting to do with your command.  However, the error message you're getting is due to the fact that you have a quoted symbol ('origami-open-node) where elisp is expecting an unquoted symbol.
Here's a rough way to think about how lisp understands what you want it to do:
(verb noun noun noun noun...)

The first element of the lisp expression is a function (unless you use a quote, which is itself a verb), which does something (often using the other elements of the list).  When you quote a function, you turn it into the noun form of the verb.  Hence, you told lisp to use the nouned form of origami-open-node rather than to use origami-open-node as a verb.
Have a look at an elisp tutorial to get a better feel for lisp syntax.

You could mention that ('origami-open-node)  expands to ((quote origami-open-node)),


text:
A single Key Binding for several commands
I want to set a key binding to both open and close nodes in origami-mode.
This is my attempt
(require 'origami)
(defun open-close-node ()
  (interactive)
  (origami-open-node)
  (origami-close-node))

(global-set-key (kbd "C-c C-f") 'open-close-node)

When pressing C-cC-f the "Messages" buffer return this:
open-close-node: Wrong number of arguments: (2 . 2), 0

When creating your own functions, it is a good idea to always read the doc-string for the functions you want to use and find out what the arguments are -- including, but not limited to, which ones are optional and which ones are required.  M-x describe-function or C-h f.  I usually like to visit the source code and see what makes it tick with M-x find-function and I also grep the source code to see how it is used throughout Emacs.  Someone will be along shortly to write-up an answer ...  I upvoted because the question is clear and you have taken the first step towards troubleshooting ...

There are a few things to consider here. You may need to dig in to the Elisp Manual (C-h i to get to the available manuals...) because there are some key concepts about functions, arguments, and commands that you may not be familiar with.
First of all, as @lawlist noted in the comments you want to to use the help system and/or source code to understand what arguments are required for the functions you are calling. C-h f origami-open-node will give you the function's doc string, which shows that it expects BUFFER and POINT to be passed as arguments.
Looking at the source (follow the link from the Help buffer) and you'll see that origami-open-node has an (interactive ...) form. This specifies how the arguments are obtained when the command is called interactively (when you call it with a key binding or via M-x). But when calling the same function from lisp you need to pass in the arguments yourself, or indicate that you want the interactive behavior by using e.g. (call-interactively 'origami-open-node)
The next question is how to get the command to do two different things. As you've defined it so far (ignoring the missing arguments), your command would open and then close the node -- I suspect that is not what you want. It sounds like to want to toggle the node open or closed depending on its current state. That would require something like an (if ...) form and a way to check whether the current node is open or closed, which might require more digging in to how origami mode works.
All that said, I think what you want is already provided by origami: have you tried the command origami-toggle-node? Looks like origami does not bind any keys by default but provides a mode map, so you can use:
(define-key origami-mode-map (kbd "C-c C-f") 'origami-toggle-node)

Origami mode has origami-mode-map - see https://github.com/gregsexton/origami.el/blob/5630536d04613476e13b413fe05fd0bbff4107ca/origami.el#L779.  I think this should be
(define-key origami-mode-map (kbd "C-c C-f"))


text:
How does emacs mark the stack for GC
Since I tried creating my own Lisp interpreter (just for learning purposes, as I knew it wouldn't get too far), I have read and tried to understand the internal workings of the Elisp interpreter and always wondered how Emacs does its garbage collection.
I know that the main idea in a Lisp interpreter is that every object that is not reachable from the stack or is the variable or function value of a symbol (basically accessible from the obarray), is considered garbage and is collected when new memory is needed. But what happens when the only reference to an object is in the stack?
How does Emacs know which block of data corresponds to a Lisp object? After all, they are mixed with the complete C/computer stack with function return addresses and C variables not necessarily used inside the Elisp side of Emacs.
After reading the Emacs source file alloc.c, I understand this is done through a tree which holds the address of all allocated memory blocks, and that should in theory solve the problem, but what happens when by pure chance a block of memory stores a valid Elisp object even when it is not supposed to be one? So, could someone please explain to me how Emacs marks/uses the C stack for Elisp function calls?

There are a few Emacs C developers who read this forum, but Eli Z. does not (as far as I am aware).  And, there are some old-timers who are also very knowledgeable who read this forum.  It may behoove you to "Submit a link" to this question on https://www.reddit.com/r/emacs/new/ so that you gain access to Eli Z. and a few other heavy-hitters.

but what happens when by pure chance a block of memory stores a valid Elisp object even when it is not supposed to be one?

Emacs conservatively marks the stack, which means that it examines each word on the stack and considers whether it "looks like" a Lisp object.  There is a comment in alloc.c that explains the general approach:

/* Conservative C stack marking requires a method to identify possibly
   live Lisp objects given a pointer value.  We do this by keeping
   track of blocks of Lisp data that are allocated in a red-black tree
   (see also the comment of mem_node which is the type of nodes in
   that tree).  Function lisp_malloc adds information for an allocated
   block to the red-black tree with calls to mem_insert, and function
   lisp_free removes it with mem_delete.  Functions live_string_p etc
   call mem_find to lookup information about a given pointer in the
   tree, and use that to determine if the pointer points to a Lisp
   object or not.  */

Conservative marking generally has two weaknesses.
One is what you have pointed out: the GC can accidentally keep data alive.  For example if Emacs happens to compute some integer value that is also a valid object reference, then that object mayb be kept alive unnecessarily.  The Emacs response to this is to do nothing.  I suppose it is unlikely to be a big problem in practice, though you could maybe make it happen by playing tricks with bit vectors.
Another weakness is that sometimes compiler optimizations can make it so that there are no obvious references to an object which is live.  As far as I know, Emacs doesn't try to do anything about this problem, either.

> Another weakness is that sometimes compiler optimizations can make it so that there are no obvious references to an object which is live. As far as I know, Emacs doesn't try to do anything about this problem, either.
This looks like a serious problem. Do we have any bug reports because of this? I think it would be hard to go from the bug to the root cause if this happens.


text:
Unconsumed commas in double-backquoted lists
I'm writing a macro which calls a helper function.  I need to return a list like this:
`(s -- (cons 'commentary s))

I have tried many combinations, but I can't seem to get what I need without an extra comma:
(let ((rule-name 'commentary))
  (car `(`(s -- (cons ',,rule-name s)))))
;; => `(s -- (cons ',commentary s))

(let ((rule-name 'commentary))
  (car `(`(s -- (cons ,',rule-name s)))))
;; => `(s -- (cons ,'commentary s))

I don't understand why the second comma is not being consumed.
The only possibly related discussion I have found is here, but I'm not sure it's related, because it's about splicing, which I'm not doing here.
What I'm actually trying to do is rewrite PEGs for peg-parse in peg.el to automatically capture rules that use the substring
action.  To do this, I need to add this to the end of each rule that contains substring:
`(s -- (cons 'rule-name s))

For example, I'm trying to write a PEG to parse Emacs packages.  Here's the call to my macro with the PEG:
(peg-auto-capture-substring
 (package package-header-line headers commentary-heading commentary code-heading rest)
 (package-header-line  heading-1 package-name triple-hyphen package-desc (opt file-local-variables) newline)
 (headers (substring (+ (not commentary-heading) (any))))
 (commentary-heading heading-1 "Commentary:" newline)
 (commentary (substring (+ (not code-heading) (any))))
 (code-heading heading-1 "Code:" newline)
 (rest (substring (+ (any))))

 (heading-1 (bol) ";;;" space)
 (package-name (substring (+ (not space) (any))))
 (triple-hyphen space "---" space)
 (package-desc (substring (+ (not file-local-variables "\n") (any))))
 (file-local-variables "-*-" space (substring (+ (not "-*-") (any))) "-*-")
 (space (+ (not "\n") (or " " "\t")))
 (newline (opt space) (+ "\n")))

Here's the macro:
(cl-defmacro peg-auto-capture-substring (&rest body)
  `(peg-parse ,@(apply #'peg-auto-capture-substring-1 body)))

And here's the helper function:
(defun peg-auto-capture-substring-1 (&rest grammar)
  ;; This should work but it leaves an extra comma!
  (cl-labels ((has-substring
               (list)
               (cl-loop for elem in list
                        if (and (atom elem)
                                (eq elem 'substring))
                        return t
                        else if (and (listp elem)
                                     (has-substring elem))
                        return t)))
    (cl-loop for rule in grammar
             for rule-name = (car rule)
             for action = `(`(s -- (cons ,',rule-name s)))
             when (has-substring rule)
             do (setq rule (append rule action))
             collect rule)))

And here's the expansion of my macro:
(peg-parse
 (package package-header-line headers commentary-heading commentary code-heading rest)
 (package-header-line heading-1 package-name triple-hyphen package-desc (opt file-local-variables) newline)
 (headers (substring (+ (not commentary-heading) (any)))
          `(s -- (cons ,'headers s)))
 (commentary-heading heading-1 "Commentary:" newline)
 (commentary (substring (+ (not code-heading) (any)))
             `(s -- (cons ,'commentary s)))
 (code-heading heading-1 "Code:" newline)
 (rest (substring (+ (any)))
       `(s -- (cons ,'rest s)))
 (heading-1 (bol) ";;;" space)
 (package-name (substring (+ (not space) (any)))
               `(s -- (cons ,'package-name s)))
 (triple-hyphen space "---" space)
 (package-desc (substring (+ (not file-local-variables "\n") (any)))
               `(s -- (cons ,'package-desc s)))
 (file-local-variables "-*-" space (substring (+ (not "-*-") (any))) "-*-"
                       `(s -- (cons ,'file-local-variables s)))
 (space (+ (not "\n") (or " " " ")))
 (newline (opt space) (+ "\n")))

As you can see, the only problem is the unconsumed comma in each action expression.
Any help would be appreciated!
Workaround found
I discovered that there is an undocumented, alternative syntax for "stack actions" in peg.el, which allows me to do this instead of a backquoted list:
(stack-action (s -- (cons 'commentary s)))

I suppose it's like peg.el's equivalent of (backquote).  So I'm able to use this helper function for my macro:
(defun peg-auto-capture-substring-1 (&rest grammar)
  `,@(cl-labels ((has-substring (list) (cl-loop for elem in list
                                                if (and (atom elem)
                                                        (eq elem 'substring))
                                                return t
                                                else if (and (listp elem)
                                                             (has-substring elem))
                                                return t)))
       (cl-loop for rule in grammar
                for rule-name = (car rule)
                for action = (list (list 'stack-action `(s -- (cons ',rule-name s))))
                when (has-substring rule)
                do (setq rule (append rule action))
                collect rule)))

Which expands to:
(peg-parse
 (package package-header-line headers commentary-heading commentary code-heading rest)
 (package-header-line heading-1 package-name triple-hyphen package-desc (opt file-local-variables) newline)
 (headers (substring (+ (not commentary-heading) (any)))
          (stack-action (s -- (cons 'headers s))))
 (commentary-heading heading-1 "Commentary:" newline)
 (commentary (substring (+ (not code-heading) (any)))
             (stack-action (s -- (cons 'commentary s))))
 (code-heading heading-1 "Code:" newline)
 (rest (substring (+ (any)))
       (stack-action (s -- (cons 'rest s))))
 (heading-1 (bol) ";;;" space)
 (package-name (substring (+ (not space) (any)))
               (stack-action (s -- (cons 'package-name s))))
 (triple-hyphen space "---" space)
 (package-desc (substring (+ (not file-local-variables "\n") (any)))
               (stack-action (s -- (cons 'package-desc s))))
 (file-local-variables "-*-" space (substring (+ (not "-*-") (any))) "-*-"
                       (stack-action (s -- (cons 'file-local-variables s))))
 (space (+ (not "\n") (or " " " ")))
 (newline (opt space) (+ "\n")))

And this works, so now it parses an Emacs package file into, e.g.:
((package-name . "peg.el")
 (package-desc . "Parsing Expression Grammars in Emacs Lisp  ")
 (file-local-variables . "lexical-binding: t; ")
 ...)

I'd still like to learn more about how backquotes work.  I using escaped backquotes as well, like:
(let ((rule-name 'commentary))
  (list '\` `(s -- (cons ',rule-name s))))

Which almost worked, except that expanded to an escaped backquote rather than an actual backquote.
I'd also like to know why the double-commas were not completely consumed by the double-backquote, because that seemed to be the real problem I was facing.  Is that a bug in Emacs's backquoting, or do I just not understand how it's working internally?
Thanks for your help.

Suggestion: Try using just list and cons to create the code you are trying to create using backquotes and commas. That will give you a hint of what you need in terms of backquote syntax. IOW, to figure out what's wrong with your syntactic sugar, try coding without it and then working toward using it, bit by bit. (BTW, if what you want to end up with is the list (cons 'foo s) then it is perfectly OK to get there via `(cons ,'foo s).)

@blujay: (let ((rule-name 'commentary)) (list 'backquote \(s -- (cons ',rule-name s))))` produces the result you've stated that you want (without nesting backquotes), but I'm confused as to why you want the outer backquote at all, if you are not evaluating anything in that form?

@Drew I tried that at one point, but I'll give it another try and report back.  Thanks.  @phils The peg-parse macro requires action forms to be backquoted.  See https://github.com/ellerh/peg.el/blob/master/peg.el#L69

@phils Thanks for your suggestion, but it produces the symbol backquote instead of an actual (?) backquote, which PEG doesn't accept--it gives the error (error "Reference to undefined PEG rule: backquote").

@blujay, I see. I know nothing about PEG, but is it any happier with this? (let ((rule-name 'commentary)) (list '\\ `(s -- (cons ',rule-name s))))` (edit: Ah, I see from your edit that you've already tried that in the interim.)

Hmm. Seeing as (let ((rule-name 'commentary)) (list '\\ `(s -- (cons ',rule-name s))))isequalto(read "`(s -- (cons 'commentary s))")` I find it a little odd that that didn't work.  You tested it, yes?

@phils Yes, that results in an escaped backslash, which doesn't work.

You can use a few different approaches, but for your specific case maybe my favorite would be:
(let ((rule-name 'commentary))
  `(,'\` (s -- (cons ',rule-name s))))

Thanks, but that also results in an escaped backslash in the macro expansion, e.g. (headers (substring (+ (not commentary-heading) (any))) \\(s -- (cons 'headers s)))`.

Hmm... maybe there's some odd interaction with peg.el, but I can't figure out how to get the output you show (even reading the C code of the Emacs printer, I can't see how you could ever get \`( in the output (my reading makes me think there's either no backslash or a space before the open paren).


text:
Why can't I bind tab to multiple spaces?
I'm trying to bind tab to either a tab or multiple spaces in Latex/ESS-noweb mode but I can't get it to work. I tried (local-set-key (kbd "<tab>") 'self-insert-command) which didn't work, and then (local-set-key (kbd "<tab>") (lambda() (insert "   "))) which also didn't work.

See https://emacs.stackexchange.com/q/5579/15748 and https://stackoverflow.com/a/34835914/3084001. Your second example is missing an interactive spec, which makes it a plain function, rather than an interactive command. Functions must be interactive in order to be bound to keys. See https://www.masteringemacs.org/article/mastering-key-bindings-emacs for a great writeup on how to define and bind commands.

It would be helpful to clarify whether you are solely looking to insert some string of text, such as tab or space characters (which is covered in the questions I link), or whether there is a higher-level purpose to this, such as performing indentation or some other type of formatting, as suggested by your choice of tags. In this case people may be able to provide answers relevant to LaTeX/ESS modes.

The function you are attempting to bind to a key is not a command. It is missing an interactive spec. 2. Only keys that correspond to characters can reasonably be bound to self-insert-command, so your first attempt would be wrong even if it had interactive: (kbd "<tab>") is not something that can be used by self-insert-command.

"which didn't work" carries very little information.  Please clarify.

@Basil Sorry for the lack of clarity. I'm new to emacs and wasn't aware of the command/function distinction. The higher level purpose is that I would like to adjust the electric indentation settings somehow, I'm just not sure exactly how I would like them yet.

(local-set-key (kbd "<tab>") #'tab-to-tab-stop)

Will make tab behave like it does in other primitive editors.