Hot answers tagged

16 votes
Accepted

Is it possible to execute a function or command at a specific time?

You want to use the function run-at-time, described in Chapter 38.10 of the Emacs Lisp manual. In your case, something like this should do the trick: (run-at-time "20:30" nil #'kill-emacs) If the ...
user avatar
  • 5,520
13 votes
Accepted

How to set temporary halt after C-x C-c?

You can roll your own predicate function that waits for 3 seconds and invariably returns non-nil (unless it is interrupted with C-g): (setq confirm-kill-emacs (lambda (&rest args) (...
user avatar
8 votes
Accepted

Prevent Emacs from messaging when it writes recentf

One solution for that narrow case is to dynamically set save-silently for that invocation specific invocation. Try: (run-at-time nil (* 5 60) (lambda () (let ((save-...
user avatar
  • 6,894
7 votes

How to set temporary halt after C-x C-c?

You can use sit-for instead of using sleep-for plus t. And the function need not be a command (interactive). sit-for returns t if it waited and nil if the user interrupted the wait. (setq confirm-...
user avatar
  • 70.3k
6 votes
Accepted

How to detect if `read-event` or `y-or-n-p` is running?

Best method seems to be found in eldoc that also displays temporary info in minibuffer: ;; Decide whether now is a good time to display a message. (defun eldoc-display-message-p () (and (eldoc-...
user avatar
4 votes
Accepted

Can I set a timer to run at 7am tomorrow?

Yes - call run-at-time using the encode-time method to pass the time argument as mentioned in its doc string: (run-at-time TIME REPEAT FUNCTION &rest ARGS) Probably introduced at or before ...
user avatar
  • 20.6k
4 votes
Accepted

Timer runs immediately then periodically

Unfortunately, you're telling it to run the function at 04:00am today. Unless you evaluated that code between midnight and 4am, that's a target time in the past, and so Emacs runs it ASAP. The run-at-...
user avatar
  • 43.9k
4 votes
Accepted

start-process: Setting current directory: No such file or directory

Yes, that's the established technique. In my code I use temporary-file-directory instead, but this is just a detail.
user avatar
4 votes
Accepted

Toggle timer function

You need to keep the timer object in a global variable or closure. Take global variable for example: (defvar my/timer nil) (defun toggle-mytimer () (interactive) (if (not (timerp my/timer)) ...
user avatar
  • 833
3 votes

Timer on modeline: how to update modeline every second?

I try not to use standard timers that repeat because they can affect performance while typing or scrolling. An idle-timer only fires once each time an idle occurs. Therefore, I would suggest setting ...
user avatar
  • 17.8k
3 votes

run-at-time under certain circumstance

My personal opinion is that Emacs is not an operating system, and while it is often convenient to do things in Emacs, this is the kind of task that is better solved outside of Emacs. Scheduling your ...
user avatar
  • 5,520
3 votes
Accepted

Time-of-day triggers

You can use run-at-time to run some code at a specific time. For example, to message "go home" every day at 5 pm: (setq go-home-timer (run-at-time "5:00pm" (* 24 60 60) ...
user avatar
  • 8,629
3 votes
Accepted

Buffer file replaced with lockfile/backupfile location

It helps to read the fine variable descriptions. Namely, the following about auto-save-visited-file-name: This variable is obsolete since Emacs 26.1; use `auto-save-visited-mode' instead. You can ...
user avatar
  • 111
2 votes
Accepted

Identifying functions that trigger timers and cause redisplays when profiling Emacs execution

M-x list-timers will show you active and idle timers, how often/when they trigger, and what function they run. The command is disabled by default, but you can enable it for one-time use or permanently ...
user avatar
  • 20.6k
2 votes

Timer on modeline: how to update modeline every second?

Thanks to @lawlist for directing me to timer.el. A solution I implemented uses timer.el's run-at-time. I replaced the format-line-list item with: (if (< (length chronos--timers-list) 2) "" (...
user avatar
  • 331
2 votes

Count down timer and org

I can't help with the pop up but, in place of that, I suggest that you use a bell sound. You should have a wav sound file for this and you could use a bell sound like org-pomodoro's. From C-h f org-...
user avatar
  • 626
1 vote

Locking an org-timer into the mode-line

You can set the mode line to be fixed with (setq-default mode-line-format "FOO") It will always show "FOO" and nothing else. I assume that if you do (setq-default mode-line-format ...
user avatar
  • 20.6k
1 vote
Accepted

How to time org-mode code block execution?

This can be handled by advising the code that handles source code block execution in Org Mode. The function in question is org-babel-execute-src-block - it runs a hook after it executes, but not ...
user avatar
  • 895
1 vote
Accepted

run-at-time in the future only

Here's some code that converts simple HH:MM time specifications to encoded times for either today or tomorrow, depending on whether the given time is later or earlier than the current time. There are ...
user avatar
  • 20.6k
1 vote

How to detect if `read-event` or `y-or-n-p` is running?

For y-or-n-p, you could check the value of input-method-use-echo-area. It is turned on by read-key-sequence, which is indirectly used by y-or-n-p – and quite likely by various other commands you'd ...
user avatar
1 vote
Accepted

Change buffer displayed in window after x amount of time

I implemented Drews comment. (Improvements are welcome) Here are 2 functions. One, which starts cycling buffers in current selected window my-cycle-buffers. And one, which stops cycling my-cycle-...
user avatar
  • 4,276
1 vote
Accepted

Error running timer "show-paren-function" when displaying matching line in message/mini buffer

A quick look at the code shows this: blink-matching-open does not return a string - the return value is not the matching text. So message complains that its arg is not a string. blink-matching-open ...
user avatar
  • 70.3k

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