Stefan
  • Member for 7 years, 3 months
  • Last seen more than a week ago
How to refactor elisp programs using pattern matching on sexps with replacement?
Accepted answer
7 votes

I believe you're looking for the el-search package, available in the GNU ELPA repository. It lets you match using pcase patterns and does implement the search&replace functionality that you're ...

View answer
Install packages globallly
7 votes

As pointed out by Nsukami, package.el does support system-wide packages. But as your subsequent question points out, it does not provide any special help to install packages in a system-wide manner. ...

View answer
Show the *Completions* buffer automatically when starting completing-read
7 votes

Last time I needed this, I used something like: (minibuffer-with-setup-hook #'minibuffer-completion-help (completing-read ...))

View answer
Why does C-c C-x look like an empty keymap?
Accepted answer
7 votes

Indeed, interactively C-h k can't be used if you're trying to find where a prefix map is defined. And even the question itself may be somewhat meaningless in the sense that it can be defined at ...

View answer
Parsing parentheses: smie vs syntax table
Accepted answer
7 votes

Speed is a good reason to let the paren-matching be performed by syntax-tables where possible. In your case, the "parens" are not multi-char, so you can definitely use syntax-tables for them. In ...

View answer
Is there a better way to handle multiline docstrings in elisp?
Accepted answer
7 votes

Of course a my-defun macro is the easy way out. But a simpler solution would be (advice-add 'eval-when-compile :filter-return (lambda (exp) (if (and (eq 'quote (car-safe exp)...

View answer
Difference between pcase-let & cl-destructuring-bind?
Accepted answer
6 votes

cl-destructuring-bind was designed more or less specifically to destructure data made of cons cells. pcase-let on the other hand is just a special case of pcase which was designed to handle arbitrary ...

View answer
How to automate installation of packages with .emacs file?
6 votes

package.el keeps track of the packages you asked to install (as opposed to those that are auto-installed as dependencies) in the custom variable package-selected-packages. So if you copy your ~/....

View answer
Is using cl-lib crucial for writing good Emacs Lisp code?
6 votes

No, it's definitely not crucial: A quick sed | sort | uniq -c says that within Emacs's own code we have: [...] 20 (cl-ecase 24 (cl-labels 26 (cl-callf 26 (cl-defmacro 26 (cl-dolist 26 (cl-...

View answer
How to postpone redrawing on startup?
Accepted answer
6 votes

The initial frame is created before your ~/.emacs file is read, so it necessarily uses the default "theme" first and only later updates to the appearance you chose. In Emacs-27, you can customize ...

View answer
Deactivate subscripts and superscripts raising / lowering in latex mode
6 votes

You're looking for tex-fontify-script, which you can customize, or just set manually via: (setq tex-fontify-script nil)

View answer
How to make (make-symbol "foo") (make-symbol "foo") equal?
6 votes

You're confusing make-symbol and intern. make-symbol is used specifically when you want such an equality not to hold.

View answer
Is there a mode to automatically update copyright years in files?
6 votes

Here's what I use: (when (fboundp 'copyright-update) (setq copyright-names-regexp "Monnier\\|Free Software") (add-hook 'before-save-hook #'copyright-update))

View answer
Can I tell prin1-to-string to use reader-macros?
Accepted answer
6 votes

Just bind print-quoted to a non-nil value around the call to prin1(-to-string).

View answer
Why isn't face-remapping-alist permanent-local by default?
Accepted answer
6 votes

permanent-local is fundamentally a way to distinguish whether the variable's buffer-local value is really specific to this buffer or is specific to the mode currently in use in this buffer. Sadly, in ...

View answer
Builtin Filter Algorithm
Accepted answer
6 votes

My crystal ball tells me that you want (require 'seq) and then ... (seq-filter ...) ... The seq package is built-in, even though you have to say explicitly when you want to use it. Of course it's ...

View answer
Is there a way to comment within a line in elisp?
6 votes

For the usual meaning of "comment", the answer is mostly no (see Dan answer for details), but if you just want to prevent code from being executed, then you can simply do nothing in your case, since ...

View answer
(la)tex-mode-hook doesn't work?
Accepted answer
6 votes

If you have AUCTeX installed, then you're presumably using AUCTeX's modes, so the hooks you need to use have names of the form TeX-mode-hook and LaTeX-mode-hook (note the capitalization).

View answer
Signaling a breakpoint in Emacs Lisp
Accepted answer
6 votes

Add (debug) and you'll be thrown into a buffer showing you the backtrace and where you can examine the current state. See: Emacs Manual "Explicit Entry to the Debugger"

View answer
Change the behaviour of RET (with electric indent) to only indent the new line, not the previous one
Accepted answer
6 votes

I think you'll get what you want with (setq-default electric-indent-inhibit t) This was meant as a variable for major-modes (rather than for users), but it should take care of your use-case as well.

View answer
Why isn't emacs-lisp-mode derived from lisp-mode?
Accepted answer
6 votes

Because lisp-mode is actually meant to be the major mode for Common-Lisp. Emacs-Lisp and Common-Lisp are closely related but neither is a superset of the other, so they should both derive from the ...

View answer
Is there a standard/recommended syntax for defining a keyboard binding?
6 votes

(global-set-key [?\M-r] 'some-command) is the "native" way. All others are built on top of this one, basically.

View answer
How can I prevent python-mode from occasionally highlighting everything as string
6 votes

When you modify the buffer, only the lines you modified get re-highlighted right away. If the modification affects highlighting of lines futher down, these get re-highlighted later via an idle timer (...

View answer
How to select non-contiguous regions in Emacs?
6 votes

The new rectangle-region support in Emacs-24.4 actually introduced (a big part of) the infrastructure needed for this functionality [ after all, a rectangular region is a non-contiguous region]. So, ...

View answer
How to syntax highlight Python f-strings so {...} uses regular code colors?
Accepted answer
5 votes

FWIW, I just pushed support for "proper" highlighting of f-strings in Emacs's master branch, so it will be available in Emacs-28 when that gets released (and is available in GNU ELPA's ...

View answer
Why do setq and set quote act differently on let-bound variables with lexical scope?
5 votes

BTW, one way to think about why it can't work is to remember that lexical scoping enjoys the so-called "α-renaming" property: variable names do not matter, and you (or the compiler) can ...

View answer
How to replace the buffer without slowing down the undo system?
Accepted answer
5 votes

Emacs-26 introduced replace-buffer-contents specifically to do that job. But use it with care: it works well when there are few differences, but if the new content happens to be completely different ...

View answer
How to make new text highlighted as well?
Accepted answer
5 votes

The problem is that you're trying it out in fundamental-mode. As explained in the docstring of hi-lock-mode: [...] In buffers where Font Lock mode is disabled, patterns are applied using overlays; ...

View answer
Equivalent of let-alist for plists?
5 votes

You could use: (pcase-defmacro plist (&rest args) `(and (pred listp) ,@(mapcar (lambda (elt) (if (consp elt) `(app (pcase--flip plist-get ,(...

View answer
How to concatenate a string and a list?
Accepted answer
5 votes

AFAIK the canonical way to turn a list into a string is with mapconcat, e.g. (defun concat-string-list (str xs) (concat str " " (mapconcat #'symbol-name xs " ")))

View answer
1 2
3
4 5
22