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 function you want to call takes parameters, you can specify them as additional parameters to run-at-time:
(run-at-time "5 sec" nil #'message "Tempus volat, hora ...
You can roll your own predicate function that waits for 3 seconds and invariably returns non-nil (unless it is interrupted with C-g):
(lambda (&rest args)
(message "Quitting in 3 seconds. Press `C-g' to stop.")
or a variant which will read any key:
One solution for that narrow case is to dynamically set save-silently for that invocation specific invocation. Try:
(run-at-time nil (* 5 60)
(let ((save-silently t))
You might alternatively use advice to globally accomplish the same thing. See Advising Functions in the Emacs ...
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.
(lambda (&rest _)
(message "Quit in 3 sec (`C-g' or other action cancels)")
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 ()
;; If this-command is non-nil while running via an idle
;; timer, we're still in the middle of executing a command,
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 Emacs version 19.26.
Perform an action at time TIME.
Repeat the action every REPEAT seconds, if REPEAT is non-nil.
REPEAT may be an integer or floating point ...
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-time code knows this is a bit dumb:
;; Handle "11:23pm" and the like. Interpret it as meaning today
;; which admittedly is rather stupid if we ...
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 ()
(if (not (timerp my/timer))
(setq my/timer (run-with-timer 5 5 'princ "Ciao"))
(setq my/timer nil)))
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 up a system that runs an idle timer while Emacs has focus and a standard timer when Emacs loses focus. Since that is outside the scope of the question, I will ...
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 backups within Emacs means that they won't run if Emacs is not running, and that they might run twice if you have two instances of Emacs open. Since Emacs has ...
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:
(* 24 60 60)
(message "go home!"))))
You can stop it with:
You can create a hook and set it up ...
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-timer-set-timer (org-timer-set-timer function help):
With two ‘C-u’ prefix arguments, use ‘org-timer-default-timer’ without
prompting the user for a ...
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 '("" display-time-string org-mode-line-string org-timer-mode-line-string " " est-target))
and enable things appropriately (e.g. you have ...
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 before, so the advice feature is required - and probably preferred for this use.
(defun gjg/time-call (time-call &rest args)
(message "Ohai %s" ...
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 three main functions:
convert-hh:mm-to-decoded converts a simple time spec in HH:MM format (N.B. no AM/PM specification - use 24-hour time instead) into the ...
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 like to treat the same way.
Detecting an active read-event seems to be harder. Perhaps it's preferable to call it via a wrapper which rebinds some variable to let ...
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-buffers-kill.
You can both bind to a hotkey if you want.
(defun my-cycle-buffers (seconds-delay)
(setq my-window (selected-window)
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 itself calls message to show the matching text, so you should be able to just remove your (when matching-text...).