help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : messages to *Messages* without appearing in mini-buffer


From: Emanuel Berg
Subject: Re: [External] : messages to *Messages* without appearing in mini-buffer?
Date: Fri, 12 Nov 2021 04:20:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Michael Heerdegen wrote:

> Invoking commands doesn't print a return value. And invoking
> commands is what you do all the time.

Still ... IMO a dedicated function is better than setting
variable back and forth if you plan to use this a lot.

Here is what you can do to have a log if you will ...

But there is a bug somewhere. Rarely but it happens there is
some complain about recentering. Don't know what that is or if
that is related to some other code ...

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/todo-did.el
;;;   https://dataswamp.org/~incal/emacs-init/todo-did.el

(defun todo-get-buffer ()
  (let*((todo-env-var "TODO_FILE")
        (todo-file    (getenv todo-env-var))
        (todo-buffer  (if todo-file
                          (find-file-noselect todo-file t)
                        (error "Set the variable %s first" todo-env-var) )))
  todo-buffer) )

(defun todo-sort-and-save ()
  (sort-lines nil (point-min) (point-max)) ; not REVERSE
  (whitespace-cleanup)
  (save-buffer) )

(defun todo-insert-entry (entry buffer)
  (with-current-buffer buffer
    (goto-char (point-max))
    (insert "\n" entry)
    (todo-sort-and-save) ))

(defun todo (what)
  (interactive "sdo what: ")
  (todo-insert-entry what (todo-get-buffer)) )

(defun todo-show-file ()
  (interactive)
  (let ((todo-buffer (todo-get-buffer)))
    (with-current-buffer todo-buffer
      (when (buffer-modified-p todo-buffer)
        (todo-sort-and-save) )
      (switch-to-buffer todo-buffer) )))

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]