Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add special set function so that customizing display options will take effect immediately #29

Merged
merged 2 commits into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions memento-mori.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; Maintainer: Ivan Andrus <[email protected]>
;; 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

Expand Down Expand Up @@ -53,17 +53,21 @@
:group 'help)

(defcustom memento-mori-display-in-modeline t
"If non-nil, `memento-mori-mode' will add mementos to the mode line.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 56 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.
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."

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 66 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.
: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.
Expand All @@ -73,6 +77,7 @@

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)))

Expand All @@ -82,7 +87,9 @@
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")

Expand Down Expand Up @@ -162,7 +169,9 @@
(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")
Expand Down Expand Up @@ -247,10 +256,20 @@
(defvar memento-mori-string ""
"The memento mori memento.
The string shown in the mode line and/or frame title when
`memento-mori-mode' is enabled. This is not meant to be changed

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.

Check warning on line 259 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Disambiguate memento-mori-mode by preceding w/ function,command,variable,option or symbol.
by the user, but can be used in other places such as org-mode

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (snapshot, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Lisp symbol `org-mode' should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Lisp symbol ‘org-mode’ should appear in quotes

Check warning on line 260 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (release-snapshot, false)

Lisp symbol ‘org-mode’ should appear in quotes
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."

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (snapshot, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Argument `symbol' should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 264 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (release-snapshot, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string
(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."

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (snapshot, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Argument `symbol' should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string

Check warning on line 269 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (release-snapshot, false)

Argument ‘symbol’ should appear (as SYMBOL) in the doc string
(set-default-toplevel-value symbol value)
(memento-mori--update))

(defvar memento-mori--modeline-construct
`(memento-mori-mode
((:propertize
Expand Down Expand Up @@ -280,7 +299,7 @@
(error "Birth date not set. Try M-x customize-group memento-mori")))

(defun memento-mori--parse-time (value)
"Return your birth time in `encode-time' format.

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (snapshot, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Argument `value' should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Argument ‘value’ should appear (as VALUE) in the doc string

Check warning on line 302 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (release-snapshot, false)

Argument ‘value’ should appear (as VALUE) in the doc string
The birth time is parsed from `memento-mori-birth-date' using
`parse-time-string'. An error is signaled if it is not valid."
(when (symbolp value)
Expand Down Expand Up @@ -314,7 +333,7 @@
"Randomly choose a quote from `memento-mori-quotes'."
(nth (random (length memento-mori-quotes)) memento-mori-quotes))

(defun memento-mori--format-memento (memento)

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

Unused lexical variable ‘current-time-list’

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

Unused lexical variable ‘current-time-list’

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

Unused lexical variable ‘current-time-list’

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

Unused lexical variable ‘current-time-list’

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

Unused lexical variable `current-time-list'

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Unused lexical variable ‘current-time-list’

Check warning on line 336 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Unused lexical variable ‘current-time-list’
"Format MEMENTO based on the current time."
(let* ((format-string (car memento))
(args-plist (cdr memento))
Expand All @@ -322,7 +341,7 @@
(since-value (plist-get args-plist :since))
(_ (when (not (or until-value since-value))
(error ":since or :until required. Parsing %s" memento)))
(current-time-list nil)

Check warning on line 344 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Unused lexical variable `current-time-list'

Check warning on line 344 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Unused lexical variable `current-time-list'
(until-seconds (when until-value
(float-time
(time-subtract
Expand Down Expand Up @@ -353,7 +372,7 @@
(/ since-seconds (* 60 60 24))
days))
(t 0)))))
(format-spec format-string

Check warning on line 375 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 375 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 375 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 375 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 375 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

format-spec called with 3 arguments, but accepts only 2
`((?Y . ,years)
(?y . ,(truncate years))
(?M . ,months)
Expand Down Expand Up @@ -392,13 +411,13 @@
(when (and memento-mori-initial-scratch-message
(boundp 'initial-scratch-message))
(setq initial-scratch-message
(format-spec memento-mori-initial-scratch-message

Check warning on line 414 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (25.1, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 414 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.2, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 414 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.3, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 414 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (26.1, false)

format-spec called with 3 arguments, but accepts only 2

Check warning on line 414 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (24.4, false)

format-spec called with 3 arguments, but accepts only 2
`((?m . ,memento-mori-string)
(?q . ,(memento-mori--random-quote)))
'ignore))))

(defun memento-mori--add-mementos ()
"Adds constructs to mode line and/or frame title to display mementos.

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (snapshot, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (29.1, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.2, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (28.1, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.2, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (27.1, false)

Probably "Adds" should be imperative "Add"

Check warning on line 420 in memento-mori.el

View workflow job for this annotation

GitHub Actions / check (release-snapshot, false)

Probably "Adds" should be imperative "Add"
Where it adds it is controlled by `memento-mori-display-in-modeline' and
`memento-mori-display-in-frame-title' respectively.

Expand Down
Loading