Questions tagged [hooks]

Hooks are an important mechanism for customizing Emacs. A hook is a Lisp variable which holds a list of functions, to be called on some well-defined occasion.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

Why does the execution of latex/hide-show-all with hooks not work?

I'm using AUCTeX, CDlatex and latex-extra to write LaTeX-files. When I access a file I'd want the contents of its sections to be hidden by default using the latex-extra1 command latex/hide-show-all, ...
Alexander Praehauser's user avatar
1 vote
1 answer
30 views

Return a list of functions with a given property or creating a group of functions

I am a copy editor and I make an intensive use of custom "predicates" when I perform replacements in LaTeX code. I use, among others, this technique: ;; predicate (defun omit-comments (beg ...
Gabriele Nicolardi's user avatar
0 votes
1 answer
25 views

Cannot get rid of isearch overlays

The following code (defun nordlow/isearch-previous-symbol-at-point () (interactive) (cond ((eq last-command 'nordlow/isearch-previous-symbol-at-point) (isearch-repeat-backward)) ;avoid ...
Nordlöw's user avatar
  • 497
0 votes
0 answers
47 views

how to turn off python formatting in emacs

I have a python program that I edit in emacs. However, sometimes when I save it, it gets re-indented, and in doing so, messes up the indentation of sections, where I have some code and then some ...
Christopher Clark's user avatar
1 vote
1 answer
80 views

Add parsing of latex-style .el file to LaTeX-hook using AUCTeX

I did some online research (e.g. here) but couldn't figure out how to solve the following problem so far (of course, I might have overlooked something since the whole emacs community is new to me). ...
lukeflo's user avatar
  • 195
1 vote
1 answer
37 views

Use 'mapcar' to build a hooks list; "wrong-type-argument listp lambda"

How can I write a mapping (e.g. a mapcar expression) to build the list for a use-package :hook clause? I'm attempting to build the list in this :hook expression: (use-package eglot :hook ( (...
bignose's user avatar
  • 639
0 votes
0 answers
15 views

Parse elfeed's entry cl-struct

I'm trying to display notifications using elfeed's hook and alert. This works: (add-hook 'elfeed-new-entry-hook (lambda (entry) (alert (prin1-to-string (elfeed-entry-content ...
Daniel Krajnik's user avatar
0 votes
1 answer
36 views

Calling git commit from shell-command results in incorrect log message

I implemented the following to git commit after a file is saved. It works, I think, but the commit message, rather than being empty, is the literal value ''. This is the case whether or not I have any ...
user2567544's user avatar
0 votes
0 answers
34 views

Getting error in hook: Symbol’s function definition is void: \(setf\ ekg-note-tags\)

I'm writing a pre-save hook for ekg (emacs knowledge graph), and getting an error I don't know how to figure out. The error is triples--with-transaction: Symbol’s function definition is void: \(setf\ ...
GaryO's user avatar
  • 496
0 votes
1 answer
29 views

Turn off show-trailing-whitespace in Echo Area

When I run (setq-default show-trailing-whitespace t) on startup, the Echo Area is affected. I can usually turn this off with hooks, e.g. (add-hook 'minibuffer-setup-hook (lambda () (setq show-...
faulty_ram_sticks's user avatar
0 votes
1 answer
29 views

Third-party function overrides my customized variable and my mode hook

In the spacemace python layer, the following function overrides my customizations for the variable company-minimum-prefix-length python layer (defun python/post-init-company () ;; backend specific ...
degen872's user avatar
0 votes
1 answer
23 views

set the correct major mode for script files based on interpreter

I want to make a function that will set the correct major mode based on the interpreter used for a script. I don't want to include extensions in my scripts (because that can be annoying if making cli ...
Hackerman's user avatar
0 votes
0 answers
28 views

How to turn on `read-only-mode` when running a command in `comint` buffers and turn off it when the command is finished?

I'd like to prevent all user inputs when a command is running in comint-like buffers (created by shell, run-python etc.) by enabling read-only-mode when I hit enter to run the command and disabling it ...
Saddle Point's user avatar
0 votes
1 answer
31 views

Tide mode: how do I get it to stop running tide-format-before-save?

I'm at my utter wit's end with this hell-plugin lmao. I've tried (remove-hook 'before-save-hook 'tide-format-before-save t), and it doesn't work. How do I remove tide-format-before-save from the ...
Alexis Purslane's user avatar
0 votes
0 answers
24 views

Emacs is generating HTML file when opening markdown files

I don't know what is happening and how to debug this. I moved my Emacs config from Fedora to Xubuntu 22.04 (that use older version of GNU Emacs) and now each time I open markdown file (only once per ...
jcubic's user avatar
  • 711
0 votes
1 answer
164 views

How to fix lsp-mode for Elisp?

I have this set in my init file: ;; build dependency tree for function (use-package lsp-mode :ensure t :hook ((clojure-mode . lsp) (clojurescript-mode . lsp) (prog-mode . ...
Pedro Delfino's user avatar
0 votes
1 answer
26 views

How to proper install and configure js2-mode via use-package declaration?

I am trying to install this package called js2-mode. This is part of my effort to follow this tutorial. Package documentation and tutorial are using classic installation via package-install as follows:...
Pedro Delfino's user avatar
0 votes
0 answers
36 views

Highlighting entries with specific keywords in Elfeed

To avoid missing on important news, I am trying to highlight Elfeed entries containing specific words in their titles: (add-hook 'elfeed-new-entry-hook (elfeed-make-tagger :entry-title '("...
Carapuce's user avatar
1 vote
2 answers
59 views

How to enable `fill-paragraph` command to be executed every time ChatGPT replies via gptel package?

I have been using this cool Emacs package called gptel. However, it is annoying for me how lengthy the ChatGPT answers look on the screen. When I want to improve readability, I keep executing the fill-...
Pedro Delfino's user avatar
2 votes
1 answer
56 views

Automatically add a newline when dragging text from Firefox into Emacs

One of my workflows is drag lines from Firefox to Emacs (X). What I'm trying to accomplish is putting a new line after dragging every line. I've tried zillions of combination but I can't find the ...
Javier Ortega's user avatar
0 votes
0 answers
21 views

Polymode in org-edit-special

I use (add-hook 'python-mode-hook 'poly-python-sql-mode) where poly-python-sql-mode is a special polymode that correctly highlights SQL queries that are used within strings in a Python file. When this ...
guibor's user avatar
  • 121
0 votes
1 answer
36 views

frame hook load theme causes frame to crash after creation

I have attempted to change my emacs theme. I am using the emacs daemon and I have attempted to create a hook to change the theme on frame creation. However when this hook is active the frame crashes ...
Progamer's user avatar
0 votes
1 answer
37 views

How to set display margins for markdown-mode buffers?

Is there a way to set the display margins for markdown-mode buffers? I've read https://www.gnu.org/software/emacs/manual/html_node/elisp/Display-Margins.html and various suggested solutions but ...
jth's user avatar
  • 101
1 vote
1 answer
42 views

Calling org-indent-mode from org-mode hook causes infinite recursion?

I have the following code in my emacs init files, and it is causing an infinite recursion, which eventually bottoms out and throws an error. (defun robs-org-mode-hook () (org-indent-mode) ...) (...
Rob N's user avatar
  • 587
0 votes
1 answer
41 views

Using major mode dependent functions

I have a function (tika-outlhg-regexp) that sets custom outline headings based on major mode. I activate this with major-mode hooks. Is there some other way? (defun tika-addhook-hgptn () (add-hook '...
Dilna's user avatar
  • 1
0 votes
1 answer
127 views

Using hooks in minor modes

I have introduced the following hook function inside a minor mode. The intention is to activate the minor mode for a number of major modes. I would also need to activate outline-minor-mode once tika-...
Dilna's user avatar
  • 1
0 votes
0 answers
26 views

Move point from a hook in EMMS playlist doesn't work

I want to move point with the current played song in an EMMS playlist. I tried it with this code: (defun tvd-emms-follow-playing-song() (interactive) (message (format "%s" emms-playlist-...
Tom's user avatar
  • 45
2 votes
0 answers
58 views

Disable fill-column-indicator Only in Minibuffer

My code (custom-set-variables '(global-display-fill-column-indicator-mode t) '(minibuffer-mode-hook `(,@minibuffer-mode-hook ,(lambda () (...
shynur's user avatar
  • 4,638
0 votes
1 answer
31 views

Changing the definitions of outline-minor-mode headings

I would like to change the pattern for heading in outline-minor-mode. Have came up with the following implementation for emacs-lisp-mode that uses a minor-mode called taxocask-minor-mode. (defvar ...
Dilna's user avatar
  • 1
0 votes
0 answers
44 views

How to wait for buffers to load?

I'm trying to create a hook for ein package that will clean up split windows and focus on the rendered buffer. The package provides one hook (called ein:ipynb-mode-hook), but running functions below ...
Daniel Krajnik's user avatar
0 votes
1 answer
38 views

Hook resulting in a Wrong type argument error?

I am trying to do two things for Elfeed Summary: Automatically update the feeds when starting Elfeed Summary. Automatically hide the feeds without unread articles when starting Elfeed Summary. ...
Carapuce's user avatar
0 votes
1 answer
67 views

How to get a minibuffer state indicator for Evil's `evil-want-minibuffer`?

For regular buffers, Evil has a state indicator in the mode line. But when using Evil in the minibuffer (by setting evil-want-minibuffer to t), there's no state indicator besides the cursor. Viper had ...
mtraceur's user avatar
  • 256
0 votes
1 answer
46 views

How to update statistics cookies on file save?

For some reason, I can't get either of these to work. I'm trying to update the statistics cookies on TODO's automatically when the file saves. (add-hook 'after-save-hook 'org-update-statistics-cookies)...
innocentios's user avatar
0 votes
0 answers
32 views

Apply a hook only when in Evil's insert state

Is there a builtin mechanism that would allow activating a hook only when in the insert state in Evil. I want to add a hook to org-tab-first-hook but only run the hooked function in the insert state. ...
Arktik's user avatar
  • 962
0 votes
1 answer
60 views

How to never auto-save large files — or, how to run a function whenever any buffer starts — or, how to abort loading a minor mode in one of its hooks

I want to tell Emacs to never auto-save files bigger than ~1MB. I know how to turn off auto-save-mode when the file size is above a certain limit, but not how to make that function run automatically ...
Zorgoth's user avatar
  • 820
0 votes
1 answer
116 views

Change cursor blinking status upon state change of evil-mode

I'm using evil-mode. My goal is to have a blinking cursor upon entering evil-insert-state, and to have a non-blinking cursor in evil-normal-state. I tried the following but it doesn't work: (add-...
NewToEmacs's user avatar
0 votes
1 answer
42 views

Call different functions based on buffer mode

I annotate my reading with org-remark and pdf-annot. They work with EPUBs and PDFs respectively, and are not interchangeable, with inconvenient consequences. What I would like to do is to bind a ...
Sati's user avatar
  • 775
1 vote
1 answer
298 views

How can I turn off Company mode in only some major modes? [duplicate]

I use company when coding. I currently have it set to global. I would like to turn it off for a few major modes. However, instead of turning it off globally, I only want to deactivate company for 2 or ...
Vinn's user avatar
  • 283
4 votes
1 answer
69 views

Isearch + Dired fast navigation

After seeing this post and one of its comments, I am trying to implement the following convenient search pattern in dired: Press C-s to start isearch Type the substring I am looking for Possibly jump ...
unvarnished's user avatar
1 vote
1 answer
98 views

How can I save all buffers on auto-save except the ones have specifc mode?

I am using following full-auto-save () (https://www.emacswiki.org/emacs/AutoSave) to save all buffers on Auto-Save. (defun full-auto-save () (interactive) (save-excursion (dolist (buf (buffer-...
alper's user avatar
  • 1,300
1 vote
1 answer
78 views

How can I force require-final-newline nil?

I'm doing this from typescript-mode-hook: (defun disable-final-newline () (setq-default mode-require-final-newline nil) (setq-default require-final-newline nil) (setq mode-require-final-newline ...
Croad Langshan's user avatar
1 vote
1 answer
211 views

What is the difference between these two statements in my init file

I'm new to elisp- what is the difference between: (add-hook 'js2-mode-hook (lambda () (flyspell-prog-mode) )) and (add-hook 'js2-mode-hook 'flyspell-prog-mode) ?
Fergie's user avatar
  • 193
1 vote
1 answer
52 views

How can I apply `bibtex-fill-entry` to the whole buffer?

When I run bibtex-fill-entry it formats the current entry block where the cursor is at. Note that bibtex-fill-entry (C-c C-q) Fill current BibTeX entry. So I have to traverse all the entries to align ...
alper's user avatar
  • 1,300
0 votes
1 answer
596 views

Turn on minor mode rainbow-mode using use-package

I would like to turn on rainbow-mode in elisp and/or lisp modes when I am editing init.el using use-package. I've tried the following: (use-package rainbow-mode :demand t :hook ((text-mode . ...
oneself's user avatar
  • 301
1 vote
1 answer
102 views

Change minibuffer color when NOT in minibuffer AND minibuffer active

I frequently click on another application when I'm doing something in the minibuffer, and then I've forgotten I was in the minibuffer when I come back to emacs. I would like to highlight the ...
Todd's user avatar
  • 211
1 vote
0 answers
52 views

Can I somehow hook a variable? [duplicate]

So a function is called when the variable value is changed? add-hook seems to only accept functions.
xeruf's user avatar
  • 334
0 votes
0 answers
30 views

Rainbow-delimiters with hooks

It seems that rainbow-delimiters does not work with hooks. For instance I have got (add-to-list 'auto-mode-alist '("\\.sty\\'" . latex-mode)) (require 'rainbow-delimiters) (add-hook 'tex-...
Dilna's user avatar
  • 1
0 votes
1 answer
28 views

Setting hook without calling external function

I am changing the default value for fill-column, then hook it for prog-mode. Would be neat to have a way that I can have a single function to do this. Currently add-hook requires a call to an ...
Dilna's user avatar
  • 1
0 votes
2 answers
85 views

How to enable markdown-mode every time I invoke Emacs Anywhere?

I am using a cool software called Emacs Anywhere. Usually, I invoke this software to write on Stack Overflow and on GitHub. Both websites use markdown. Hence, almost every time I invoke Emacs Anywhere,...
Pedro Delfino's user avatar
0 votes
1 answer
105 views

highlight-changes-mode: clear displayed changes after saving

I currently use this mode like so : (global-highlight-changes-mode t) (setq highlight-changes-visibility-initial-state nil); initially hide ;; toggle visibility (global-set-key (kbd "<f2> =&...
John Doe's user avatar
  • 169

1
2 3 4 5
8