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.

36 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
86 views

Get task duration from old timestamps

Assuming I have a task where I store a timestamp for every taskchange I do: * DONE Extremely important dummy task :categorywhatevs: - State "DONE" from "IN PROGRESS" [2015-06-08 Mo 14:...
4
votes
1answer
237 views

(How) can I emulate {eshell,comint}-output-filter-functions in term?

What I want to do from inside a term shell is have a function called when there is new output or a certain regexp (e.g. a prompt) appears in in a term's output. The callback function should then be ...
3
votes
0answers
45 views

Package to detect most common typing mistakes

I'm a decent touch-typist, capping out around 90 WPM, but I know I'd be better if I eliminated some of the more persistent typos that crop up semi-consistently. It occurred to me this morning that ...
3
votes
0answers
1k views

When using emacsclient, how can I open the file in the active buffer?

When I open a file with emacsclient without invoking -c, Emacs visits the file in a new buffer in the background while leaving my current window configuration in place. I'd like to change this, e.g. ...
2
votes
1answer
1k views

automatic latex-preview-pane with auctex and or-mode latex export

To enable automatic latex-preview-pane-mode with AUCTex I bound it to a hook: (add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode) This works. When I open a *.tex file, then latex-preview-pane-mode ...
2
votes
0answers
59 views

Hook variable for horizontal scrolling

There is the hook variable window-scroll-functions for functions to be called before redisplay after vertical scrolling. Is there a similar variable for horizontal scrolling?
2
votes
0answers
196 views

Faces not set immediately after load-theme

I'm trying to set the faces of highlight-indent-guides automatically whenever a new theme is loaded by making small adjustments to the background color of the default face. I have everything working ...
2
votes
0answers
319 views

How to make ansi-term output read only?

When using ansi-term in line mode emacs lets you edit the buffer arbitrarily, not just after the last prompt. I'm trying to make it read only so I stop fudging with command output. The problem is all ...
2
votes
0answers
211 views

Expand LOGBOOK on 2nd Tab press? (hook for 2nd org-cycle?)

In org-mode.. I store lots of state-change messages and timing info in the LOGBOOK drawer. Most of the time, I don't look into the LOGBOOK drawer, but once in a while when following up on a pending ...
1
vote
0answers
77 views

use-package org-mode :hook is being ignored

I'm currently running this version of Emacs: GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.7) of 2019-04-11, modified by Debian I'm attempting to use use-package to configure the ...
1
vote
1answer
65 views

delete-trailing-whitespace on save while always preserving location of cursor

I have the following before save hook defined which deletes all trailing whitespace and converts tabs to spaces (except in makefile mode since makefiles need tabs to work). This works great, however, ...
1
vote
0answers
46 views

Org-mode :results file hook to launch file

My scenario python code creating a wav file last line of code returns the written file name org-mode src block with the option :results file The result block correctly links to the audio file, and I ...
1
vote
0answers
190 views

How to get customizations added to `ess-mode-hook` to run in Aquamacs ESS

In Aquamacs 3.3, ESS 16.04, I can't get customizations added to ess-mode-hook to run. Here's a simple example. (defun my-ess-hook () (setq ess-default-style 'DEFAULT) (setq ess-indent-level 2)) (...
1
vote
0answers
40 views

Running emacsclient causes some flashing effect to happen on other frames

I picked up this code from: Is there any way to run a hook function only once? (setq myGraphicModeHash (make-hash-table :test 'equal :size 2)) (puthash "gui" t myGraphicModeHash) (puthash "term" t ...
1
vote
0answers
32 views

ESS hooks breaking buffers not associated with files

This is a weird one, for me: I use both ESS (for R programming) and gist.el for (surprise!) interacting with github gists. Except, now I have a problem: every time I try to view a gist locally, ESS's ...
1
vote
0answers
64 views

Do Any Hooks for (Specific) Package Installation Exist?

I have a StumpWM configuration that loads a file contained in the SLIME package installed through Emacs (swank-loader.lisp). However, problems arise when my SLIME package is updated, because the ...
1
vote
1answer
468 views

Read first line of file when opening to rename buffer

I want to add a hook that reads the first line of the file/buffer when it opens. I want to do this so that I can rename the buffer that opens notes from simplenote. But, how do I read the first line?...
0
votes
1answer
16 views

Change font or point colour based on absolute path of the source file

This is a rare occasion when I need it, but I am trying to figure out a way to change colour of font/point based on the path of source file to easily distinguish which file I am editing when I am ...
0
votes
0answers
24 views

Enable prog-mode when minor mode is activated

I created a minor mode for some specific file extension to fontify the syntax and provide correct indentation. 1)The indentation doesn't work for some reason. 2) How to enable prog-mode when the ...
0
votes
0answers
44 views

How to disable eldoc when using TRAMP (editing files over SSH)

Eldoc really bogs down the editor when used over SSH with TRAMP. I want to disable it in those cases. What I've tried is this: (defun no-tramp-eldoc () (interactive) (when (string-prefix-p "...
0
votes
1answer
37 views

Write a function that runs another function after adding a hook

I want to run some function f after adding a hook to a mode and after running f remove the hook that I added, returning the result of f if there is one. Here is a non-working version that I hope ...
0
votes
0answers
29 views

How to load image using iimage-mode when I first open a markdown file?

I have a file which embeds an image ![](file://tmp.jpg) I have added iimage mode to the markdown mode hook and even added recenter to it (add-hook 'markdown-mode-hook 'iimage-mode) (add-hook '...
0
votes
1answer
26 views

window-configuration-change-hook false positives from desktop-mode

I'm trying to use window-configuration-change-hook in a package to perform some action when a buffer becomes visible for the first time. It works, however when starting Emacs, desktop-mode calls ...
0
votes
1answer
75 views

Updating pyenv when switching to a Python buffer

I use pyenv to maintain my python versions and virtualenvs. I really like the way you can create a local .python-version for each project, pointing to the version I need. I use pyenv-mode which allows ...
0
votes
0answers
24 views

Haskell-mode-hook help window keeps opening

I installed haskell-mode, but every time I press RET or TAB on a Haskell file it keeps opening that window Any idea on how to deactivate this ?
0
votes
0answers
31 views

Alarmbell on saving .py file if linting errors using flake8

I'd like to configure Emacs to play an audible noise when saving my .py files but only if there is a linting error present. I currently have flycheck linting done on the fly and autopep8 settings ...
0
votes
0answers
27 views

Call a function every time a specific piece of text is inserted

I'm wondering whether there is an already existing mechanism of executing a function every time a specific piece of text is inserted. For example, I would like to call company-bibtex whenever I enter ...
0
votes
1answer
293 views

add-hook evil-insert-state-entry-hook is not calling the function

Update: It worked properly somehow after disabling and enabling nyan-mode. BUT there is no evidence indicating any relationship between them. Because I can't reproduce this problem after it was ...
0
votes
0answers
71 views

recenter *xref* buffer on next-error

I have a next-error-hook to recenter the next-error-last-buffer, so if the buffer is displayed, it will recenter to the line of the error I just jumped to: (defun jpk/next-error-hook () (let ((win (...
0
votes
0answers
141 views

Using hooks to organize configuration

Up to this point, I used to have a separate configuration for each major mode, e.g. init.org.el, init.c++.el etc. I would invoke Emacs using an one of the aliases like these: alias emacs-org='emacs -...
0
votes
0answers
172 views

How can the ace-window hotkey be set to work in sr-speedbar?

I have configured the M-p key to trigger ace-window, but when I navigate to the sr-speedbar window it stops working and I have to use C-x o to move out. Is there some mode hook I have to use to ensure ...
0
votes
0answers
107 views

Do something before window configuration change

AFAIK, window-configuration-change-hook applies after a configuration change, and there is no corresponding window-before-configuration-change-hook. What's the best way to detect window ...
0
votes
0answers
61 views

How can I know what command is running when I move the point or select something?

One example: I select something, then the minibuffer give me some response. For example, in markdown-preview-mode I select a paragraph then the minibuffer shows me the paragraph with <p> in each ...
0
votes
1answer
812 views

Changing mode-line face when evil state changes

I'm trying to change the mode-line face box attribute to be the same color as the evil emacs state face, obviously updating it each time the mode changes. I've seen some things about using a post-...
0
votes
0answers
132 views

Recommendations for eval on save workflow for projects?

I've started to write a package and excessive use of the interactive eval-* functions has become a pain point for me. After I make a change re-evaluating entire file or package is almost always ...
0
votes
0answers
91 views

Finding proper hook for a major mode

So this is some elisp code I have in my init.el file: (defun complete-dollar () (interactive) (insert "$$") (backward-char 1)) (defun my-latex-keys () "Modify keymaps by latex-mode" (...