Hot answers tagged

4

See the variable Man-notify-method, which can be customized. Specifically, the O.P. may be interested in the value 'aggressive. The following is a printout of the *Help* buffer for C-h v aka M-x describe-variable: Man-notify-method is a variable defined in ‘man.el’. Its value is ‘friendly’ You can customize this variable. Probably introduced at or ...


4

Assuming that the O.P. meant to use an underscore in the function name of org_setup (which is possible, but not the standard naming convention), then the problem is with the call to add-hook itself. Instead of using (org_setup), it should be 'org_setup. Try changing the call to add-hook as follows: (add-hook 'org-mode-hook 'org_setup)


4

The only hook I know of that might help is window-size-change-functions. Code such as this, for example (replace the message call by whatever you want done: (defun foo (frame) (let ((fullscreen (frame-parameter frame 'fullscreen))) (when (memq fullscreen '(fullscreen fullboth)) (message "Do what you want here.")))) (add-hook 'window-...


3

reposition-window calls beginning-of-defun to compute the window boundaries. So you get an infinite recursion when calling reposition-window from c-beginning-of-defun. You can add the following guard for avoiding that recursion: (defvar c-beginning-of-defun-after-hook nil "Functions to be run after `c-beginning-of-defun'.") (advice-add 'c-...


3

Is there ... some inbuilt way to achieve this? Yes -- if you enable savehist-mode in your init file, then any variable you add to savehist-additional-variables will automatically be saved and restored between sessions. Bonus question: it would be awesome to also be able to save the history of the same savehist-mode automatically saves most history ...


3

You could try using something like: (add-function :after after-focus-change-function #'your-function-here) So, in your case, something like this should do what you are after: (add-function :after after-focus-change-function (lambda () (save-some-buffers t))) If you look at the documentation of after-focus-change-function with C-h v after-focus-change-...


2

Welcome to SE (emacs)! Look up run-hooks which gives the whole story but the tl;dr is expose a hook variable my-fancy-hook to the user and at the right place in yr own code put: (run-hooks 'my-fancy-hook)


2

I am a strong believer in not polluting hooks, especially something so fundamental like special-mode that is used by countless other major-modes. As such, I would recommend not using the special-mode-hook. The following example adds an entry to the display-buffer-alist that will trigger a custom display-buffer-... function when a matching regexp exists. [...


2

If I correctly understood your question, the solution is pretty simple: (defun emacs-startup-screen () "Display the weekly org-agenda and all todos." (org-agenda nil "n")) (add-hook 'emacs-startup-hook #'emacs-startup-screen) Instead of the named function emacs-startup-screen, you can also use a lambda function like (lambda () (org-...


2

You may use per-buffer-theme.el. For example you could start with a setup like this: (require 'per-buffer-theme) (setq per-buffer-theme/use-timer t) (setq per-buffer-theme/timer-idle-delay 0.1) (setq per-buffer-theme/default-theme 'notheme) (setq per-buffer-theme/themes-alist '(((:theme . dichromacy) (:buffernames nil) (:modes ...


2

It depends on what kind of changes you make. There's nothing special about code invoked from a hook. If you set a global variable it remains set until something sets it differently or makunbounds it. Your question is general, so the answer is general. If you pose a specific question, e.g. with some code, specific answers can likely be given.


2

You say: "post-command-hook triggers after every command, not just user-invoked commands." And in comments you say that by "user-invoked" you really mean invoked interactively. It's not true that post-command-hook triggers each time a function that is a command is invoked. It's triggered for such a function only when it is invoked ...


1

Add (add-hook 'csv-mode-hook 'csv-align-mode) to ~/.emacs and it works. Note: It's csv, not tsv, even though editing .tsv files. My skills don't yet suffice to make it in .dir-locals.el.


1

As discussed in the comments to my question, I was a bit confused when writing the question, but will keep the original text in case similarly inexperienced people approach it from the same way. To answer the main question "How to dynamically replace certain text, by evaluating a function on change in current buffer", below is an example of how to ...


1

You don’t need to pass any arguments to anything. The new hook that you have created, after-save-interactively-hook, is called just after saving the current buffer. Any hook functions you add to that list can simply call buffer-file-name to get the name of the file visited by the current buffer. For more information, use C-h f buffer-file-name to view the ...


1

I think something has gone wrong if you can't modify the use-package form -- AFAIK that macro is intended for use by end-users only. That said, the documentation you've quoted: all of the following are equivalent: (use-package ace-jump-mode :hook prog-mode) (use-package ace-jump-mode :hook (prog-mode . ace-jump-mode)) (use-package ace-jump-mode :...


1

It appears as though org-roam has a hook specifically for this: org-roam-file-setup-hook. It's not well documented, but from reading the code it looks like it's called whenever an org-roam file is opened. From my testing, that means when it's done through the normal find-file means, from org-roam-find-file, and probably just about everything else that opens ...


1

There is a variable named interprogram-paste-function that is bound to the function that retrieves the value from the system. You can define your own function that calls the original function and remove the hyphens, and bind it to this variable. The package https://github.com/Lindydancer/highlight2clipboard does similar things, although it modifies things ...


1

TL;DR: set the variable org-agenda-files to be a list of all the directories that you want to scan recursively for *.org files: (setq org-agenda-files '("~/Dropbox/org/journal/")) Explanation: There are two org-agenda-files objects: a function and a variable. Org mode calls the function when it needs the list. The function looks at the org-agenda-...


1

Following NickD's input on my first answer (thanks @NickD) I think a better approach is to limit org-update-radio-target-regexp to only fire when the target is first created. This is done by binding the ">" key and then testing whether point is just to the right of a <<<radio target>>> (after it is pressed). Here is the code: (...


1

You can find out what is going on yourself by putting the cursor after the use-package stanza and doing M-x pp-macroexpand-last-sexp. You will discover that the :hook line expands to (add-hook 'TeX-after-compilation-finished-functions-hook #'TeX-revert-document-buffer) which is not what you wanted. Long story short: :hook only does what you want if the car ...


1

There is no such hook, but you can write a function that does what you want and execute that instead: (defun ndk/org-export-to-html-and-rsync () (interactive) (org-export-as 'html) (rsync-html)) You can even bind to a key so that you can execute it easily: (define-key org-mode-map (kbd "C-c z") #'ndk/org-export-to-html-and-rsync) Notes: ...


1

There is no hook called org-deadline. Most hooks are called <mumble>-hook so when you are looking for one, try C-h v org--hook and press TAB: that should give you a completion buffer with all the available hooks whose names start with org-. Unfortunately, there is no hook defined to allow you to call a function after you set a deadline. But you can ...


1

Sure, just add something like this to your init file: (defun oleg/compile-lua () "use love2d to compile my lua code" (interactive) (compile "love2d /home/huseyin/Documents/Programming/Lua/")) (global-set-key (kbd "<f5>") #'oleg/compile-lua) You can name the function whatever you prefer, and bind it to whichever key ...


1

org-capture-prepare-finalize-hook worked for me, not org-capture-after-finalize-hook.


Only top voted, non community-wiki answers of a minimum length are eligible