From 52cde64326ef8175bbbb7828670b1f0920a34b7c Mon Sep 17 00:00:00 2001 From: Ivan Andrus Date: Sat, 6 Apr 2024 20:07:11 -0500 Subject: [PATCH 1/2] Add special set function so that customizing display options will take effect immediately --- memento-mori.el | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/memento-mori.el b/memento-mori.el index 6ca5de0..243a41a 100644 --- a/memento-mori.el +++ b/memento-mori.el @@ -58,12 +58,16 @@ Really, it adds it to the `global-mode-string', which usually appears in the mode line, however, if you have customized your mode line it may not appear." :group 'memento-mori - :type 'boolean) + :type 'boolean + :set #'memento-mori--set-value-and-update-display + :initialize #'custom-initialize-default) (defcustom memento-mori-display-in-frame-title nil "If non-nil, `memento-mori-mode' will add mementos to the frame title." :group 'memento-mori - :type 'boolean) + :type 'boolean + :set #'memento-mori--set-value-and-update-display + :initialize #'custom-initialize-default) (defcustom memento-mori-initial-scratch-message nil "If non-nil, overwrite the value of `initial-scratch-message' with this. @@ -73,6 +77,7 @@ If this contains a %q it will be replaced with a random quote from Ultimately, it will be displayed as the initial documentation in *scratch* buffer at startup." + :group 'memento-mori :type '(choice (text :tag "Scratch message format") (const :tag "none" nil))) @@ -82,7 +87,9 @@ This is deprecated in favor of the more flexible `memento-mori-mementos'. To use `memento-mori-mementos' customize it, or erase customization of `memento-mori-birth-date'." :group 'memento-mori - :type 'string) + :type 'string + :set #'memento-mori--set-value-and-update + :initialize #'custom-initialize-default) (make-obsolete-variable 'memento-mori-birth-date 'memento-mori-mementos "0.2.1") @@ -162,7 +169,9 @@ of precision depending on if it's longer than 10 years or not." (plist :key-type symbol :options ((:until string :tag "Date") (:since string) (:formula function)) - :value-type string)))) + :value-type string))) + :set #'memento-mori--set-value-and-update + :initialize #'custom-initialize-default) (define-obsolete-variable-alias 'memento-mori-age-string 'memento-mori-string "0.2.0") @@ -251,6 +260,16 @@ The string shown in the mode line and/or frame title when by the user, but can be used in other places such as org-mode agendas to display the current momento.") +(defun memento-mori--set-value-and-update-display (symbol value) + "Function to set display values, so that the display will then be recalculated." + (set-default-toplevel-value symbol value) + (memento-mori--add-mementos)) + +(defun memento-mori--set-value-and-update (symbol value) + "Function to set memento config, so that a new memento will be chosen." + (set-default-toplevel-value symbol value) + (memento-mori--update)) + (defvar memento-mori--modeline-construct `(memento-mori-mode ((:propertize From ceb02b37f22c26b4ddd08697cdca550c27791e3c Mon Sep 17 00:00:00 2001 From: Ivan Andrus Date: Sat, 6 Apr 2024 22:08:06 -0500 Subject: [PATCH 2/2] Fix checks by depending on a newer Emacs --- memento-mori.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memento-mori.el b/memento-mori.el index 243a41a..99ac07c 100644 --- a/memento-mori.el +++ b/memento-mori.el @@ -6,7 +6,7 @@ ;; Maintainer: Ivan Andrus ;; URL: https://github.com/gvol/emacs-memento-mori ;; Version: 0.3.1 -;; Package-Requires: ((emacs "24.3")) +;; Package-Requires: ((emacs "24.4")) ;; Keywords: help ;; SPDX-License-Identifier: ISC