├── .dir-locals.el ├── .gitignore ├── CHANGELOG.org ├── COPYING ├── README.md ├── README.org ├── doclicense.texi ├── tmr-tabulated.el └── tmr.el /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((emacs-lisp-mode . ((indent-tabs-mode . nil)))) 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.elc 2 | *-autoloads.el 3 | *-pkg.el 4 | tmr.info 5 | tmr.texi 6 | /makel.mk 7 | -------------------------------------------------------------------------------- /CHANGELOG.org: -------------------------------------------------------------------------------- 1 | #+title: Change log of TMR 2 | #+author: Protesilaos Stavrou 3 | #+email: info@protesilaos.com 4 | #+options: ':nil toc:nil num:nil author:nil email:nil 5 | #+startup: content 6 | 7 | This document contains the release notes for each tagged commit on the 8 | project's main git repository: . 9 | 10 | The newest release is at the top. For further details, please consult 11 | the manual: . 12 | 13 | #+toc: headlines 1 insert TOC here, with one headline level 14 | 15 | * Version 1.1.0 on 2025-04-18 16 | :PROPERTIES: 17 | :CUSTOM_ID: h:41248cbf-d399-411d-91ff-5359a00a1577 18 | :END: 19 | 20 | This version makes small refinements to an already stable package. 21 | 22 | ** All of =tmr-tabulated.el= is part of =tmr.el= 23 | :PROPERTIES: 24 | :CUSTOM_ID: h:cd10fa6b-60ed-4045-ae32-780e62b50f21 25 | :END: 26 | 27 | The command ~tmr-tabulated-view~, which produces a grid with 28 | timers+descriptions, used to be in a separate file. It now is part of 29 | the singular =tmr.el= to keep things simple. Users who were using 30 | =(require 'tmr-tabulated)= or similar will now get a warning. Simply 31 | load ~tmr~ instead. 32 | 33 | ** Refined the behaviour of the ~tmr-tabulated-view~ command 34 | :PROPERTIES: 35 | :CUSTOM_ID: h:bd56a213-7714-4bd7-bd1a-f3ac108f27d2 36 | :END: 37 | 38 | When the command ~tmr-tabulated-view~ (alias ~tmr-list-timers~) is 39 | called interactively, it uses the =*tmr-tabulated-view*= buffer just 40 | as it did before. Though it also evaluates the new user option 41 | ~tmr-list-timers-action-alist~: it is a variable that controls where 42 | the buffer is displayed. The default value displays the buffer at the 43 | bottom of the Emacs frame and makes some other tweaks for usability. 44 | 45 | Watch my video on the ~display-buffer-alist~ for further details on 46 | how to control the display of buffers: . 47 | 48 | The ~tmr-tabulated-view~ command is further revised to make it 49 | callable from a program. One scenario where we do this is to interrupt 50 | the termination of Emacs if there are running timers (more below). 51 | 52 | ** TMR interrupts the termination of Emacs if it must 53 | :PROPERTIES: 54 | :CUSTOM_ID: h:5a4bf956-b1c2-446b-848c-eb64ffa50109 55 | :END: 56 | 57 | In the past, we did not have anything to prevent the termination of 58 | Emacs if timers were running: Emacs would simply shut down. Now we 59 | define the ~tmr-kill-emacs-query-function~, which is added to the 60 | standard ~kill-emacs-query-functions~: if there are running timers, it 61 | asks for confirmation before closing Emacs. To make it easier for 62 | users to decide how to proceed, it also pops up the list with all the 63 | timers (i.e. it uses ~tmr-tabulated-view~ from Lisp, as noted above). 64 | 65 | ** The list view is easier to follow 66 | :PROPERTIES: 67 | :CUSTOM_ID: h:c432f1ab-dcaf-4a01-8004-cf268a24b228 68 | :END: 69 | 70 | The buffer produced by ~tmr-tabulated-view~ now uses more colours to 71 | make it easier to track the data it presents. These are all the faces 72 | it applies: 73 | 74 | - ~tmr-tabulated-start-time~ :: The time when the timer was started. 75 | 76 | - ~tmr-tabulated-end-time~ :: The time when the timer is set to end. 77 | 78 | - ~tmr-tabulated-remaining-time~ :: The remaining time. 79 | 80 | - ~tmr-tabulated-acknowledgement~ :: Whether the timer needs to be 81 | "acknowledged" after it ends (if it is marked as "acknowledged", 82 | then it will not go away until the user confirms they have seen it). 83 | 84 | - ~tmr-tabulated-description~ :: The text describing what the timer is 85 | about. 86 | 87 | * Version 1.0.0 on 2024-08-30 88 | :PROPERTIES: 89 | :CUSTOM_ID: h:88595352-0263-425c-baab-6042f63ae28a 90 | :END: 91 | 92 | This version adds quality-of-life improvements to an already stable 93 | base. 94 | 95 | ** The ~tmr-with-details~ supersedes the ~tmr-with-description~ 96 | :PROPERTIES: 97 | :CUSTOM_ID: h:ac3d5ea6-2e89-477b-a5eb-9b408ef30b4e 98 | :END: 99 | 100 | The ~tmr-with-description~ would always prompt for a time input and 101 | then a description of the resulting timer object. We now provide a 102 | more general command, ~tmr-with-details~, which does this in addition 103 | to an extra prompt for an acknowledgement. What an "acknowledgement" 104 | is, is documented in the following section. 105 | 106 | ** Timers can now be "acknowledged" 107 | :PROPERTIES: 108 | :CUSTOM_ID: h:1a971ba1-09a6-4df6-bbe5-73685430417c 109 | :END: 110 | 111 | Normally, when a timer elapses it does not stick around to notify the 112 | user again and again. This means that the user may miss the one 113 | notification if, say, they were away from the computer. As such, we 114 | now provide an opt-in mechanism where a timer persists until it is 115 | explicitly acknowledged as finished. The acknowledgement is either an 116 | additional duration for the timer to produce another notification in 117 | the future, or an explicit consent from the timer to count as 118 | finished. The goal is to help the user never miss a timer. 119 | 120 | Setting up an acknowledgement can be done in the following ways: 121 | 122 | - Call the standard ~tmr~ command with a prefix argument (=C-u= by 123 | default). This will make it prompt for a description and an 124 | acknowledgement. 125 | 126 | - Use the new command ~tmr-with-details~, which asks for a timer 127 | input, a description, and whether to include an acknowledgement 128 | prompt. 129 | 130 | - Use the new command ~tmr-toggle-acknowledge~, which will prompt for 131 | a timer and then toggle the acknowledgement status on/off. In this 132 | scenario, the timer already exists (e.g. it was created with ~tmr~ 133 | without a prefix argument). 134 | 135 | All timers are listed in a nice list with the command 136 | ~tmr-tabulated-view~. An extra column will indicate their 137 | acknowledgement status. 138 | 139 | Thanks to Daniel Mendler for contributing this feature. This was done 140 | in the form of patches, sent via email. Daniel has assigned copyright 141 | to the Free Software Foundation. 142 | 143 | ** The ~tmr-list-timers~ is an alias for ~tmr-tabulated-view~ 144 | :PROPERTIES: 145 | :CUSTOM_ID: h:f1d80033-45f5-47cc-b76b-c8aee05dd789 146 | :END: 147 | 148 | Perhaps the "list timers" is a more meaningful description of what the 149 | command does, as opposed to "tabulated view". 150 | 151 | ** Use the ~tmr-prefix-map~ 152 | :PROPERTIES: 153 | :CUSTOM_ID: h:20dcbc95-a376-4130-8ae8-7be6c7aa149a 154 | :END: 155 | 156 | We now define a prefix keymap that users can bind directly to a key 157 | and get all the TMR commands in one go. For example, this adds all TMR 158 | commands behind the =C-c t= prefix: 159 | 160 | #+begin_src emacs-lisp 161 | (define-key global-map (kbd "C-c t") 'tmr-prefix-map) 162 | #+end_src 163 | 164 | Thanks to Daniel Mendler for this patch. 165 | 166 | ** TMR uses its own faces 167 | :PROPERTIES: 168 | :CUSTOM_ID: h:1d6ddc5a-8856-40d4-8328-f6413cb37f30 169 | :END: 170 | 171 | Theme developers or users can now modify how the various TMR 172 | indicators look by tweaking the faces we provide: 173 | 174 | - ~tmr-duration~ 175 | - ~tmr-description~ 176 | - ~tmr-start-time~ 177 | - ~tmr-end-time~ 178 | - ~tmr-is-acknowledged~ 179 | - ~tmr-must-be-acknowledged~ 180 | - ~tmr-finished~ 181 | 182 | The default values inherit from basic faces that should be supported 183 | everywhere. 184 | 185 | Existing users will not notice any visual difference, other things 186 | being equal. 187 | 188 | ** Fixed some typos in the manual 189 | :PROPERTIES: 190 | :CUSTOM_ID: h:2b0e0105-d142-45de-807d-b2ef60c25dc8 191 | :END: 192 | 193 | Thanks to Ed Tavinor for the contribution. The change pertains to 194 | typos and is within the limit of edits that do not require copyright 195 | assignment to the Free Software Foundation. 196 | 197 | * Version 0.4.0 on 2022-07-07 198 | :PROPERTIES: 199 | :CUSTOM_ID: h:52e3b3ac-70ef-47c5-895c-92adbd5c92b0 200 | :END: 201 | 202 | The general theme of this release is that TMR became simpler, better, 203 | and more robust. Daniel Mendler provided lots of patches and is now 204 | recognised as co-author of the package together with Damien Cassou and 205 | me (Protesilaos). With the exception of documentation changes and other 206 | accompanying tweaks, all of the following are courtesy of Daniel 207 | Mendler. Consult the git log for the minutia. 208 | 209 | + Timers can also be set using an absolute time input. For example, 210 | =21:45= will set a timer from now until the specified time. The 211 | familiar ways of starting timers with relative values, work as they 212 | did before. This is part of a wider internal revision to make the 213 | parsing of input more strict. 214 | 215 | + TMR no longer maintains distinct feature sets between its minibuffer 216 | and tabulated interfaces. What works in one context, works equally in 217 | the other. All commands that were formerly available only in the 218 | ~tmr-tabulated-mode~ (accessed via ~tmr-tabulated-view~) are now 219 | implemented anew to provide the requisite minibuffer capabilities. 220 | When called from inside the ~tmr-tabulated-mode~, the commands operate 221 | on the timer at point. Otherwise they prompt for completion among the 222 | available timers (where relevant). This covers all operations for 223 | creating, cloning, [re-]describing, rescheduling, and removing timers. 224 | The ~tmr-tabulated-mode-map~ is updated thus: 225 | 226 | #+begin_src emacs-lisp 227 | (defvar tmr-tabulated-mode-map 228 | (let ((map (make-sparse-keymap))) 229 | (define-key map "k" #'tmr-remove) 230 | (define-key map "r" #'tmr-remove) 231 | (define-key map "R" #'tmr-remove-finished) 232 | (define-key map "+" #'tmr) 233 | (define-key map "t" #'tmr) 234 | (define-key map "*" #'tmr-with-description) 235 | (define-key map "T" #'tmr-with-description) 236 | (define-key map "c" #'tmr-clone) 237 | (define-key map "e" #'tmr-edit-description) 238 | (define-key map "s" #'tmr-reschedule) 239 | map) 240 | "Keybindings for `tmr-tabulated-mode-map'.") 241 | #+end_src 242 | 243 | Similarly, our sample key bindings are these: 244 | 245 | #+begin_src emacs-lisp 246 | ;; OPTIONALLY set your own global key bindings: 247 | (let ((map global-map)) 248 | (define-key map (kbd "C-c t t") #'tmr) 249 | (define-key map (kbd "C-c t T") #'tmr-with-description) 250 | (define-key map (kbd "C-c t l") #'tmr-tabulated-view) ; "list timers" mnemonic 251 | (define-key map (kbd "C-c t c") #'tmr-clone) 252 | (define-key map (kbd "C-c t k") #'tmr-cancel) 253 | (define-key map (kbd "C-c t s") #'tmr-reschedule) 254 | (define-key map (kbd "C-c t e") #'tmr-edit-description) 255 | (define-key map (kbd "C-c t r") #'tmr-remove) 256 | (define-key map (kbd "C-c t R") #'tmr-remove-finished)) 257 | #+end_src 258 | 259 | + The tabulated view now shows the remaining time for all timer objects. 260 | This is how the =*tmr-tabulated-view*= buffer is formatted: 261 | 262 | #+begin_example 263 | Start End Remaining Description 264 | 10:11:49 10:11:54 ✔ 265 | 10:11:36 10:31:36 19m 35s 266 | 10:11:32 10:26:32 14m 31s Yet another test 267 | 10:11:16 10:21:16 9m 14s Testing how it works 268 | #+end_example 269 | 270 | + All timer objects are refactored to expose a properly formatted 271 | completion table. The completion category is ~tmr-timer~. In 272 | practical terms, =embark= (and other standards-compliant packages) can 273 | operate on them. The manual provides sample glue code for Embark: 274 | 275 | #+begin_src emacs-lisp 276 | (defvar tmr-action-map 277 | (let ((map (make-sparse-keymap))) 278 | (define-key map "k" #'tmr-remove) 279 | (define-key map "r" #'tmr-remove) 280 | (define-key map "R" #'tmr-remove-finished) 281 | (define-key map "c" #'tmr-clone) 282 | (define-key map "e" #'tmr-edit-description) 283 | (define-key map "s" #'tmr-reschedule) 284 | map)) 285 | 286 | (with-eval-after-load 'embark 287 | (add-to-list 'embark-keymap-alist '(tmr-timer . tmr-action-map)) 288 | (cl-loop 289 | for cmd the key-bindings of tmr-action-map 290 | if (commandp cmd) do 291 | (add-to-list 'embark-post-action-hooks (list cmd 'embark--restart)))) 292 | #+end_src 293 | 294 | The [[https://github.com/oantolin/embark/wiki/Additional-Actions#actions-for-prots-tmr-tmr-may-ring][Embark Wiki]] is updated accordingly. 295 | 296 | + The new user option ~tmr-confirm-single-timer~ governs how TMR should 297 | behave while operating on the sole timer. If non-nil (the default), 298 | TMR will always use the minibuffer to select a timer object to operate 299 | on, even when there is only one candidate available. If set to nil, 300 | TMR will not ask for confirmation when there is one timer available: 301 | the operation will be carried out outright. The default value is 302 | optimal for use with Embark. 303 | 304 | + The existing user option ~tmr-description-list~ is revised to accept 305 | either a list of strings (the old approach) or a symbol of a variable 306 | that holds a list of strings. In the latter case, this can be the 307 | ~tmr-description-history~, which is a variable that stores the user's 308 | input at the relevant minibuffer prompt. We have made this the new 309 | default value, as it grows naturally to reflect one's usage of TMR. 310 | Minibuffer histories can persist between sessions if the user enables 311 | the built-in =savehist= library. Sample configuration: 312 | 313 | #+begin_src emacs-lisp 314 | (require 'savehist) 315 | (setq savehist-file (locate-user-emacs-file "savehist")) 316 | (setq history-length 10000) 317 | (setq history-delete-duplicates t) 318 | (setq savehist-save-minibuffer-history t) 319 | (add-hook 'after-init-hook #'savehist-mode) 320 | #+end_src 321 | 322 | + Fixed an edge case where a ~when-let*~ form did not return the 323 | expected value. Thanks to Nathan R. DeGruchy for the patch. The 324 | patch is below the ~15 line threshold and thus does not require 325 | copyright assignment to the Free Software Foundation. 326 | 327 | + Named the mailing list address as the =Maintainer:= of Denote. 328 | Together with the other package headers, they help the user find our 329 | primary sources and/or communication channels. This change conforms 330 | with work being done upstream in package.el by Philip Kaludercic. I 331 | was informed about it here: 332 | . 333 | 334 | + Updated the manual to reflect the aforementioned. 335 | 336 | * Version 0.3.0 on 2022-05-17 337 | :PROPERTIES: 338 | :CUSTOM_ID: h:0a2d4909-0079-47e9-97f4-220e85a811f9 339 | :END: 340 | 341 | The gist of TMR's May Release is that TMR is Maintained Rigorously---but 342 | enough with The Mostly Recursive acronyms! 343 | 344 | + This is the first version for which we produce a change log. The 345 | short story of previous releases: I (Protesilaos) was using and 346 | developing TMR (pronounced as "timer" or "T-M-R") as part of my 347 | personal setup for more than a year until I eventually contributed it 348 | to GNU ELPA. 349 | 350 | + What was once =tmr.el= is now split up into purpose-specific files: 351 | =tmr.el= (core functionality), =tmr-tabulated.el= (grid view), 352 | =tmr-sound.el= (audible notifications), and =tmr-notification.el= 353 | (desktop notifications). 354 | 355 | + The ~tmr-with-description~ command creates a new timer while always 356 | asking for a description. Whereas the standard ~tmr~ command prompts 357 | for a description only when invoked with a prefix argument. 358 | 359 | + The ~tmr-clone~ command copies the duration and optional description 360 | of an existing timer object into a new one. The operation is 361 | performed without further questions, except if a prefix argument is 362 | supplied: in that case the command will prompt for a duration and, if 363 | the original timer had a description, for one as well. The default 364 | values of these prompts are those of the original timer. 365 | 366 | + The ~tmr-remove-finished~ deletes all elapsed timers. This means that 367 | they are removed from the list of available timers and, thus, cannot 368 | be cloned. 369 | 370 | + The ~tmr-timer-created-functions~, ~tmr-timer-completed-functions~, 371 | and ~tmr-timer-cancelled-functions~ are hooks which can be used to 372 | control what happens once a timer is (i) created, (ii) elapses, or 373 | (iii) is cancelled. 374 | 375 | + Elapsed and running timers are displayed in a grid view with the 376 | command ~tmr-tabulated-view~. The buffer looks like this: 377 | 378 | #+begin_example 379 | Start End Finished? Description 380 | 09:22:43 09:32:43 ✔ Prepare tea 381 | 09:17:14 09:37:14 Boil water 382 | 09:07:03 09:57:03 Bake bread 383 | #+end_example 384 | 385 | + In that grid view, it is possible to create a new timer, or operate on 386 | the one at point to cancel, clone, redescribe, and reschedule it. 387 | 388 | + Thanks to Christian Tietze for implementing changes to how desktop 389 | notifications are handled. The overall effect should still be the 390 | same for existing users, though the implementation has been redesigned. 391 | 392 | + Thanks to Damien Cassou who is now is my co-author due to multiple 393 | contributions for =tmr.el=, the addition of the grid view, and the 394 | splitting of TMR into numerous files. Please consult the Git commit 395 | log for the details. (I still am the maintainer.) 396 | 397 | + Christian and Damien have assigned copyright to the Free Software 398 | Foundation. It is required for all packages distributed via GNU ELPA. 399 | 400 | The manual documents the technicalities and provides a sample 401 | configuration. Either evaluate the form =(info "(tmr) Top")= if you 402 | have the package installed or visit https://protesilaos.com/emacs/tmr. 403 | 404 | * Version 0.2.0 on 2022-04-21 405 | :PROPERTIES: 406 | :CUSTOM_ID: h:054285c2-3d90-4adc-ada4-61222b31fb85 407 | :END: 408 | 409 | This entry is retroactively introduced on 2022-07-07. 410 | 411 | + Changed the ~tmr~ and ~tmr-cancel~ commands to handle a list of timers 412 | instead of only interfacing with the last timer. 413 | 414 | + Improved the documentation. 415 | 416 | + Made various internal tweaks and refinements. 417 | 418 | + Added TMR to the official GNU ELPA archive as =tmr=. 419 | 420 | * Version 0.1.0 on 2021-10-02 421 | :PROPERTIES: 422 | :CUSTOM_ID: h:1fce2c20-a16c-4ea9-9006-cf565f78f812 423 | :END: 424 | 425 | This entry is retroactively introduced on 2022-07-07. 426 | 427 | TMR was originally [[https://protesilaos.com/codelog/2021-10-02-introducing-tmr-el/][announced on my website]]. The code was developed as 428 | part of [[https://protesilaos.com/emacs/dotemacs][my dotemacs]] for several months before it was placed in its own 429 | Git repo. Even before the Elisp implementation, the core idea existed 430 | as a standalone shell script, which is still part of [[https://git.sr.ht/~protesilaos/dotfiles][my dotfiles]]. 431 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 2021 Protesilaos Stavrou 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 2021 Protesilaos Stavrou 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TMR 2 | 3 | TMR is an Emacs package that provides facilities for setting timers 4 | using a convenient notation. Lots of commands are available to operate 5 | on timers, while there also exists a tabulated view to display all 6 | timers in a nice grid. 7 | 8 | + Package name (GNU ELPA): `tmr` 9 | + Official manual: 10 | + Change log: 11 | + Git repositories: 12 | + GitHub: 13 | + GitLab: 14 | + Backronym: TMR May Ring; Timer Must Run. 15 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | #+title: TMR May Ring 2 | #+author: Protesilaos Stavrou 3 | #+email: info@protesilaos.com 4 | #+language: en 5 | #+options: ':t toc:nil author:t email:t num:t 6 | #+startup: content 7 | #+macro: stable-version 1.1.0 8 | #+macro: release-date 2025-04-18 9 | #+macro: development-version 1.2.0-dev 10 | #+export_file_name: tmr.texi 11 | #+texinfo_filename: tmr.info 12 | #+texinfo_dir_category: Emacs misc features 13 | #+texinfo_dir_title: TMR May Ring: (tmr) 14 | #+texinfo_dir_desc: Set timers using a convenient notation 15 | #+texinfo_header: @set MAINTAINERSITE @uref{https://protesilaos.com,maintainer webpage} 16 | #+texinfo_header: @set MAINTAINER Protesilaos Stavrou 17 | #+texinfo_header: @set MAINTAINEREMAIL @email{info@protesilaos.com} 18 | #+texinfo_header: @set MAINTAINERCONTACT @uref{mailto:info@protesilaos.com,contact the maintainer} 19 | 20 | This manual, written by Protesilaos Stavrou, describes the customization 21 | options for ~tmr~ (or TMR, TMR May Ring, ...), and provides every other 22 | piece of information pertinent to it. The name of the package is 23 | pronounced as "timer" or "T-M-R". 24 | 25 | The documentation furnished herein corresponds to stable version 26 | {{{stable-version}}}, released on {{{release-date}}}. Any reference to 27 | a newer feature which does not yet form part of the latest tagged 28 | commit, is explicitly marked as such. 29 | 30 | Current development target is {{{development-version}}}. 31 | 32 | + Package name (GNU ELPA): ~tmr~ 33 | + Official manual: 34 | + Change log: 35 | + Git repositories: 36 | + GitHub: 37 | + GitLab: 38 | + Backronym: TMR May Ring; Timer Must Run. 39 | 40 | #+toc: headlines 8 insert TOC here, with eight headline levels 41 | 42 | * COPYING 43 | :PROPERTIES: 44 | :CUSTOM_ID: h:c002f811-ea06-4123-988b-a73183581fb9 45 | :END: 46 | 47 | Copyright (C) 2021-2025 Free Software Foundation, Inc. 48 | 49 | #+begin_quote 50 | Permission is granted to copy, distribute and/or modify this document 51 | under the terms of the GNU Free Documentation License, Version 1.3 or 52 | any later version published by the Free Software Foundation; with no 53 | Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and 54 | with the Back-Cover Texts as in (a) below. A copy of the license is 55 | included in the section entitled “GNU Free Documentation License.” 56 | 57 | (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and 58 | modify this GNU manual.” 59 | #+end_quote 60 | 61 | * Overview 62 | :PROPERTIES: 63 | :CUSTOM_ID: h:7b3966d3-43c6-47f1-816a-8104f634bbd1 64 | :END: 65 | #+cindex: Overview of features 66 | 67 | #+findex: tmr 68 | TMR is an Emacs package that provides facilities for setting timers 69 | using a convenient notation. The first point of entry is the ~tmr~ 70 | command. It prompts for a unit of time, which is represented as a 71 | string that consists of a number and, optionally, a single character 72 | suffix which specifies the unit of time. Without a suffix, the number 73 | is interpreted as a count in minutes. Valid input formats: 74 | 75 | | Input | Meaning | 76 | |-------+-----------| 77 | | 5 | 5 minutes | 78 | | 5m | 5 minutes | 79 | | 5s | 5 seconds | 80 | | 5h | 5 hours | 81 | 82 | The input can be a floating point: 83 | 84 | | Input | Meaning | 85 | |-------+--------------------------| 86 | | 1.5 | 1.5 minutes (90 seconds) | 87 | | 1.5h | 1.5 hours (90 minutes) | 88 | 89 | The input can also be an absolute time, such as =16:00= or =16:00:30=. 90 | It sets a timer from present time until the one specified. 91 | 92 | If ~tmr~ is called with an optional prefix argument (=C-u= with default 93 | key bindings), it asks for a description to be associated with the given 94 | timer. 95 | 96 | #+findex: tmr-with-details 97 | An alternative to the ~tmr~ command is ~tmr-with-details~. The 98 | difference between the two is that the latter always prompts for a 99 | description and if the timer should be acknowledged. 100 | 101 | #+findex: tmr-edit-description 102 | The command ~tmr-edit-description~ can change the description a given 103 | timer object. 104 | 105 | #+findex: tmr-toggle-acknowledge 106 | The command ~tmr-toggle-acknowledge~ toggles the acknowledge flag of a 107 | given timer object. A timer that needs to be acknowledged prompts for 108 | confirmation after it elapses. The user can either confirm and thus 109 | dismiss the timer, or set a new duration for the next reminder, using 110 | the familiar TMR input. 111 | 112 | #+vindex: tmr-descriptions-list 113 | The user option ~tmr-descriptions-list~ defines the completion 114 | candidates that are shown at the description prompt. Its value can be 115 | either a list of strings or the symbol of a variable that holds a list 116 | of strings. The default value of ~tmr-description-history~, is the name 117 | of a variable that contains input provided by the user at the relevant 118 | prompt of the ~tmr~ and ~tmr-with-details~ commands. 119 | 120 | When the timer is set, a message is sent to the echo area recording the 121 | current time and the point in the future when the timer elapses. Echo 122 | area messages can be reviewed with the ~view-echo-area-messages~ which 123 | is bound to =C-h e= by default. To check all timers, use the command 124 | ~tmr-tabulated-view~, which has more features than the generic 125 | =*Messages*= buffer ([[#h:51fe78e0-d614-492b-b7a3-fb6d5bd52a9a][Grid view]]). 126 | 127 | #+findex: tmr-cancel 128 | The ~tmr-cancel~ command cancels running timers without erasing them from 129 | the list of created timer objects. Timers at the completion prompt are 130 | described by the exact time they were set and the input that was used to 131 | create them, including the optional description that ~tmr~ and 132 | ~tmr-with-details~ accept. 133 | 134 | #+findex: tmr-remove 135 | The ~tmr-remove~ command is like ~tmr-cancel~, except it is not limited 136 | to active timers: it can target elapsed ones as well. 137 | 138 | #+findex: tmr-clone 139 | The ~tmr-clone~ command directly copies the duration and optional 140 | description of a timer into a new one. With an optional prefix argument 141 | (=C-u= by default), this command prompts for a duration. If a double 142 | prefix argument is supplied (=C-u C-u=), the command asks for a duration 143 | and then a description. The default values of such prompts are those of 144 | the original timer. 145 | 146 | #+findex: tmr-reschedule 147 | The command ~tmr-reschedule~ changes the duration of the given timer to 148 | a new one provided at the prompt. In practice this is a shortcut to (i) 149 | cloning the timer, (ii) prompting for duration, and (iii) cancelling the 150 | original timer. 151 | 152 | #+findex: tmr-remove-finished 153 | The ~tmr-remove-finished~ command deletes all elapsed timers from the 154 | list of timers. This means that they can no longer be cloned. 155 | 156 | #+vindex: tmr-confirm-single-timer 157 | By default, TMR uses minibuffer completion to pick a timer object in 158 | operations such as cloning and cancelling. If the user option 159 | ~tmr-confirm-single-timer~ is set to nil, TMR will not use completion when 160 | there is only one timer available: it will perform the specified command 161 | outright. 162 | 163 | Timers have hooks associated with their creation, cancellation, and 164 | completion ([[#h:c908f440-da08-462e-be4e-a61fb274ecbc][Hooks]]). TMR can also integrate with the desktop environment 165 | to send notifications ([[#h:56bbbd6f-5b63-4375-9c86-e1eb231be356][Sound and desktop notifications]]). 166 | 167 | #+vindex: tmr-prefix-map 168 | TMR does not specify global key bindings. Instead, it sets up the 169 | ~tmr-prefix-map~, which specifies keys for the relevant commands. The 170 | user has the option to either bind the map to a prefix key, such as 171 | =C-c t= (so ~tmr~ is =C-c t t=), or bind individual commands to the 172 | desired keys ([[#h:69eeb3fb-f11d-431e-ae16-2d9b322871cc][Sample configuration]]). 173 | 174 | ** Grid or tabulated view 175 | :PROPERTIES: 176 | :CUSTOM_ID: h:51fe78e0-d614-492b-b7a3-fb6d5bd52a9a 177 | :END: 178 | #+cindex: About tmr-tabulated and relevant commands 179 | 180 | #+findex: tmr-tabulated-view 181 | #+findex: tmr-list-timers 182 | Timers can be viewed in a grid with ~tmr-tabulated-view~ (alias 183 | ~tmr-list-timers~). The data is placed in the =*tmr-tabulated-view*= 184 | buffer and looks like this: 185 | 186 | #+begin_example 187 | Start End Remaining Description 188 | 10:11:49 10:11:54 ✔ 189 | 10:11:36 10:31:36 19m 35s 190 | 10:11:32 10:26:32 14m 31s Yet another test 191 | 10:11:16 10:21:16 9m 14s Testing how it works 192 | #+end_example 193 | 194 | If a timer has elapsed, it has a check mark associated with it, 195 | otherwise the =Remaining= column shows the time left. A =Description= 196 | is shown only if it is provided while setting the timer, otherwise the 197 | field is left blank. 198 | 199 | Inside this grid view, all TMR commands that operate on timer objects 200 | automatically target the one at point. Whereas the global behaviour is 201 | to use minibuffer completion to pick a timer to operate on. 202 | 203 | The ~tmr-tabulated-view~ command relies on Emacs' ~tabulated-list-mode~. 204 | From the =*tmr-tabulated-view*= buffer, one can invoke the command 205 | ~describe-mode~ (=C-h m= with standard key bindings) to learn about the 206 | applicable functionality, such as how to expand/contract columns and 207 | toggle sorting. 208 | 209 | While in this grid view, one can perform all the operations on timers we 210 | have already covered herein (the =C-h m= will show you their key 211 | bindings in this mode). 212 | 213 | #+vindex: tmr-list-timers-action-alist 214 | The user option ~tmr-list-timers-action-alist~ controls how the 215 | command ~tmr-tabulated-view~ displays its buffer. Its default 216 | behaviour is to (i) place the buffer at the bottom of the Emacs frame, 217 | (ii) resize the window to match the height of the buffer, and (iii) 218 | select that window. 219 | 220 | The value of this user option is the same data that is passed to 221 | ~display-buffer-alist~. It is meant to be customised by advanced 222 | users. Evaluate =(info "(elisp) Displaying Buffers")= to read the 223 | relevant entry in the manual. 224 | 225 | The ~tmr-list-timers-action-alist~ is relevant only when the command 226 | ~tmr-tabulated-view~ is called interactively. In Lisp, the ~tmr-tabulated-view~ 227 | requires the buffer it should use and the concomitant action alist. 228 | 229 | Faces used in the tabulated view: 230 | 231 | #+vindex: tmr-tabulated-start-time 232 | - ~tmr-tabulated-start-time~ :: The time the timer started. 233 | 234 | #+vindex: tmr-tabulated-end-time 235 | - ~tmr-tabulated-end-time~ :: The time the timer will end. 236 | 237 | #+vindex: tmr-tabulated-remaining-time 238 | - ~tmr-tabulated-remaining-time~ :: The timer's remaining time. 239 | 240 | #+vindex: tmr-tabulated-acknowledgement 241 | - ~tmr-tabulated-acknowledgement~ :: Whether the timer needs to be 242 | acknowledged. 243 | 244 | #+vindex: tmr-tabulated-description 245 | - ~tmr-tabulated-description~ :: The description of the timer. 246 | 247 | ** Display timers on the mode line 248 | :PROPERTIES: 249 | :CUSTOM_ID: h:a1938fd5-64ef-4f4f-ade1-c7058d4062fc 250 | :END: 251 | #+cindex: About tmr-mode-line-mode and related user options 252 | 253 | [ This is part of {{{development-version}}}. ] 254 | 255 | #+findex: tmr-mode-line-mode 256 | The ~tmr-mode-line-mode~ is a minor mode that displays running timers 257 | on the mode line. Specifically, the timers are shown as part of the 258 | ~global-mode-string~. This means that they may be displayed on the 259 | ~tab-bar-mode~ instead of the mode line if the user option 260 | ~tab-bar-format~ is configured accordingly. 261 | 262 | #+vindex: tmr-mode-line-format 263 | The user option ~tmr-mode-line-format~ controls how the timers are 264 | rendered. This is a string that treats specially the =%r= and =%d= 265 | specifiers. The =%r= represents the remaining time, while =%d= is the 266 | description of the timer. 267 | 268 | #+vindex: tmr-mode-line-max-desc-length 269 | The user option ~tmr-mode-line-max-desc-length~ sets the maximum 270 | length of a timers description, when the ~tmr-mode-line-format~ is 271 | configured to show descriptions. 272 | 273 | #+vindex: tmr-mode-line-max-timers 274 | The user option ~tmr-mode-line-max-timers~ sets the maximum number of 275 | running timers that are shown on the mode line at any one time. 276 | 277 | #+vindex: tmr-mode-line-separator 278 | The user option ~tmr-mode-line-separator~ specifies a string that is 279 | inserted between timers on the mode line to visually separate them. 280 | 281 | #+vindex: tmr-mode-line-prefix 282 | The user option ~tmr-mode-line-prefix~ specifies a string that is 283 | prepended to the indicator with all the running timers. 284 | 285 | Applicable faces for this case are: 286 | 287 | #+vindex: tmr-mode-line-active 288 | - ~tmr-mode-line-active~ :: Any active timer. 289 | 290 | #+vindex: tmr-mode-line-soon 291 | - ~tmr-mode-line-soon~ :: A timer that expires within 2 minutes. 292 | 293 | #+vindex: tmr-mode-line-urgent 294 | - ~tmr-mode-line-urgent~ :: A timer that expires within 30 seconds. 295 | 296 | ** Hooks 297 | :PROPERTIES: 298 | :CUSTOM_ID: h:c908f440-da08-462e-be4e-a61fb274ecbc 299 | :END: 300 | #+cindex: Hooks triggered by timer operations 301 | 302 | TMR provides the following hooks: 303 | 304 | #+vindex: tmr-timer-created-functions 305 | + ~tmr-timer-created-functions~ :: This is triggered by the ~tmr~ command. 306 | By default, it prints a message in the echo area showing the newly 307 | created timer's start and end time as well as its optional description 308 | (if provided). 309 | 310 | #+vindex: tmr-timer-finished-functions 311 | + ~tmr-timer-finished-functions~ :: This runs when a timer elapses. By 312 | default, it (i) produces a desktop notification which describes the 313 | timer's start/end time and optional description (if available), (ii) 314 | plays an alarm sound ([[#h:56bbbd6f-5b63-4375-9c86-e1eb231be356][Sound and desktop notifications]]), and (iii) prints 315 | a message in the echo area which is basically the same as the desktop 316 | notification. 317 | 318 | #+vindex: tmr-timer-cancelled-functions 319 | + ~tmr-timer-cancelled-functions~ :: This is called by ~tmr-cancel~. By 320 | default, it prints a message in the echo area describing the timer that 321 | was cancelled. 322 | 323 | ** Sound and desktop notifications 324 | :PROPERTIES: 325 | :CUSTOM_ID: h:56bbbd6f-5b63-4375-9c86-e1eb231be356 326 | :END: 327 | #+cindex: Alarm sound and settings for desktop notifications 328 | 329 | #+vindex: tmr-sound-file 330 | #+vindex: tmr-notification-urgency 331 | Once the timer has run its course, it produces a desktop notification and 332 | plays an alarm sound. The notification's message is practically the same 333 | as that which is sent to the echo area. 334 | 335 | The sound file for the alarm is defined in ~tmr-sound-file~, while the 336 | urgency of the notification can be set through the user option 337 | ~tmr-notification-urgency~. Note that it is up to the desktop 338 | environment or notification daemon to decide how to handle the urgency 339 | value. 340 | 341 | If the ~tmr-sound-file~ is nil, or the file is not found, no sound will 342 | be played. 343 | 344 | Sound playback depends on the =ffplay= executable which is part of 345 | =ffmpeg=. 346 | 347 | Desktop notifications work only if Emacs is built with DBus 348 | functionality. This is the norm. If such functionality is not 349 | available, TMR will issue a warning informing the user accordingly. 350 | 351 | ** Minibuffer histories 352 | :PROPERTIES: 353 | :CUSTOM_ID: h:fbedb656-2402-46bc-9763-d5112700c954 354 | :END: 355 | 356 | TMR defines two variables that store user input: ~tmr-duration-history~ 357 | and ~tmr-description-history~. Minibuffer histories can persist between 358 | sessions if the user enables the built-in =savehist= library. Sample 359 | configuration: 360 | 361 | #+begin_src emacs-lisp 362 | (require 'savehist) 363 | (setq savehist-file (locate-user-emacs-file "savehist")) 364 | (setq history-length 500) 365 | (setq history-delete-duplicates t) 366 | (setq savehist-save-minibuffer-history t) 367 | (add-hook 'after-init-hook #'savehist-mode) 368 | #+end_src 369 | 370 | * Installation 371 | :PROPERTIES: 372 | :CUSTOM_ID: h:46378bdf-f6cc-469e-b0b0-1b90dd9aa595 373 | :END: 374 | #+cindex: Installation instructions 375 | 376 | ** GNU ELPA package 377 | :PROPERTIES: 378 | :CUSTOM_ID: h:807c2a8c-3d49-4fb3-bfb9-84d10675c95b 379 | :END: 380 | 381 | The package is available as ~tmr~. Simply do: 382 | 383 | : M-x package-refresh-contents 384 | : M-x package-install 385 | 386 | And search for it. 387 | 388 | GNU ELPA provides the latest stable release. Those who prefer to follow 389 | the development process in order to report bugs or suggest changes, can 390 | use the version of the package from the GNU-devel ELPA archive. Read: 391 | https://protesilaos.com/codelog/2022-05-13-emacs-elpa-devel/. 392 | 393 | ** Manual installation 394 | :PROPERTIES: 395 | :CUSTOM_ID: h:39fae83f-a49a-4887-8132-eb42e61919ea 396 | :END: 397 | 398 | Assuming your Emacs files are found in =~/.emacs.d/=, execute the 399 | following commands in a shell prompt: 400 | 401 | #+begin_src sh 402 | cd ~/.emacs.d 403 | 404 | # Create a directory for manually-installed packages 405 | mkdir manual-packages 406 | 407 | # Go to the new directory 408 | cd manual-packages 409 | 410 | # Clone this repo, naming it "tmr" 411 | git clone https://github.com/protesilaos/tmr tmr 412 | #+end_src 413 | 414 | Finally, in your =init.el= (or equivalent) evaluate this: 415 | 416 | #+begin_src emacs-lisp 417 | ;; Make Elisp files in that directory available to the user. 418 | (add-to-list 'load-path "~/.emacs.d/manual-packages/tmr") 419 | #+end_src 420 | 421 | Everything is in place to set up the package. 422 | 423 | * Sample configuration 424 | :PROPERTIES: 425 | :CUSTOM_ID: h:69eeb3fb-f11d-431e-ae16-2d9b322871cc 426 | :END: 427 | #+cindex: Package configuration 428 | 429 | #+begin_src emacs-lisp 430 | ;; Set to nil to disable the sound 431 | (setq tmr-sound-file "/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga") 432 | 433 | ;; Desktop notification urgency level 434 | (setq tmr-notification-urgency 'normal) 435 | 436 | ;; Read the `tmr-descriptions-list' doc string 437 | (setq tmr-descriptions-list 'tmr-description-history) 438 | 439 | ;; Set global prefix bindings (autoloaded): 440 | (define-key global-map "\C-ct" 'tmr-prefix-map) 441 | 442 | ;; Alternatively bind tmr command (autoloaded): 443 | (define-key global-map "\C-ct" 'tmr) 444 | #+end_src 445 | 446 | * Integration with Embark 447 | :PROPERTIES: 448 | :CUSTOM_ID: h:64711ce4-c023-4f6e-b9aa-b43942013423 449 | :END: 450 | 451 | The =embark= package provides standards-compliant infrastructure to run 452 | context-dependent actions on all sorts of targets (symbol at point, current 453 | completion candidate, etc.). TMR is set up to make its timer objects 454 | recognisable by Embark and registers the ~tmr-action-map~ in Embark. 455 | 456 | * Acknowledgements 457 | :PROPERTIES: 458 | :CUSTOM_ID: h:047ecc52-ca02-4424-a037-c5b6a02383de 459 | :END: 460 | #+cindex: Contributors 461 | 462 | TMR is meant to be a collective effort. Every bit of help matters. 463 | 464 | + Authors :: Protesilaos Stavrou (maintainer), Damien Cassou, Daniel 465 | Mendler, Steven Allen. 466 | 467 | + Contributions to the code or manual :: Christian Tietze, Ed Tavinor, 468 | Nathan R. DeGruchy. 469 | 470 | * GNU Free Documentation License 471 | :PROPERTIES: 472 | :CUSTOM_ID: h:b8b7def2-5ab0-4623-b3ef-2a1bd17bb42a 473 | :END: 474 | 475 | #+texinfo: @include doclicense.texi 476 | 477 | #+begin_export html 478 |
479 | 
480 |                 GNU Free Documentation License
481 |                  Version 1.3, 3 November 2008
482 | 
483 | 
484 |  Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
485 |      
486 |  Everyone is permitted to copy and distribute verbatim copies
487 |  of this license document, but changing it is not allowed.
488 | 
489 | 0. PREAMBLE
490 | 
491 | The purpose of this License is to make a manual, textbook, or other
492 | functional and useful document "free" in the sense of freedom: to
493 | assure everyone the effective freedom to copy and redistribute it,
494 | with or without modifying it, either commercially or noncommercially.
495 | Secondarily, this License preserves for the author and publisher a way
496 | to get credit for their work, while not being considered responsible
497 | for modifications made by others.
498 | 
499 | This License is a kind of "copyleft", which means that derivative
500 | works of the document must themselves be free in the same sense.  It
501 | complements the GNU General Public License, which is a copyleft
502 | license designed for free software.
503 | 
504 | We have designed this License in order to use it for manuals for free
505 | software, because free software needs free documentation: a free
506 | program should come with manuals providing the same freedoms that the
507 | software does.  But this License is not limited to software manuals;
508 | it can be used for any textual work, regardless of subject matter or
509 | whether it is published as a printed book.  We recommend this License
510 | principally for works whose purpose is instruction or reference.
511 | 
512 | 
513 | 1. APPLICABILITY AND DEFINITIONS
514 | 
515 | This License applies to any manual or other work, in any medium, that
516 | contains a notice placed by the copyright holder saying it can be
517 | distributed under the terms of this License.  Such a notice grants a
518 | world-wide, royalty-free license, unlimited in duration, to use that
519 | work under the conditions stated herein.  The "Document", below,
520 | refers to any such manual or work.  Any member of the public is a
521 | licensee, and is addressed as "you".  You accept the license if you
522 | copy, modify or distribute the work in a way requiring permission
523 | under copyright law.
524 | 
525 | A "Modified Version" of the Document means any work containing the
526 | Document or a portion of it, either copied verbatim, or with
527 | modifications and/or translated into another language.
528 | 
529 | A "Secondary Section" is a named appendix or a front-matter section of
530 | the Document that deals exclusively with the relationship of the
531 | publishers or authors of the Document to the Document's overall
532 | subject (or to related matters) and contains nothing that could fall
533 | directly within that overall subject.  (Thus, if the Document is in
534 | part a textbook of mathematics, a Secondary Section may not explain
535 | any mathematics.)  The relationship could be a matter of historical
536 | connection with the subject or with related matters, or of legal,
537 | commercial, philosophical, ethical or political position regarding
538 | them.
539 | 
540 | The "Invariant Sections" are certain Secondary Sections whose titles
541 | are designated, as being those of Invariant Sections, in the notice
542 | that says that the Document is released under this License.  If a
543 | section does not fit the above definition of Secondary then it is not
544 | allowed to be designated as Invariant.  The Document may contain zero
545 | Invariant Sections.  If the Document does not identify any Invariant
546 | Sections then there are none.
547 | 
548 | The "Cover Texts" are certain short passages of text that are listed,
549 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that
550 | the Document is released under this License.  A Front-Cover Text may
551 | be at most 5 words, and a Back-Cover Text may be at most 25 words.
552 | 
553 | A "Transparent" copy of the Document means a machine-readable copy,
554 | represented in a format whose specification is available to the
555 | general public, that is suitable for revising the document
556 | straightforwardly with generic text editors or (for images composed of
557 | pixels) generic paint programs or (for drawings) some widely available
558 | drawing editor, and that is suitable for input to text formatters or
559 | for automatic translation to a variety of formats suitable for input
560 | to text formatters.  A copy made in an otherwise Transparent file
561 | format whose markup, or absence of markup, has been arranged to thwart
562 | or discourage subsequent modification by readers is not Transparent.
563 | An image format is not Transparent if used for any substantial amount
564 | of text.  A copy that is not "Transparent" is called "Opaque".
565 | 
566 | Examples of suitable formats for Transparent copies include plain
567 | ASCII without markup, Texinfo input format, LaTeX input format, SGML
568 | or XML using a publicly available DTD, and standard-conforming simple
569 | HTML, PostScript or PDF designed for human modification.  Examples of
570 | transparent image formats include PNG, XCF and JPG.  Opaque formats
571 | include proprietary formats that can be read and edited only by
572 | proprietary word processors, SGML or XML for which the DTD and/or
573 | processing tools are not generally available, and the
574 | machine-generated HTML, PostScript or PDF produced by some word
575 | processors for output purposes only.
576 | 
577 | The "Title Page" means, for a printed book, the title page itself,
578 | plus such following pages as are needed to hold, legibly, the material
579 | this License requires to appear in the title page.  For works in
580 | formats which do not have any title page as such, "Title Page" means
581 | the text near the most prominent appearance of the work's title,
582 | preceding the beginning of the body of the text.
583 | 
584 | The "publisher" means any person or entity that distributes copies of
585 | the Document to the public.
586 | 
587 | A section "Entitled XYZ" means a named subunit of the Document whose
588 | title either is precisely XYZ or contains XYZ in parentheses following
589 | text that translates XYZ in another language.  (Here XYZ stands for a
590 | specific section name mentioned below, such as "Acknowledgements",
591 | "Dedications", "Endorsements", or "History".)  To "Preserve the Title"
592 | of such a section when you modify the Document means that it remains a
593 | section "Entitled XYZ" according to this definition.
594 | 
595 | The Document may include Warranty Disclaimers next to the notice which
596 | states that this License applies to the Document.  These Warranty
597 | Disclaimers are considered to be included by reference in this
598 | License, but only as regards disclaiming warranties: any other
599 | implication that these Warranty Disclaimers may have is void and has
600 | no effect on the meaning of this License.
601 | 
602 | 2. VERBATIM COPYING
603 | 
604 | You may copy and distribute the Document in any medium, either
605 | commercially or noncommercially, provided that this License, the
606 | copyright notices, and the license notice saying this License applies
607 | to the Document are reproduced in all copies, and that you add no
608 | other conditions whatsoever to those of this License.  You may not use
609 | technical measures to obstruct or control the reading or further
610 | copying of the copies you make or distribute.  However, you may accept
611 | compensation in exchange for copies.  If you distribute a large enough
612 | number of copies you must also follow the conditions in section 3.
613 | 
614 | You may also lend copies, under the same conditions stated above, and
615 | you may publicly display copies.
616 | 
617 | 
618 | 3. COPYING IN QUANTITY
619 | 
620 | If you publish printed copies (or copies in media that commonly have
621 | printed covers) of the Document, numbering more than 100, and the
622 | Document's license notice requires Cover Texts, you must enclose the
623 | copies in covers that carry, clearly and legibly, all these Cover
624 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
625 | the back cover.  Both covers must also clearly and legibly identify
626 | you as the publisher of these copies.  The front cover must present
627 | the full title with all words of the title equally prominent and
628 | visible.  You may add other material on the covers in addition.
629 | Copying with changes limited to the covers, as long as they preserve
630 | the title of the Document and satisfy these conditions, can be treated
631 | as verbatim copying in other respects.
632 | 
633 | If the required texts for either cover are too voluminous to fit
634 | legibly, you should put the first ones listed (as many as fit
635 | reasonably) on the actual cover, and continue the rest onto adjacent
636 | pages.
637 | 
638 | If you publish or distribute Opaque copies of the Document numbering
639 | more than 100, you must either include a machine-readable Transparent
640 | copy along with each Opaque copy, or state in or with each Opaque copy
641 | a computer-network location from which the general network-using
642 | public has access to download using public-standard network protocols
643 | a complete Transparent copy of the Document, free of added material.
644 | If you use the latter option, you must take reasonably prudent steps,
645 | when you begin distribution of Opaque copies in quantity, to ensure
646 | that this Transparent copy will remain thus accessible at the stated
647 | location until at least one year after the last time you distribute an
648 | Opaque copy (directly or through your agents or retailers) of that
649 | edition to the public.
650 | 
651 | It is requested, but not required, that you contact the authors of the
652 | Document well before redistributing any large number of copies, to
653 | give them a chance to provide you with an updated version of the
654 | Document.
655 | 
656 | 
657 | 4. MODIFICATIONS
658 | 
659 | You may copy and distribute a Modified Version of the Document under
660 | the conditions of sections 2 and 3 above, provided that you release
661 | the Modified Version under precisely this License, with the Modified
662 | Version filling the role of the Document, thus licensing distribution
663 | and modification of the Modified Version to whoever possesses a copy
664 | of it.  In addition, you must do these things in the Modified Version:
665 | 
666 | A. Use in the Title Page (and on the covers, if any) a title distinct
667 |    from that of the Document, and from those of previous versions
668 |    (which should, if there were any, be listed in the History section
669 |    of the Document).  You may use the same title as a previous version
670 |    if the original publisher of that version gives permission.
671 | B. List on the Title Page, as authors, one or more persons or entities
672 |    responsible for authorship of the modifications in the Modified
673 |    Version, together with at least five of the principal authors of the
674 |    Document (all of its principal authors, if it has fewer than five),
675 |    unless they release you from this requirement.
676 | C. State on the Title page the name of the publisher of the
677 |    Modified Version, as the publisher.
678 | D. Preserve all the copyright notices of the Document.
679 | E. Add an appropriate copyright notice for your modifications
680 |    adjacent to the other copyright notices.
681 | F. Include, immediately after the copyright notices, a license notice
682 |    giving the public permission to use the Modified Version under the
683 |    terms of this License, in the form shown in the Addendum below.
684 | G. Preserve in that license notice the full lists of Invariant Sections
685 |    and required Cover Texts given in the Document's license notice.
686 | H. Include an unaltered copy of this License.
687 | I. Preserve the section Entitled "History", Preserve its Title, and add
688 |    to it an item stating at least the title, year, new authors, and
689 |    publisher of the Modified Version as given on the Title Page.  If
690 |    there is no section Entitled "History" in the Document, create one
691 |    stating the title, year, authors, and publisher of the Document as
692 |    given on its Title Page, then add an item describing the Modified
693 |    Version as stated in the previous sentence.
694 | J. Preserve the network location, if any, given in the Document for
695 |    public access to a Transparent copy of the Document, and likewise
696 |    the network locations given in the Document for previous versions
697 |    it was based on.  These may be placed in the "History" section.
698 |    You may omit a network location for a work that was published at
699 |    least four years before the Document itself, or if the original
700 |    publisher of the version it refers to gives permission.
701 | K. For any section Entitled "Acknowledgements" or "Dedications",
702 |    Preserve the Title of the section, and preserve in the section all
703 |    the substance and tone of each of the contributor acknowledgements
704 |    and/or dedications given therein.
705 | L. Preserve all the Invariant Sections of the Document,
706 |    unaltered in their text and in their titles.  Section numbers
707 |    or the equivalent are not considered part of the section titles.
708 | M. Delete any section Entitled "Endorsements".  Such a section
709 |    may not be included in the Modified Version.
710 | N. Do not retitle any existing section to be Entitled "Endorsements"
711 |    or to conflict in title with any Invariant Section.
712 | O. Preserve any Warranty Disclaimers.
713 | 
714 | If the Modified Version includes new front-matter sections or
715 | appendices that qualify as Secondary Sections and contain no material
716 | copied from the Document, you may at your option designate some or all
717 | of these sections as invariant.  To do this, add their titles to the
718 | list of Invariant Sections in the Modified Version's license notice.
719 | These titles must be distinct from any other section titles.
720 | 
721 | You may add a section Entitled "Endorsements", provided it contains
722 | nothing but endorsements of your Modified Version by various
723 | parties--for example, statements of peer review or that the text has
724 | been approved by an organization as the authoritative definition of a
725 | standard.
726 | 
727 | You may add a passage of up to five words as a Front-Cover Text, and a
728 | passage of up to 25 words as a Back-Cover Text, to the end of the list
729 | of Cover Texts in the Modified Version.  Only one passage of
730 | Front-Cover Text and one of Back-Cover Text may be added by (or
731 | through arrangements made by) any one entity.  If the Document already
732 | includes a cover text for the same cover, previously added by you or
733 | by arrangement made by the same entity you are acting on behalf of,
734 | you may not add another; but you may replace the old one, on explicit
735 | permission from the previous publisher that added the old one.
736 | 
737 | The author(s) and publisher(s) of the Document do not by this License
738 | give permission to use their names for publicity for or to assert or
739 | imply endorsement of any Modified Version.
740 | 
741 | 
742 | 5. COMBINING DOCUMENTS
743 | 
744 | You may combine the Document with other documents released under this
745 | License, under the terms defined in section 4 above for modified
746 | versions, provided that you include in the combination all of the
747 | Invariant Sections of all of the original documents, unmodified, and
748 | list them all as Invariant Sections of your combined work in its
749 | license notice, and that you preserve all their Warranty Disclaimers.
750 | 
751 | The combined work need only contain one copy of this License, and
752 | multiple identical Invariant Sections may be replaced with a single
753 | copy.  If there are multiple Invariant Sections with the same name but
754 | different contents, make the title of each such section unique by
755 | adding at the end of it, in parentheses, the name of the original
756 | author or publisher of that section if known, or else a unique number.
757 | Make the same adjustment to the section titles in the list of
758 | Invariant Sections in the license notice of the combined work.
759 | 
760 | In the combination, you must combine any sections Entitled "History"
761 | in the various original documents, forming one section Entitled
762 | "History"; likewise combine any sections Entitled "Acknowledgements",
763 | and any sections Entitled "Dedications".  You must delete all sections
764 | Entitled "Endorsements".
765 | 
766 | 
767 | 6. COLLECTIONS OF DOCUMENTS
768 | 
769 | You may make a collection consisting of the Document and other
770 | documents released under this License, and replace the individual
771 | copies of this License in the various documents with a single copy
772 | that is included in the collection, provided that you follow the rules
773 | of this License for verbatim copying of each of the documents in all
774 | other respects.
775 | 
776 | You may extract a single document from such a collection, and
777 | distribute it individually under this License, provided you insert a
778 | copy of this License into the extracted document, and follow this
779 | License in all other respects regarding verbatim copying of that
780 | document.
781 | 
782 | 
783 | 7. AGGREGATION WITH INDEPENDENT WORKS
784 | 
785 | A compilation of the Document or its derivatives with other separate
786 | and independent documents or works, in or on a volume of a storage or
787 | distribution medium, is called an "aggregate" if the copyright
788 | resulting from the compilation is not used to limit the legal rights
789 | of the compilation's users beyond what the individual works permit.
790 | When the Document is included in an aggregate, this License does not
791 | apply to the other works in the aggregate which are not themselves
792 | derivative works of the Document.
793 | 
794 | If the Cover Text requirement of section 3 is applicable to these
795 | copies of the Document, then if the Document is less than one half of
796 | the entire aggregate, the Document's Cover Texts may be placed on
797 | covers that bracket the Document within the aggregate, or the
798 | electronic equivalent of covers if the Document is in electronic form.
799 | Otherwise they must appear on printed covers that bracket the whole
800 | aggregate.
801 | 
802 | 
803 | 8. TRANSLATION
804 | 
805 | Translation is considered a kind of modification, so you may
806 | distribute translations of the Document under the terms of section 4.
807 | Replacing Invariant Sections with translations requires special
808 | permission from their copyright holders, but you may include
809 | translations of some or all Invariant Sections in addition to the
810 | original versions of these Invariant Sections.  You may include a
811 | translation of this License, and all the license notices in the
812 | Document, and any Warranty Disclaimers, provided that you also include
813 | the original English version of this License and the original versions
814 | of those notices and disclaimers.  In case of a disagreement between
815 | the translation and the original version of this License or a notice
816 | or disclaimer, the original version will prevail.
817 | 
818 | If a section in the Document is Entitled "Acknowledgements",
819 | "Dedications", or "History", the requirement (section 4) to Preserve
820 | its Title (section 1) will typically require changing the actual
821 | title.
822 | 
823 | 
824 | 9. TERMINATION
825 | 
826 | You may not copy, modify, sublicense, or distribute the Document
827 | except as expressly provided under this License.  Any attempt
828 | otherwise to copy, modify, sublicense, or distribute it is void, and
829 | will automatically terminate your rights under this License.
830 | 
831 | However, if you cease all violation of this License, then your license
832 | from a particular copyright holder is reinstated (a) provisionally,
833 | unless and until the copyright holder explicitly and finally
834 | terminates your license, and (b) permanently, if the copyright holder
835 | fails to notify you of the violation by some reasonable means prior to
836 | 60 days after the cessation.
837 | 
838 | Moreover, your license from a particular copyright holder is
839 | reinstated permanently if the copyright holder notifies you of the
840 | violation by some reasonable means, this is the first time you have
841 | received notice of violation of this License (for any work) from that
842 | copyright holder, and you cure the violation prior to 30 days after
843 | your receipt of the notice.
844 | 
845 | Termination of your rights under this section does not terminate the
846 | licenses of parties who have received copies or rights from you under
847 | this License.  If your rights have been terminated and not permanently
848 | reinstated, receipt of a copy of some or all of the same material does
849 | not give you any rights to use it.
850 | 
851 | 
852 | 10. FUTURE REVISIONS OF THIS LICENSE
853 | 
854 | The Free Software Foundation may publish new, revised versions of the
855 | GNU Free Documentation License from time to time.  Such new versions
856 | will be similar in spirit to the present version, but may differ in
857 | detail to address new problems or concerns.  See
858 | https://www.gnu.org/licenses/.
859 | 
860 | Each version of the License is given a distinguishing version number.
861 | If the Document specifies that a particular numbered version of this
862 | License "or any later version" applies to it, you have the option of
863 | following the terms and conditions either of that specified version or
864 | of any later version that has been published (not as a draft) by the
865 | Free Software Foundation.  If the Document does not specify a version
866 | number of this License, you may choose any version ever published (not
867 | as a draft) by the Free Software Foundation.  If the Document
868 | specifies that a proxy can decide which future versions of this
869 | License can be used, that proxy's public statement of acceptance of a
870 | version permanently authorizes you to choose that version for the
871 | Document.
872 | 
873 | 11. RELICENSING
874 | 
875 | "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
876 | World Wide Web server that publishes copyrightable works and also
877 | provides prominent facilities for anybody to edit those works.  A
878 | public wiki that anybody can edit is an example of such a server.  A
879 | "Massive Multiauthor Collaboration" (or "MMC") contained in the site
880 | means any set of copyrightable works thus published on the MMC site.
881 | 
882 | "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
883 | license published by Creative Commons Corporation, a not-for-profit
884 | corporation with a principal place of business in San Francisco,
885 | California, as well as future copyleft versions of that license
886 | published by that same organization.
887 | 
888 | "Incorporate" means to publish or republish a Document, in whole or in
889 | part, as part of another Document.
890 | 
891 | An MMC is "eligible for relicensing" if it is licensed under this
892 | License, and if all works that were first published under this License
893 | somewhere other than this MMC, and subsequently incorporated in whole or
894 | in part into the MMC, (1) had no cover texts or invariant sections, and
895 | (2) were thus incorporated prior to November 1, 2008.
896 | 
897 | The operator of an MMC Site may republish an MMC contained in the site
898 | under CC-BY-SA on the same site at any time before August 1, 2009,
899 | provided the MMC is eligible for relicensing.
900 | 
901 | 
902 | ADDENDUM: How to use this License for your documents
903 | 
904 | To use this License in a document you have written, include a copy of
905 | the License in the document and put the following copyright and
906 | license notices just after the title page:
907 | 
908 |     Copyright (c)  YEAR  YOUR NAME.
909 |     Permission is granted to copy, distribute and/or modify this document
910 |     under the terms of the GNU Free Documentation License, Version 1.3
911 |     or any later version published by the Free Software Foundation;
912 |     with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
913 |     A copy of the license is included in the section entitled "GNU
914 |     Free Documentation License".
915 | 
916 | If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
917 | replace the "with...Texts." line with this:
918 | 
919 |     with the Invariant Sections being LIST THEIR TITLES, with the
920 |     Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
921 | 
922 | If you have Invariant Sections without Cover Texts, or some other
923 | combination of the three, merge those two alternatives to suit the
924 | situation.
925 | 
926 | If your document contains nontrivial examples of program code, we
927 | recommend releasing these examples in parallel under your choice of
928 | free software license, such as the GNU General Public License,
929 | to permit their use in free software.
930 | 
931 | #+end_export 932 | 933 | #+html: 956 | -------------------------------------------------------------------------------- /doclicense.texi: -------------------------------------------------------------------------------- 1 | @c The GNU Free Documentation License. 2 | @center Version 1.3, 3 November 2008 3 | 4 | @c This file is intended to be included within another document, 5 | @c hence no sectioning command or @node. 6 | 7 | @display 8 | Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. 9 | @uref{https://fsf.org/} 10 | 11 | Everyone is permitted to copy and distribute verbatim copies 12 | of this license document, but changing it is not allowed. 13 | @end display 14 | 15 | @enumerate 0 16 | @item 17 | PREAMBLE 18 | 19 | The purpose of this License is to make a manual, textbook, or other 20 | functional and useful document @dfn{free} in the sense of freedom: to 21 | assure everyone the effective freedom to copy and redistribute it, 22 | with or without modifying it, either commercially or noncommercially. 23 | Secondarily, this License preserves for the author and publisher a way 24 | to get credit for their work, while not being considered responsible 25 | for modifications made by others. 26 | 27 | This License is a kind of ``copyleft'', which means that derivative 28 | works of the document must themselves be free in the same sense. It 29 | complements the GNU General Public License, which is a copyleft 30 | license designed for free software. 31 | 32 | We have designed this License in order to use it for manuals for free 33 | software, because free software needs free documentation: a free 34 | program should come with manuals providing the same freedoms that the 35 | software does. But this License is not limited to software manuals; 36 | it can be used for any textual work, regardless of subject matter or 37 | whether it is published as a printed book. We recommend this License 38 | principally for works whose purpose is instruction or reference. 39 | 40 | @item 41 | APPLICABILITY AND DEFINITIONS 42 | 43 | This License applies to any manual or other work, in any medium, that 44 | contains a notice placed by the copyright holder saying it can be 45 | distributed under the terms of this License. Such a notice grants a 46 | world-wide, royalty-free license, unlimited in duration, to use that 47 | work under the conditions stated herein. The ``Document'', below, 48 | refers to any such manual or work. Any member of the public is a 49 | licensee, and is addressed as ``you''. You accept the license if you 50 | copy, modify or distribute the work in a way requiring permission 51 | under copyright law. 52 | 53 | A ``Modified Version'' of the Document means any work containing the 54 | Document or a portion of it, either copied verbatim, or with 55 | modifications and/or translated into another language. 56 | 57 | A ``Secondary Section'' is a named appendix or a front-matter section 58 | of the Document that deals exclusively with the relationship of the 59 | publishers or authors of the Document to the Document's overall 60 | subject (or to related matters) and contains nothing that could fall 61 | directly within that overall subject. (Thus, if the Document is in 62 | part a textbook of mathematics, a Secondary Section may not explain 63 | any mathematics.) The relationship could be a matter of historical 64 | connection with the subject or with related matters, or of legal, 65 | commercial, philosophical, ethical or political position regarding 66 | them. 67 | 68 | The ``Invariant Sections'' are certain Secondary Sections whose titles 69 | are designated, as being those of Invariant Sections, in the notice 70 | that says that the Document is released under this License. If a 71 | section does not fit the above definition of Secondary then it is not 72 | allowed to be designated as Invariant. The Document may contain zero 73 | Invariant Sections. If the Document does not identify any Invariant 74 | Sections then there are none. 75 | 76 | The ``Cover Texts'' are certain short passages of text that are listed, 77 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that 78 | the Document is released under this License. A Front-Cover Text may 79 | be at most 5 words, and a Back-Cover Text may be at most 25 words. 80 | 81 | A ``Transparent'' copy of the Document means a machine-readable copy, 82 | represented in a format whose specification is available to the 83 | general public, that is suitable for revising the document 84 | straightforwardly with generic text editors or (for images composed of 85 | pixels) generic paint programs or (for drawings) some widely available 86 | drawing editor, and that is suitable for input to text formatters or 87 | for automatic translation to a variety of formats suitable for input 88 | to text formatters. A copy made in an otherwise Transparent file 89 | format whose markup, or absence of markup, has been arranged to thwart 90 | or discourage subsequent modification by readers is not Transparent. 91 | An image format is not Transparent if used for any substantial amount 92 | of text. A copy that is not ``Transparent'' is called ``Opaque''. 93 | 94 | Examples of suitable formats for Transparent copies include plain 95 | ASCII without markup, Texinfo input format, La@TeX{} input 96 | format, SGML or XML using a publicly available 97 | DTD, and standard-conforming simple HTML, 98 | PostScript or PDF designed for human modification. Examples 99 | of transparent image formats include PNG, XCF and 100 | JPG@. Opaque formats include proprietary formats that can be 101 | read and edited only by proprietary word processors, SGML or 102 | XML for which the DTD and/or processing tools are 103 | not generally available, and the machine-generated HTML, 104 | PostScript or PDF produced by some word processors for 105 | output purposes only. 106 | 107 | The ``Title Page'' means, for a printed book, the title page itself, 108 | plus such following pages as are needed to hold, legibly, the material 109 | this License requires to appear in the title page. For works in 110 | formats which do not have any title page as such, ``Title Page'' means 111 | the text near the most prominent appearance of the work's title, 112 | preceding the beginning of the body of the text. 113 | 114 | The ``publisher'' means any person or entity that distributes copies 115 | of the Document to the public. 116 | 117 | A section ``Entitled XYZ'' means a named subunit of the Document whose 118 | title either is precisely XYZ or contains XYZ in parentheses following 119 | text that translates XYZ in another language. (Here XYZ stands for a 120 | specific section name mentioned below, such as ``Acknowledgements'', 121 | ``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' 122 | of such a section when you modify the Document means that it remains a 123 | section ``Entitled XYZ'' according to this definition. 124 | 125 | The Document may include Warranty Disclaimers next to the notice which 126 | states that this License applies to the Document. These Warranty 127 | Disclaimers are considered to be included by reference in this 128 | License, but only as regards disclaiming warranties: any other 129 | implication that these Warranty Disclaimers may have is void and has 130 | no effect on the meaning of this License. 131 | 132 | @item 133 | VERBATIM COPYING 134 | 135 | You may copy and distribute the Document in any medium, either 136 | commercially or noncommercially, provided that this License, the 137 | copyright notices, and the license notice saying this License applies 138 | to the Document are reproduced in all copies, and that you add no other 139 | conditions whatsoever to those of this License. You may not use 140 | technical measures to obstruct or control the reading or further 141 | copying of the copies you make or distribute. However, you may accept 142 | compensation in exchange for copies. If you distribute a large enough 143 | number of copies you must also follow the conditions in section 3. 144 | 145 | You may also lend copies, under the same conditions stated above, and 146 | you may publicly display copies. 147 | 148 | @item 149 | COPYING IN QUANTITY 150 | 151 | If you publish printed copies (or copies in media that commonly have 152 | printed covers) of the Document, numbering more than 100, and the 153 | Document's license notice requires Cover Texts, you must enclose the 154 | copies in covers that carry, clearly and legibly, all these Cover 155 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on 156 | the back cover. Both covers must also clearly and legibly identify 157 | you as the publisher of these copies. The front cover must present 158 | the full title with all words of the title equally prominent and 159 | visible. You may add other material on the covers in addition. 160 | Copying with changes limited to the covers, as long as they preserve 161 | the title of the Document and satisfy these conditions, can be treated 162 | as verbatim copying in other respects. 163 | 164 | If the required texts for either cover are too voluminous to fit 165 | legibly, you should put the first ones listed (as many as fit 166 | reasonably) on the actual cover, and continue the rest onto adjacent 167 | pages. 168 | 169 | If you publish or distribute Opaque copies of the Document numbering 170 | more than 100, you must either include a machine-readable Transparent 171 | copy along with each Opaque copy, or state in or with each Opaque copy 172 | a computer-network location from which the general network-using 173 | public has access to download using public-standard network protocols 174 | a complete Transparent copy of the Document, free of added material. 175 | If you use the latter option, you must take reasonably prudent steps, 176 | when you begin distribution of Opaque copies in quantity, to ensure 177 | that this Transparent copy will remain thus accessible at the stated 178 | location until at least one year after the last time you distribute an 179 | Opaque copy (directly or through your agents or retailers) of that 180 | edition to the public. 181 | 182 | It is requested, but not required, that you contact the authors of the 183 | Document well before redistributing any large number of copies, to give 184 | them a chance to provide you with an updated version of the Document. 185 | 186 | @item 187 | MODIFICATIONS 188 | 189 | You may copy and distribute a Modified Version of the Document under 190 | the conditions of sections 2 and 3 above, provided that you release 191 | the Modified Version under precisely this License, with the Modified 192 | Version filling the role of the Document, thus licensing distribution 193 | and modification of the Modified Version to whoever possesses a copy 194 | of it. In addition, you must do these things in the Modified Version: 195 | 196 | @enumerate A 197 | @item 198 | Use in the Title Page (and on the covers, if any) a title distinct 199 | from that of the Document, and from those of previous versions 200 | (which should, if there were any, be listed in the History section 201 | of the Document). You may use the same title as a previous version 202 | if the original publisher of that version gives permission. 203 | 204 | @item 205 | List on the Title Page, as authors, one or more persons or entities 206 | responsible for authorship of the modifications in the Modified 207 | Version, together with at least five of the principal authors of the 208 | Document (all of its principal authors, if it has fewer than five), 209 | unless they release you from this requirement. 210 | 211 | @item 212 | State on the Title page the name of the publisher of the 213 | Modified Version, as the publisher. 214 | 215 | @item 216 | Preserve all the copyright notices of the Document. 217 | 218 | @item 219 | Add an appropriate copyright notice for your modifications 220 | adjacent to the other copyright notices. 221 | 222 | @item 223 | Include, immediately after the copyright notices, a license notice 224 | giving the public permission to use the Modified Version under the 225 | terms of this License, in the form shown in the Addendum below. 226 | 227 | @item 228 | Preserve in that license notice the full lists of Invariant Sections 229 | and required Cover Texts given in the Document's license notice. 230 | 231 | @item 232 | Include an unaltered copy of this License. 233 | 234 | @item 235 | Preserve the section Entitled ``History'', Preserve its Title, and add 236 | to it an item stating at least the title, year, new authors, and 237 | publisher of the Modified Version as given on the Title Page. If 238 | there is no section Entitled ``History'' in the Document, create one 239 | stating the title, year, authors, and publisher of the Document as 240 | given on its Title Page, then add an item describing the Modified 241 | Version as stated in the previous sentence. 242 | 243 | @item 244 | Preserve the network location, if any, given in the Document for 245 | public access to a Transparent copy of the Document, and likewise 246 | the network locations given in the Document for previous versions 247 | it was based on. These may be placed in the ``History'' section. 248 | You may omit a network location for a work that was published at 249 | least four years before the Document itself, or if the original 250 | publisher of the version it refers to gives permission. 251 | 252 | @item 253 | For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve 254 | the Title of the section, and preserve in the section all the 255 | substance and tone of each of the contributor acknowledgements and/or 256 | dedications given therein. 257 | 258 | @item 259 | Preserve all the Invariant Sections of the Document, 260 | unaltered in their text and in their titles. Section numbers 261 | or the equivalent are not considered part of the section titles. 262 | 263 | @item 264 | Delete any section Entitled ``Endorsements''. Such a section 265 | may not be included in the Modified Version. 266 | 267 | @item 268 | Do not retitle any existing section to be Entitled ``Endorsements'' or 269 | to conflict in title with any Invariant Section. 270 | 271 | @item 272 | Preserve any Warranty Disclaimers. 273 | @end enumerate 274 | 275 | If the Modified Version includes new front-matter sections or 276 | appendices that qualify as Secondary Sections and contain no material 277 | copied from the Document, you may at your option designate some or all 278 | of these sections as invariant. To do this, add their titles to the 279 | list of Invariant Sections in the Modified Version's license notice. 280 | These titles must be distinct from any other section titles. 281 | 282 | You may add a section Entitled ``Endorsements'', provided it contains 283 | nothing but endorsements of your Modified Version by various 284 | parties---for example, statements of peer review or that the text has 285 | been approved by an organization as the authoritative definition of a 286 | standard. 287 | 288 | You may add a passage of up to five words as a Front-Cover Text, and a 289 | passage of up to 25 words as a Back-Cover Text, to the end of the list 290 | of Cover Texts in the Modified Version. Only one passage of 291 | Front-Cover Text and one of Back-Cover Text may be added by (or 292 | through arrangements made by) any one entity. If the Document already 293 | includes a cover text for the same cover, previously added by you or 294 | by arrangement made by the same entity you are acting on behalf of, 295 | you may not add another; but you may replace the old one, on explicit 296 | permission from the previous publisher that added the old one. 297 | 298 | The author(s) and publisher(s) of the Document do not by this License 299 | give permission to use their names for publicity for or to assert or 300 | imply endorsement of any Modified Version. 301 | 302 | @item 303 | COMBINING DOCUMENTS 304 | 305 | You may combine the Document with other documents released under this 306 | License, under the terms defined in section 4 above for modified 307 | versions, provided that you include in the combination all of the 308 | Invariant Sections of all of the original documents, unmodified, and 309 | list them all as Invariant Sections of your combined work in its 310 | license notice, and that you preserve all their Warranty Disclaimers. 311 | 312 | The combined work need only contain one copy of this License, and 313 | multiple identical Invariant Sections may be replaced with a single 314 | copy. If there are multiple Invariant Sections with the same name but 315 | different contents, make the title of each such section unique by 316 | adding at the end of it, in parentheses, the name of the original 317 | author or publisher of that section if known, or else a unique number. 318 | Make the same adjustment to the section titles in the list of 319 | Invariant Sections in the license notice of the combined work. 320 | 321 | In the combination, you must combine any sections Entitled ``History'' 322 | in the various original documents, forming one section Entitled 323 | ``History''; likewise combine any sections Entitled ``Acknowledgements'', 324 | and any sections Entitled ``Dedications''. You must delete all 325 | sections Entitled ``Endorsements.'' 326 | 327 | @item 328 | COLLECTIONS OF DOCUMENTS 329 | 330 | You may make a collection consisting of the Document and other documents 331 | released under this License, and replace the individual copies of this 332 | License in the various documents with a single copy that is included in 333 | the collection, provided that you follow the rules of this License for 334 | verbatim copying of each of the documents in all other respects. 335 | 336 | You may extract a single document from such a collection, and distribute 337 | it individually under this License, provided you insert a copy of this 338 | License into the extracted document, and follow this License in all 339 | other respects regarding verbatim copying of that document. 340 | 341 | @item 342 | AGGREGATION WITH INDEPENDENT WORKS 343 | 344 | A compilation of the Document or its derivatives with other separate 345 | and independent documents or works, in or on a volume of a storage or 346 | distribution medium, is called an ``aggregate'' if the copyright 347 | resulting from the compilation is not used to limit the legal rights 348 | of the compilation's users beyond what the individual works permit. 349 | When the Document is included in an aggregate, this License does not 350 | apply to the other works in the aggregate which are not themselves 351 | derivative works of the Document. 352 | 353 | If the Cover Text requirement of section 3 is applicable to these 354 | copies of the Document, then if the Document is less than one half of 355 | the entire aggregate, the Document's Cover Texts may be placed on 356 | covers that bracket the Document within the aggregate, or the 357 | electronic equivalent of covers if the Document is in electronic form. 358 | Otherwise they must appear on printed covers that bracket the whole 359 | aggregate. 360 | 361 | @item 362 | TRANSLATION 363 | 364 | Translation is considered a kind of modification, so you may 365 | distribute translations of the Document under the terms of section 4. 366 | Replacing Invariant Sections with translations requires special 367 | permission from their copyright holders, but you may include 368 | translations of some or all Invariant Sections in addition to the 369 | original versions of these Invariant Sections. You may include a 370 | translation of this License, and all the license notices in the 371 | Document, and any Warranty Disclaimers, provided that you also include 372 | the original English version of this License and the original versions 373 | of those notices and disclaimers. In case of a disagreement between 374 | the translation and the original version of this License or a notice 375 | or disclaimer, the original version will prevail. 376 | 377 | If a section in the Document is Entitled ``Acknowledgements'', 378 | ``Dedications'', or ``History'', the requirement (section 4) to Preserve 379 | its Title (section 1) will typically require changing the actual 380 | title. 381 | 382 | @item 383 | TERMINATION 384 | 385 | You may not copy, modify, sublicense, or distribute the Document 386 | except as expressly provided under this License. Any attempt 387 | otherwise to copy, modify, sublicense, or distribute it is void, and 388 | will automatically terminate your rights under this License. 389 | 390 | However, if you cease all violation of this License, then your license 391 | from a particular copyright holder is reinstated (a) provisionally, 392 | unless and until the copyright holder explicitly and finally 393 | terminates your license, and (b) permanently, if the copyright holder 394 | fails to notify you of the violation by some reasonable means prior to 395 | 60 days after the cessation. 396 | 397 | Moreover, your license from a particular copyright holder is 398 | reinstated permanently if the copyright holder notifies you of the 399 | violation by some reasonable means, this is the first time you have 400 | received notice of violation of this License (for any work) from that 401 | copyright holder, and you cure the violation prior to 30 days after 402 | your receipt of the notice. 403 | 404 | Termination of your rights under this section does not terminate the 405 | licenses of parties who have received copies or rights from you under 406 | this License. If your rights have been terminated and not permanently 407 | reinstated, receipt of a copy of some or all of the same material does 408 | not give you any rights to use it. 409 | 410 | @item 411 | FUTURE REVISIONS OF THIS LICENSE 412 | 413 | The Free Software Foundation may publish new, revised versions 414 | of the GNU Free Documentation License from time to time. Such new 415 | versions will be similar in spirit to the present version, but may 416 | differ in detail to address new problems or concerns. See 417 | @uref{https://www.gnu.org/licenses/}. 418 | 419 | Each version of the License is given a distinguishing version number. 420 | If the Document specifies that a particular numbered version of this 421 | License ``or any later version'' applies to it, you have the option of 422 | following the terms and conditions either of that specified version or 423 | of any later version that has been published (not as a draft) by the 424 | Free Software Foundation. If the Document does not specify a version 425 | number of this License, you may choose any version ever published (not 426 | as a draft) by the Free Software Foundation. If the Document 427 | specifies that a proxy can decide which future versions of this 428 | License can be used, that proxy's public statement of acceptance of a 429 | version permanently authorizes you to choose that version for the 430 | Document. 431 | 432 | @item 433 | RELICENSING 434 | 435 | ``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any 436 | World Wide Web server that publishes copyrightable works and also 437 | provides prominent facilities for anybody to edit those works. A 438 | public wiki that anybody can edit is an example of such a server. A 439 | ``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the 440 | site means any set of copyrightable works thus published on the MMC 441 | site. 442 | 443 | ``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 444 | license published by Creative Commons Corporation, a not-for-profit 445 | corporation with a principal place of business in San Francisco, 446 | California, as well as future copyleft versions of that license 447 | published by that same organization. 448 | 449 | ``Incorporate'' means to publish or republish a Document, in whole or 450 | in part, as part of another Document. 451 | 452 | An MMC is ``eligible for relicensing'' if it is licensed under this 453 | License, and if all works that were first published under this License 454 | somewhere other than this MMC, and subsequently incorporated in whole 455 | or in part into the MMC, (1) had no cover texts or invariant sections, 456 | and (2) were thus incorporated prior to November 1, 2008. 457 | 458 | The operator of an MMC Site may republish an MMC contained in the site 459 | under CC-BY-SA on the same site at any time before August 1, 2009, 460 | provided the MMC is eligible for relicensing. 461 | 462 | @end enumerate 463 | 464 | @page 465 | @heading ADDENDUM: How to use this License for your documents 466 | 467 | To use this License in a document you have written, include a copy of 468 | the License in the document and put the following copyright and 469 | license notices just after the title page: 470 | 471 | @smallexample 472 | @group 473 | Copyright (C) @var{year} @var{your name}. 474 | Permission is granted to copy, distribute and/or modify this document 475 | under the terms of the GNU Free Documentation License, Version 1.3 476 | or any later version published by the Free Software Foundation; 477 | with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 478 | Texts. A copy of the license is included in the section entitled ``GNU 479 | Free Documentation License''. 480 | @end group 481 | @end smallexample 482 | 483 | If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, 484 | replace the ``with@dots{}Texts.''@: line with this: 485 | 486 | @smallexample 487 | @group 488 | with the Invariant Sections being @var{list their titles}, with 489 | the Front-Cover Texts being @var{list}, and with the Back-Cover Texts 490 | being @var{list}. 491 | @end group 492 | @end smallexample 493 | 494 | If you have Invariant Sections without Cover Texts, or some other 495 | combination of the three, merge those two alternatives to suit the 496 | situation. 497 | 498 | If your document contains nontrivial examples of program code, we 499 | recommend releasing these examples in parallel under your choice of 500 | free software license, such as the GNU General Public License, 501 | to permit their use in free software. 502 | 503 | @c Local Variables: 504 | @c ispell-local-pdict: "ispell-dict" 505 | @c End: 506 | -------------------------------------------------------------------------------- /tmr-tabulated.el: -------------------------------------------------------------------------------- 1 | ;;; tmr-tabulated.el --- Display TMR timers in a tabulated list -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2020-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Protesilaos Stavrou , 6 | ;; Damien Cassou , 7 | ;; Daniel Mendler 8 | ;; Maintainer: Protesilaos Stavrou 9 | ;; URL: https://github.com/protesilaos/tmr 10 | 11 | ;; This file is NOT part of GNU Emacs. 12 | 13 | ;; This program is free software; you can redistribute it and/or modify 14 | ;; it under the terms of the GNU General Public License as published by 15 | ;; the Free Software Foundation, either version 3 of the License, or 16 | ;; (at your option) any later version. 17 | ;; 18 | ;; This program is distributed in the hope that it will be useful, 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | ;; GNU General Public License for more details. 22 | ;; 23 | ;; You should have received a copy of the GNU General Public License 24 | ;; along with this program. If not, see . 25 | 26 | ;;; Commentary: 27 | ;; 28 | ;; Call `M-x tmr-tabulated-view' to display all tmr timers in a grid, 29 | ;; one by line with sortable columns. Columns show the creation date, 30 | ;; the end date, a check mark if the timer is finished and the timer's 31 | ;; optional description. 32 | ;; 33 | ;; Please read the manual for all the technicalities. Either evaluate 34 | ;; (info "(tmr) Top") or visit . 35 | 36 | ;;; Code: 37 | 38 | (require 'tmr) 39 | 40 | ;; NOTE 2024-10-30: We keep this file to avoid breaking user 41 | ;; configurations, but we will remove it eventually. 42 | (display-warning 43 | 'tmr 44 | "`tmr-tabulated.el' is merged into `tmr.el'; only use `tmr.el'" 45 | :warning) 46 | 47 | (provide 'tmr-tabulated) 48 | ;;; tmr-tabulated.el ends here 49 | -------------------------------------------------------------------------------- /tmr.el: -------------------------------------------------------------------------------- 1 | ;;; tmr.el --- Set timers using a convenient notation -*- lexical-binding: t -*- 2 | 3 | ;; Copyright (C) 2020-2025 Free Software Foundation, Inc. 4 | 5 | ;; Author: Protesilaos Stavrou , 6 | ;; Damien Cassou , 7 | ;; Daniel Mendler 8 | ;; Steven Allen 9 | ;; Maintainer: Protesilaos Stavrou 10 | ;; URL: https://github.com/protesilaos/tmr 11 | ;; Version: 1.1.0 12 | ;; Package-Requires: ((emacs "29.1")) 13 | ;; Keywords: convenience, timer 14 | 15 | ;; This file is NOT part of GNU Emacs. 16 | 17 | ;; This program is free software; you can redistribute it and/or modify 18 | ;; it under the terms of the GNU General Public License as published by 19 | ;; the Free Software Foundation, either version 3 of the License, or 20 | ;; (at your option) any later version. 21 | ;; 22 | ;; This program is distributed in the hope that it will be useful, 23 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | ;; GNU General Public License for more details. 26 | ;; 27 | ;; You should have received a copy of the GNU General Public License 28 | ;; along with this program. If not, see . 29 | 30 | ;;; Commentary: 31 | ;; 32 | ;; TMR is an Emacs package that provides facilities for setting timers 33 | ;; using a convenient notation. 34 | ;; 35 | ;; Please read the manual for all the technicalities. Either evaluate 36 | ;; (info "(tmr) Top") or visit . 37 | 38 | ;;; Code: 39 | 40 | (require 'seq) 41 | (require 'format-spec) 42 | (eval-when-compile 43 | (require 'cl-lib) 44 | (require 'subr-x)) 45 | 46 | (defgroup tmr () 47 | "TMR May Ring: set timers using a simple notation." 48 | :link '(info-link :tag "Info Manual" "(tmr)") 49 | :link '(url-link :tag "Homepage" "https://protesilaos.com/emacs/tmr") 50 | :link '(emacs-library-link :tag "Library Source" "tmr.el") 51 | :group 'data) 52 | 53 | ;;;; User options 54 | 55 | (defcustom tmr-description-list 'tmr-description-history 56 | "List of timer description presets. 57 | The value can be either a list of strings or the symbol of a 58 | variable that holds a list of strings. 59 | 60 | The default value of `tmr-description-history', is the name of a 61 | variable that contains input provided by the user at the relevant 62 | prompt of the `tmr' and `tmr-with-details' commands." 63 | :type '(choice symbol (repeat string))) 64 | 65 | (defcustom tmr-notification-urgency 'normal 66 | "The urgency level of the desktop notification. 67 | Values can be `low', `normal' (default), or `critical'. 68 | 69 | The desktop environment or notification daemon is responsible for 70 | such notifications." 71 | :type '(choice 72 | (const :tag "Low" low) 73 | (const :tag "Normal" normal) 74 | (const :tag "Critical" critical))) 75 | 76 | (defcustom tmr-sound-file 77 | "/usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga" 78 | "Path to sound file used by `tmr-sound-play'. 79 | If nil, don't play any sound." 80 | :type '(choice 81 | file 82 | (const :tag "Off" nil))) 83 | 84 | (defcustom tmr-confirm-single-timer t 85 | "Whether to act on the sole timer outright or with confirmation. 86 | 87 | If non-nil (the default), TMR will use the minibuffer to select a 88 | timer object to operate on, even when there is only one candidate 89 | available. 90 | 91 | If set to nil, TMR will not ask for confirmation when there is 92 | one timer available: the operatation will be carried out 93 | outright." 94 | :type 'boolean) 95 | 96 | (defcustom tmr-timer-created-functions 97 | (list #'tmr-print-message-for-created-timer) 98 | "Functions to execute when a timer is created. 99 | Each function must accept a timer as argument." 100 | :type 'hook 101 | :options '(tmr-print-message-for-created-timer)) 102 | 103 | (defcustom tmr-timer-finished-functions 104 | (list #'tmr-sound-play 105 | #'tmr-notification-notify 106 | #'tmr-print-message-for-finished-timer 107 | #'tmr-acknowledge-minibuffer) 108 | "Functions to execute when a timer is finished. 109 | Each function must accept a timer as argument." 110 | :type 'hook 111 | :options (list #'tmr-sound-play 112 | #'tmr-notification-notify 113 | #'tmr-print-message-for-finished-timer 114 | #'tmr-acknowledge-minibuffer 115 | #'tmr-acknowledge-dialog)) 116 | 117 | (defcustom tmr-timer-cancelled-functions 118 | (list #'tmr-print-message-for-cancelled-timer) 119 | "Functions to execute when a timer is created. 120 | Each function must accept a timer as argument." 121 | :type 'hook) 122 | 123 | (defcustom tmr-finished-indicator "✔" 124 | "Indicator for a finished timer, shown in `tmr-tabulated-view'." 125 | :package-version '(tmr . "1.0.0") 126 | :type 'string) 127 | 128 | (defun tmr-select-and-resize (window) 129 | "Select WINDOW and fit it to its buffer." 130 | (select-window window) 131 | (fit-window-to-buffer window)) 132 | 133 | (defcustom tmr-list-timers-action-alist 134 | '((display-buffer-reuse-mode-window display-buffer-at-bottom) 135 | (mode . tmr-tabulated-mode) 136 | (dedicated . t) 137 | (preserve-size . (t . t)) 138 | (body-function . tmr-select-and-resize)) 139 | "Action alist used by `tmr-tabulated-view' in interactive use. 140 | This is the same data that is passed to `display-buffer-alist'. 141 | Read Info node `(elisp) Displaying Buffers'. As such, it is 142 | meant for experienced users." 143 | :risky t 144 | :type `(alist 145 | :key-type (choice :tag "Condition" regexp 146 | (function :tag "Matcher function")) 147 | :value-type ,display-buffer--action-custom-type) 148 | :package-version '(tmr . "1.1.0")) 149 | 150 | (defcustom tmr-mode-line-format "%r%d" 151 | "Format string for displaying a timer in the mode-line. 152 | Available format specifiers: 153 | - %r: Remaining time. 154 | - %d: Timer description (truncated to `tmr-mode-line-max-desc-length')." 155 | :type 'string 156 | :package-version '(tmr . "1.2.0") 157 | :group 'tmr) 158 | 159 | (defcustom tmr-mode-line-separator " | " 160 | "String used to separate multiple timers in the mode-line." 161 | :type 'string 162 | :package-version '(tmr . "1.2.0") 163 | :group 'tmr) 164 | 165 | (defcustom tmr-mode-line-max-timers 3 166 | "Maximum number of timers to display in the mode-line. 167 | Set to nil to show all timers." 168 | :type '(choice (const :tag "Show all" nil) 169 | (integer :tag "Maximum number")) 170 | :package-version '(tmr . "1.2.0") 171 | :group 'tmr) 172 | 173 | (defcustom tmr-mode-line-max-desc-length 15 174 | "Maximum length for timer descriptions in the mode-line. 175 | Longer descriptions will be truncated." 176 | :type '(choice (const :tag "Don't truncate" nil) 177 | (integer :tag "Truncate")) 178 | :package-version '(tmr . "1.2.0") 179 | :group 'tmr) 180 | 181 | (defcustom tmr-mode-line-prefix 182 | (cond 183 | ((char-displayable-p ?⏰) "⏰") 184 | ((char-displayable-p ?∞) "∞") 185 | (t "!")) 186 | "Prefix string displayed before the timer list." 187 | :type 'string 188 | :package-version '(tmr . "1.2.0") 189 | :group 'tmr) 190 | 191 | ;;;; Faces 192 | 193 | (defgroup tmr-faces () 194 | "Faces for `tmr'." 195 | :link '(info-link :tag "Info Manual" "(tmr)") 196 | :link '(url-link :tag "Homepage" "https://protesilaos.com/emacs/tmr") 197 | :link '(emacs-library-link :tag "Library Source" "tmr.el") 198 | :group 'tmr) 199 | 200 | (defface tmr-duration nil 201 | "Face for styling the duration of a timer." 202 | :package-version '(tmr . "1.0.0") 203 | :group 'tmr-faces) 204 | 205 | (defface tmr-description '((t :inherit bold)) 206 | "Face for styling the description of a timer." 207 | :package-version '(tmr . "1.0.0") 208 | :group 'tmr-faces) 209 | 210 | (defface tmr-start-time '((t :inherit success)) 211 | "Face for styling the start time of a timer." 212 | :package-version '(tmr . "1.0.0") 213 | :group 'tmr-faces) 214 | 215 | (defface tmr-end-time '((t :inherit error)) 216 | "Face for styling the start time of a timer." 217 | :package-version '(tmr . "1.0.0") 218 | :group 'tmr-faces) 219 | 220 | (defface tmr-is-acknowledged '((t :inherit success)) 221 | "Face for styling the acknowledgment confirmation." 222 | :package-version '(tmr . "1.0.0") 223 | :group 'tmr-faces) 224 | 225 | (defface tmr-must-be-acknowledged '((t :inherit warning)) 226 | "Face for styling the acknowledgment confirmation." 227 | :package-version '(tmr . "1.0.0") 228 | :group 'tmr-faces) 229 | 230 | (defface tmr-finished '((t :inherit error)) 231 | "Face for styling the confirmation of a finished timer." 232 | :package-version '(tmr . "1.0.0") 233 | :group 'tmr-faces) 234 | 235 | (defface tmr-tabulated-start-time 236 | '((((class color) (min-colors 88) (background light)) 237 | :foreground "#004476") 238 | (((class color) (min-colors 88) (background dark)) 239 | :foreground "#c0d0ef") 240 | (t :foreground "cyan")) 241 | "Start time in the `tmr-tabulated-view'." 242 | :package-version '(tmr . "1.1.0") 243 | :group 'tmr-faces) 244 | 245 | (defface tmr-tabulated-end-time 246 | '((((class color) (min-colors 88) (background light)) 247 | :foreground "#800040") 248 | (((class color) (min-colors 88) (background dark)) 249 | :foreground "#e59fc6") 250 | (t :foreground "magenta")) 251 | "End time in the `tmr-tabulated-view'." 252 | :package-version '(tmr . "1.1.0") 253 | :group 'tmr-faces) 254 | 255 | (defface tmr-tabulated-remaining-time 256 | '((((class color) (min-colors 88) (background light)) 257 | :foreground "#603f00") 258 | (((class color) (min-colors 88) (background dark)) 259 | :foreground "#deba66") 260 | (t :foreground "yellow")) 261 | "Remaining time in the `tmr-tabulated-view'." 262 | :package-version '(tmr . "1.1.0") 263 | :group 'tmr-faces) 264 | 265 | (defface tmr-tabulated-acknowledgement 266 | '((t :inherit bold)) 267 | "Acknowledgement indicator in the `tmr-tabulated-view'." 268 | :package-version '(tmr . "1.1.0") 269 | :group 'tmr-faces) 270 | 271 | (defface tmr-tabulated-description 272 | '((t :inherit font-lock-doc-face)) 273 | "Description of timer in the `tmr-tabulated-view'." 274 | :package-version '(tmr . "1.1.0") 275 | :group 'tmr-faces) 276 | 277 | (defface tmr-mode-line-active 278 | '((t :inherit mode-line-emphasis)) 279 | "Face for active timers in the mode-line." 280 | :package-version '(tmr . "1.2.0") 281 | :group 'tmr-faces) 282 | 283 | (defface tmr-mode-line-soon 284 | '((t :inherit warning)) 285 | "Face for timers that will expire in the next 2 minutes." 286 | :package-version '(tmr . "1.2.0") 287 | :group 'tmr-faces) 288 | 289 | (defface tmr-mode-line-urgent 290 | '((t :inherit error)) 291 | "Face for timers that will expire in the next 30 seconds." 292 | :package-version '(tmr . "1.2.0") 293 | :group 'tmr-faces) 294 | 295 | ;;;; Common helpers 296 | 297 | (cl-defstruct (tmr--timer 298 | (:constructor tmr--timer-create) 299 | (:copier tmr--timer-copy)) 300 | (creation-date 301 | nil 302 | :read-only t 303 | :documentation "Time at which the timer was created.") 304 | (end-date 305 | nil 306 | :read-only t 307 | :documentation "Time at which the timer finishes.") 308 | (finishedp 309 | nil 310 | :read-only nil 311 | :documentation "Non-nil if the timer is finished.") 312 | (acknowledgep 313 | nil 314 | :read-only nil 315 | :documentation "Non-nil if the timer must be acknowledged.") 316 | (timer-object 317 | nil 318 | :read-only nil 319 | :documentation "The object returned by `run-with-timer'.") 320 | (input 321 | nil 322 | :read-only t 323 | :documentation "The original input which is internally interpreted as a duration.") 324 | (description 325 | nil 326 | :read-only nil 327 | :documentation "Optional string describing the purpose of the timer, e.g., \"Stop the oven\".")) 328 | 329 | (defun tmr--long-description (timer) 330 | "Return a human-readable description for TIMER." 331 | (let ((start (tmr--format-creation-date timer)) 332 | (end (tmr--format-end-date timer)) 333 | (description (tmr--timer-description timer))) 334 | ;; We prefix it with TMR just so it is easier to find in 335 | ;; `view-echo-area-messages'. The concise wording makes it flexible 336 | ;; enough to be used when starting a timer but also when cancelling 337 | ;; one: check `tmr-print-message-for-created-timer' and 338 | ;; `tmr-print-message-for-cancelled-timer'. 339 | (format "TMR start %s; end %s; %s %s%s%s" 340 | (propertize start 'face 'tmr-start-time) 341 | (propertize end 'face 'tmr-end-time) 342 | (if (string-search ":" (tmr--timer-input timer)) 343 | "until" 344 | "duration") 345 | (propertize (tmr--timer-input timer) 'face 'tmr-duration) 346 | (cond 347 | ((and (tmr--timer-acknowledgep timer) 348 | (tmr--timer-finishedp timer)) 349 | (concat "; " (propertize "acknowledged" 'face 'tmr-is-acknowledged))) 350 | ((tmr--timer-acknowledgep timer) 351 | (concat "; " (propertize "acknowledge" 'face 'tmr-must-be-acknowledged))) 352 | ((tmr--timer-finishedp timer) 353 | (concat "; " (propertize "finished" 'face 'tmr-finished))) 354 | (t "")) 355 | (if description 356 | (concat "; " (propertize description 'face 'tmr-description)) 357 | "")))) 358 | 359 | (defun tmr--long-description-for-finished-timer (timer) 360 | "Return a human-readable description of finished TIMER. 361 | This includes the creation and completion dates as well as the 362 | optional `tmr--timer-description'." 363 | (let ((start (tmr--format-creation-date timer)) 364 | (end (tmr--format-end-date timer)) 365 | (description (tmr--timer-description timer))) 366 | ;; For the TMR prefix, see comment in `tmr--long-description'. 367 | (format "TMR Time is up!\n%s%s %s\n%s %s" 368 | (if description (concat (propertize description 'face 'tmr-description) "\n") "") 369 | (propertize "Started" 'face 'tmr-start-time) 370 | start 371 | (propertize "Ended" 'face 'tmr-end-time) 372 | end))) 373 | 374 | (defun tmr--format-creation-date (timer) 375 | "Return a string representing when TIMER was created." 376 | (tmr--format-time (tmr--timer-creation-date timer))) 377 | 378 | (defun tmr--format-end-date (timer) 379 | "Return a string representing when TIMER should finish." 380 | (tmr--format-time (tmr--timer-end-date timer))) 381 | 382 | (defun tmr--format-remaining (timer) 383 | "Format remaining time of TIMER." 384 | (if (tmr--timer-finishedp timer) 385 | tmr-finished-indicator 386 | (let* ((secs (round (- (float-time (tmr--timer-end-date timer)) 387 | (float-time)))) 388 | (str (if (> secs 3600) 389 | (format "%sh %sm" (/ secs 3600) (/ (% secs 3600) 60)) 390 | (if (> secs 60) 391 | (format "%sm %ss" (/ secs 60) (% secs 60)) 392 | (format "%ss" secs))))) 393 | (if (< secs 0) 394 | ;; Negative remaining time occurs for non-acknowledged timers with 395 | ;; additional duration. 396 | (propertize str 'face 'tmr-must-be-acknowledged) 397 | str)))) 398 | 399 | (defun tmr--format-time (time) 400 | "Return a human-readable string representing TIME." 401 | (format-time-string "%T" time)) 402 | 403 | (defun tmr--parse-duration (now time) 404 | "Parse TIME string given current time NOW." 405 | (save-match-data 406 | (cond 407 | ((string-match-p "\\`[0-9]+\\(?:\\.[0-9]+\\)?\\'" time) 408 | (* (string-to-number time) 60)) 409 | ((string-match "\\`\\([0-9]+\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?\\'" time) 410 | (let ((val (decode-time now))) 411 | (setf (decoded-time-hour val) (string-to-number (match-string 1 time)) 412 | (decoded-time-minute val) (string-to-number (match-string 2 time)) 413 | (decoded-time-second val) (if (match-end 3) 414 | (string-to-number (match-string 3 time)) 415 | 0) 416 | val (encode-time val)) 417 | (when (time-less-p val now) 418 | (user-error "Time %s is already over" time)) 419 | (ceiling (float-time (time-subtract val now))))) 420 | ((string-match "\\`\\([0-9]+\\(?:\\.[0-9]+\\)?\\)[mhs]\\'" time) 421 | (let ((num (string-to-number (match-string 1 time)))) 422 | (pcase (aref time (1- (length time))) 423 | (?s num) 424 | (?h (* num 60 60)) 425 | (?m (* num 60))))) 426 | (t (user-error "TMR Made Ridiculous; append character for [m]inutes, [h]ours, [s]econds"))))) 427 | 428 | (defvar tmr--timers nil 429 | "List of timer objects. 430 | Populated by `tmr' and then operated on by `tmr-cancel'.") 431 | 432 | (defvar tmr--update-hook nil 433 | "Hooks to execute when timers are changed.") 434 | 435 | ;;;; Commands 436 | 437 | (defun tmr-remove (timer) 438 | "Cancel and remove TIMER object set with `tmr' command. 439 | Interactively, let the user choose which timer to cancel with 440 | completion." 441 | (interactive (list (tmr--read-timer "Remove timer: "))) 442 | (cancel-timer (tmr--timer-timer-object timer)) 443 | (setq tmr--timers (delete timer tmr--timers)) 444 | (run-hooks 'tmr--update-hook) 445 | (run-hook-with-args 'tmr-timer-cancelled-functions timer)) 446 | 447 | (defun tmr-cancel (timer) 448 | "Cancel TIMER object set with `tmr' command. 449 | Interactively, let the user choose which timer to cancel with 450 | completion. This command is the same as `tmr-remove' but 451 | chooses only among active timers." 452 | (interactive (list (tmr--read-timer "Cancel timer: " :active))) 453 | (tmr-remove timer)) 454 | 455 | (defun tmr-reschedule (timer) 456 | "Reschedule TIMER. 457 | This is the same as cloning it, prompting for duration and 458 | cancelling the original one." 459 | (interactive (list (tmr--read-timer "Reschedule timer: "))) 460 | (tmr-clone timer :prompt) 461 | (let (tmr-timer-cancelled-functions) 462 | (tmr-cancel timer))) 463 | 464 | (defun tmr-edit-description (timer description) 465 | "Change TIMER description with that of DESCRIPTION." 466 | (interactive 467 | (list 468 | (tmr--read-timer "Edit description of timer: ") 469 | (tmr--description-prompt))) 470 | (setf (tmr--timer-description timer) description) 471 | (run-hooks 'tmr--update-hook)) 472 | 473 | (defun tmr-toggle-acknowledge (timer) 474 | "Toggle ackowledge flag of TIMER." 475 | (interactive 476 | (list 477 | (tmr--read-timer "Toggle acknowledge flag of timer: "))) 478 | (setf (tmr--timer-acknowledgep timer) (not (tmr--timer-acknowledgep timer))) 479 | (run-hooks 'tmr--update-hook)) 480 | 481 | (defun tmr-remove-finished () 482 | "Remove all finished timers." 483 | (interactive) 484 | (setq tmr--timers (seq-remove #'tmr--timer-finishedp tmr--timers)) 485 | (run-hooks 'tmr--update-hook)) 486 | 487 | (defvar tmr--read-timer-hook nil 488 | "Hooks to execute to find current timer.") 489 | 490 | (defun tmr--timer-annotation (timer) 491 | "Annotate TIMER completion candidate with remaining time." 492 | (setq timer (get-text-property 0 'tmr-timer timer)) 493 | (if (tmr--timer-finishedp timer) 494 | " (finished)" 495 | (format " (%s remaining)" (tmr--format-remaining timer)))) 496 | 497 | (defun tmr--read-timer (prompt &optional active) 498 | "Let the user choose a timer among all (or ACTIVE) timers. 499 | 500 | Return the selected timer. If there is a single timer and 501 | `tmr-confirm-single-timer' is nil, use that. If there are 502 | multiple timers, prompt for one with completion with PROMPT text. 503 | If there are no timers, throw an error." 504 | (or 505 | (run-hook-with-args-until-success 'tmr--read-timer-hook) 506 | (pcase 507 | (if active 508 | (seq-remove #'tmr--timer-finishedp tmr--timers) 509 | tmr--timers) 510 | ('nil (user-error "No timers available")) 511 | ((and `(,timer) (guard (not tmr-confirm-single-timer))) timer) 512 | (timers 513 | (let* ((timer-list (mapcar 514 | (lambda (x) 515 | (propertize 516 | (tmr--long-description x) 517 | 'tmr-timer x)) 518 | timers)) 519 | (selected 520 | (car (member (completing-read 521 | prompt 522 | (tmr--completion-table 523 | timer-list 'tmr-timer #'tmr--timer-annotation) 524 | nil t) 525 | timer-list)))) 526 | (or (and selected (get-text-property 0 'tmr-timer selected)) 527 | (user-error "No timer selected"))))))) 528 | 529 | (declare-function notifications-notify "notifications" (&rest params)) 530 | 531 | (defun tmr-notification-notify (timer) 532 | "Dispatch a notification for TIMER. 533 | 534 | Read: (info \"(elisp) Desktop Notifications\") for details." 535 | (if (featurep 'dbusbind) 536 | (let ((title "TMR May Ring (Emacs tmr package)") 537 | (body (tmr--long-description-for-finished-timer timer))) 538 | (unless (fboundp 'notifications-notify) 539 | (require 'notifications)) 540 | (notifications-notify 541 | :title title 542 | :body body 543 | :app-name "GNU Emacs" 544 | :app-icon 'emacs 545 | :urgency tmr-notification-urgency 546 | :sound-file tmr-sound-file)) 547 | (warn "Emacs has no DBUS support, TMR notifications unavailable"))) 548 | 549 | ;; NOTE 2022-04-21: Emacs has a `play-sound' function but it only 550 | ;; supports .wav and .au formats. Also, it does not work on all 551 | ;; platforms and Emacs needs to be compiled --with-sound capabilities. 552 | (defun tmr-sound-play (&optional _timer) 553 | "Play `tmr-sound-file' using the ffplay executable (ffmpeg). 554 | TIMER is unused." 555 | (when-let* ((sound tmr-sound-file) 556 | ((file-exists-p sound))) 557 | (unless (executable-find "ffplay") 558 | (user-error "Cannot play %s without `ffplay'" sound)) 559 | (call-process-shell-command 560 | (format "ffplay -nodisp -autoexit %s >/dev/null 2>&1" sound) nil 0))) 561 | 562 | (defun tmr-print-message-for-created-timer (timer) 563 | "Show a `message' informing the user that TIMER was created." 564 | (message "%s" (tmr--long-description timer))) 565 | 566 | (defun tmr-print-message-for-finished-timer (timer) 567 | "Show a `message' informing the user that TIMER has finished." 568 | (message "%s" (tmr--long-description-for-finished-timer timer))) 569 | 570 | (defun tmr-print-message-for-cancelled-timer (timer) 571 | "Show a `message' informing the user that TIMER is cancelled." 572 | (message "Cancelled: <<%s>>" (tmr--long-description timer))) 573 | 574 | (defvar tmr-duration-history nil 575 | "Minibuffer history of `tmr' durations.") 576 | 577 | (defun tmr--read-duration (&optional default) 578 | "Ask the user to type a duration. 579 | If DEFAULT is provided, use that as a default." 580 | (let ((def (or default (nth 0 tmr-duration-history)))) 581 | (read-string 582 | (format-prompt 583 | "N minutes for timer (append `h' or `s' for other units)" def) 584 | nil 'tmr-duration-history def))) 585 | 586 | (defvar tmr-description-history nil 587 | "Minibuffer history of `tmr' descriptions.") 588 | 589 | (defun tmr--description-prompt (&optional default) 590 | "Helper prompt for descriptions in `tmr'. 591 | If optional DEFAULT is provided use it as a default candidate." 592 | (completing-read 593 | (format-prompt "Description for this tmr" default) 594 | (tmr--completion-table 595 | (if (listp tmr-description-list) 596 | tmr-description-list 597 | (symbol-value tmr-description-list))) 598 | nil nil nil 'tmr-description-history default)) 599 | 600 | (defun tmr--acknowledge-prompt () 601 | "Ask the user if a timer must be acknowledged." 602 | (y-or-n-p "Acknowledge timer after finish? ")) 603 | 604 | (defun tmr-acknowledge-dialog (timer) 605 | "Acknowledge TIMER by showing a GUI dialog." 606 | (when-let* (((tmr--timer-acknowledgep timer)) 607 | (duration 608 | (x-popup-dialog 609 | t 610 | `(,(tmr--long-description-for-finished-timer timer) 611 | ("Acknowledge" . nil) 612 | ("+ 1 m" . 60) 613 | ("+ 5 m" . 300) 614 | ("+ 10 min" . 600) 615 | ("+ 15 min" . 960) 616 | nil)))) 617 | (tmr--continue-overtime timer duration))) 618 | 619 | (defun tmr-acknowledge-minibuffer (timer) 620 | "Acknowledge TIMER using the minibuffer." 621 | (when (tmr--timer-acknowledgep timer) 622 | (while 623 | (let ((input 624 | (read-from-minibuffer 625 | (concat (tmr--long-description-for-finished-timer timer) 626 | "\nAcknowledge with `ack' or additional duration: ")))) 627 | (not (or (equal input "ack") 628 | (when-let* ((duration 629 | (ignore-errors 630 | (tmr--parse-duration (current-time) input)))) 631 | (tmr--continue-overtime timer duration) 632 | t))))))) 633 | 634 | (defun tmr--continue-overtime (timer duration) 635 | "Continue TIMER even after it expired for DURATION. 636 | This function is used if a timer is not acknowledged." 637 | (setf (tmr--timer-finishedp timer) nil 638 | (tmr--timer-timer-object timer) 639 | (run-with-timer duration nil #'tmr--complete timer)) 640 | (run-hooks 'tmr--update-hook) 641 | (run-hook-with-args 'tmr-timer-created-functions timer)) 642 | 643 | (defun tmr--complete (timer) 644 | "Mark TIMER as finished and execute `tmr-timer-finished-functions'." 645 | (setf (tmr--timer-finishedp timer) t) 646 | (run-hooks 'tmr--update-hook) 647 | (run-hook-with-args 'tmr-timer-finished-functions timer)) 648 | 649 | ;;;###autoload 650 | (defun tmr (time &optional description acknowledgep) 651 | "Set timer to TIME duration and notify after it elapses. 652 | 653 | When TIME is a number, it is interpreted as a count of minutes. 654 | Otherwise TIME must be a string that consists of a number and a 655 | special final character denoting a unit of time: h for hours, s 656 | for seconds. 657 | 658 | With optional DESCRIPTION as a prefix (\\[universal-argument]), 659 | prompt for a description among `tmr-description-list', though 660 | allow for any string to serve as valid input. 661 | 662 | With optional ACKNOWLEDGEP non-nil the timer must be acknowledged 663 | after it finished, such that the timer cannot be missed. 664 | 665 | This command also plays back `tmr-sound-file' if it is available. 666 | 667 | To cancel the timer, use the `tmr-cancel' command. 668 | 669 | To always prompt for a DESCRIPTION when setting a timer, use the 670 | command `tmr-with-details' instead of this one." 671 | (interactive 672 | (list 673 | (tmr--read-duration) 674 | (when current-prefix-arg (tmr--description-prompt)) 675 | (when current-prefix-arg (tmr--acknowledge-prompt)))) 676 | (when (natnump time) 677 | (setq time (number-to-string time))) 678 | (let* ((creation-date (current-time)) 679 | (duration (tmr--parse-duration creation-date time)) 680 | (timer (tmr--timer-create 681 | :description description 682 | :acknowledgep acknowledgep 683 | :creation-date creation-date 684 | :end-date (time-add creation-date duration) 685 | :input time))) 686 | (setf (tmr--timer-timer-object timer) 687 | (run-with-timer duration nil #'tmr--complete timer)) 688 | (push timer tmr--timers) 689 | (run-hooks 'tmr--update-hook) 690 | (run-hook-with-args 'tmr-timer-created-functions timer))) 691 | 692 | ;;;###autoload 693 | (defun tmr-with-details (time &optional description acknowledgep) 694 | "Set timer to TIME duration and notify after it elapses. 695 | 696 | See `tmr' for a description of the arguments DESCRIPTION and 697 | ACKNOWLEDGEP. The difference between the two commands is that 698 | `tmr-with-details' always asks for a description and if the timer 699 | should be acknowledged whereas `tmr' only asks for it when the 700 | user uses a prefix argument (\\[universal-argument])." 701 | (interactive 702 | (list 703 | (tmr--read-duration) 704 | (tmr--description-prompt) 705 | (tmr--acknowledge-prompt))) 706 | (tmr time description acknowledgep)) 707 | 708 | (defun tmr-clone (timer &optional prompt) 709 | "Create a new timer by cloning TIMER. 710 | With optional PROMPT, such as a prefix argument, ask for 711 | confirmation about the duration. When PROMPT is a double prefix 712 | argument, ask for a description as well and ask if the timer must 713 | be acknowledged. 714 | 715 | Without a PROMPT, clone TIMER outright." 716 | (interactive 717 | (list 718 | (tmr--read-timer "Clone timer: ") 719 | current-prefix-arg)) 720 | (tmr 721 | (if prompt 722 | (tmr--read-duration (format "%s" (tmr--timer-input timer))) 723 | (format "%s" (tmr--timer-input timer))) 724 | (if (equal prompt '(16)) 725 | (tmr--description-prompt (tmr--timer-description timer)) 726 | (tmr--timer-description timer)) 727 | (if (equal prompt '(16)) 728 | (tmr--acknowledge-prompt) 729 | (tmr--timer-acknowledgep timer)))) 730 | 731 | (defun tmr--completion-table (candidates &optional category annotation) 732 | "Make completion table for CANDIDATES with sorting disabled. 733 | CATEGORY is the completion category. 734 | ANNOTATION is an annotation function." 735 | (lambda (str pred action) 736 | (if (eq action 'metadata) 737 | `(metadata (display-sort-function . identity) 738 | (cycle-sort-function . identity) 739 | (annotation-function . ,annotation) 740 | (category . ,category)) 741 | (complete-with-action action candidates str pred)))) 742 | 743 | 744 | ;;;; Key bindings 745 | 746 | (defvar-keymap tmr-prefix-map 747 | :doc "Global prefix map for TMRs. 748 | This map should be bound to a global prefix key." 749 | "+" #'tmr 750 | "*" #'tmr-with-details 751 | "t" #'tmr 752 | "T" #'tmr-with-details 753 | "l" #'tmr-tabulated-view 754 | "c" #'tmr-clone 755 | "s" #'tmr-reschedule 756 | "a" #'tmr-toggle-acknowledge 757 | "e" #'tmr-edit-description 758 | "r" #'tmr-remove 759 | "R" #'tmr-remove-finished 760 | "k" #'tmr-cancel) 761 | 762 | ;;;###autoload (autoload 'tmr-prefix-map "tmr" nil t 'keymap) 763 | (defalias 'tmr-prefix-map tmr-prefix-map) 764 | 765 | (defvar-keymap tmr-tabulated-mode-map 766 | :doc "Keybindings for `tmr-tabulated-mode'." 767 | "k" #'tmr-remove 768 | "r" #'tmr-remove 769 | "R" #'tmr-remove-finished 770 | "+" #'tmr 771 | "t" #'tmr 772 | "*" #'tmr-with-details 773 | "T" #'tmr-with-details 774 | "c" #'tmr-clone 775 | "a" #'tmr-toggle-acknowledge 776 | "e" #'tmr-edit-description 777 | "s" #'tmr-reschedule) 778 | 779 | ;;;;; Integration with the `embark' package 780 | 781 | (defvar-keymap tmr-action-map 782 | :doc "Action map for TMRs, which can be utilized by Embark." 783 | "k" #'tmr-remove 784 | "r" #'tmr-remove 785 | "R" #'tmr-remove-finished 786 | "c" #'tmr-clone 787 | "a" #'tmr-toggle-acknowledge 788 | "e" #'tmr-edit-description 789 | "s" #'tmr-reschedule) 790 | 791 | (defvar embark-keymap-alist) 792 | (defvar embark-post-action-hooks) 793 | (with-eval-after-load 'embark 794 | (add-to-list 'embark-keymap-alist '(tmr-timer . tmr-action-map)) 795 | (cl-loop 796 | for cmd the key-bindings of tmr-action-map 797 | if (commandp cmd) do 798 | (add-to-list 'embark-post-action-hooks (list cmd 'embark--restart)))) 799 | 800 | ;;;; Tabulated view 801 | 802 | ;;;###autoload 803 | (defun tmr-tabulated-view (buffer action-alist) 804 | "Open a tabulated list buffer listing tmr timers. 805 | BUFFER is the buffer to use and ACTION-ALIST is what `display-buffer' 806 | uses. Those parameters are meant for use in Lisp. In interactive use, 807 | they are set to reasonable default values." 808 | (interactive 809 | (list 810 | (get-buffer-create "*tmr-tabulated-view*") 811 | tmr-list-timers-action-alist)) 812 | (with-current-buffer buffer 813 | (tmr-tabulated-mode)) 814 | (display-buffer buffer action-alist)) 815 | 816 | (defalias 'tmr-list-timers 'tmr-tabulated-view 817 | "Alias for `tmr-tabulated-view' command.") 818 | 819 | (defun tmr-tabulated--set-entries () 820 | "Set the value of `tabulated-list-entries' with timers." 821 | (setq-local tabulated-list-entries 822 | (mapcar #'tmr-tabulated--timer-to-entry tmr--timers))) 823 | 824 | (defun tmr-tabulated--timer-to-entry (timer) 825 | "Convert TIMER into an entry suitable for `tabulated-list-entries'." 826 | (list 827 | timer 828 | (vector 829 | (propertize (tmr--format-creation-date timer) 'face 'tmr-tabulated-start-time) 830 | (propertize (tmr--format-end-date timer) 'face 'tmr-tabulated-end-time) 831 | (propertize (tmr--format-remaining timer) 'face 'tmr-tabulated-remaining-time) 832 | (propertize (if (tmr--timer-acknowledgep timer) "Yes" "") 'face 'tmr-tabulated-acknowledgement) 833 | (propertize (or (tmr--timer-description timer) "") 'face 'tmr-tabulated-description)))) 834 | 835 | (defvar-local tmr-tabulated--refresh-timer nil 836 | "Timer used to refresh tabulated view.") 837 | 838 | (defun tmr-tabulated--window-hook () 839 | "Setup timer to refresh tabulated view." 840 | (if (get-buffer-window) 841 | (unless tmr-tabulated--refresh-timer 842 | (let* ((timer nil) 843 | (buf (current-buffer)) 844 | (refresh 845 | (lambda () 846 | (if (buffer-live-p buf) 847 | (with-current-buffer buf 848 | (if-let* ((win (get-buffer-window))) 849 | (with-selected-window win 850 | (let ((end (eobp))) 851 | ;; Optimized refreshing 852 | (dolist (entry tabulated-list-entries) 853 | (setf (aref (cadr entry) 2) 854 | (propertize (tmr--format-remaining (car entry)) 'face 'tmr-tabulated-remaining-time))) 855 | (tabulated-list-print t) 856 | (when end (goto-char (point-max)))) 857 | ;; HACK: For some reason the hl-line highlighting gets lost here 858 | (when (and (bound-and-true-p global-hl-line-mode) 859 | (fboundp 'global-hl-line-highlight)) 860 | (global-hl-line-highlight)) 861 | (when (and (bound-and-true-p hl-line-mode) 862 | (fboundp 'hl-line-highlight)) 863 | (hl-line-highlight))) 864 | (cancel-timer timer) 865 | (setq tmr-tabulated--refresh-timer nil))) 866 | (cancel-timer timer))))) 867 | (setq timer (run-at-time 1 1 refresh) 868 | tmr-tabulated--refresh-timer timer))) 869 | (when tmr-tabulated--refresh-timer 870 | (cancel-timer tmr-tabulated--refresh-timer) 871 | (setq tmr-tabulated--refresh-timer nil)))) 872 | 873 | (defun tmr-tabulated--compare-remaining (a b) 874 | "Compare remaining time of timers A and B." 875 | (time-less-p (tmr--timer-end-date (car a)) 876 | (tmr--timer-end-date (car b)))) 877 | 878 | (define-derived-mode tmr-tabulated-mode tabulated-list-mode "TMR" 879 | "Major mode to display tmr timers." 880 | (setq-local tabulated-list-format 881 | [("Start" 10 t) 882 | ("End" 10 t) 883 | ("Remaining" 10 tmr-tabulated--compare-remaining) 884 | ("Acknowledge?" 14 t) 885 | ("Description" 0 t)]) 886 | (add-hook 'window-configuration-change-hook #'tmr-tabulated--window-hook nil t) 887 | (add-hook 'tabulated-list-revert-hook #'tmr-tabulated--set-entries nil t) 888 | (tmr-tabulated--set-entries) 889 | (tabulated-list-init-header) 890 | (tabulated-list-print)) 891 | 892 | (defun tmr-tabulated--timer-at-point () 893 | "Return the timer on the current line or nil." 894 | (and (eq major-mode #'tmr-tabulated-mode) (tabulated-list-get-id))) 895 | 896 | (defun tmr-tabulated--refresh () 897 | "Refresh *tmr-tabulated-view* buffer if it exists." 898 | (when-let* ((buf (get-buffer "*tmr-tabulated-view*"))) 899 | (with-current-buffer buf 900 | (let ((lines (line-number-at-pos))) 901 | (revert-buffer) 902 | (when (and (bobp) (> lines 1)) 903 | (forward-line (1- lines)) 904 | (unless (tabulated-list-get-id) 905 | (forward-line -1))))))) 906 | 907 | (add-hook 'tmr--update-hook #'tmr-tabulated--refresh) 908 | (add-hook 'tmr--read-timer-hook #'tmr-tabulated--timer-at-point) 909 | 910 | ;;;; Mode-line indicator 911 | 912 | (defvar tmr-mode-line-string nil 913 | "TMR mode-line string.") 914 | (put 'tmr-mode-line-string 'risky-local-variable t) 915 | 916 | (defvar tmr-mode-line--update-timer nil 917 | "Timer to update the mode-line.") 918 | 919 | (defun tmr-mode-line--format-remaining (timer) 920 | "Format remaining time for TIMER with appropriate face." 921 | (let* ((secs (float-time (time-subtract (tmr--timer-end-date timer) nil))) 922 | (face (cond ((and (< secs 5) (evenp (truncate secs))) 923 | '(tmr-mode-line-urgent (:inverse-video t))) 924 | ((< secs 30) 'tmr-mode-line-urgent) 925 | ((= (truncate secs) 30) 926 | '(tmr-mode-line-urgent (:inverse-video t))) 927 | ((= (truncate secs) 60) 928 | '(tmr-mode-line-soon (:inverse-video t))) 929 | ((< secs 120) 'tmr-mode-line-soon) 930 | ((= (truncate secs) 120) 931 | '(tmr-mode-line-soon (:inverse-video t))) 932 | (t 'tmr-mode-line-active))) 933 | (formatted (format-seconds 934 | (cond ((< secs 120) "%mm %ss%z") 935 | ((< secs (* 24 60 60)) "%hh %mm%z") 936 | (t "%dd %hh%z")) 937 | secs))) 938 | (propertize formatted 'face face))) 939 | 940 | (defun tmr-mode-line--format-description (timer) 941 | "Format description for TIMER, truncating if necessary." 942 | (if-let* ((desc (tmr--timer-description timer))) 943 | (concat " " (if tmr-mode-line-max-desc-length 944 | (truncate-string-to-width 945 | desc tmr-mode-line-max-desc-length 946 | nil nil t) 947 | desc)) 948 | "")) 949 | 950 | (defun tmr-mode-line--format-timer (timer) 951 | "Format a single TIMER for display in the mode-line." 952 | (propertize 953 | (format-spec tmr-mode-line-format 954 | `((?r . ,(tmr-mode-line--format-remaining timer)) 955 | (?d . ,(tmr-mode-line--format-description timer)))) 956 | 'help-echo (tmr--long-description timer))) 957 | 958 | (defun tmr-mode-line--get-active-timers () 959 | "Return a sorted list of active timers." 960 | (thread-last tmr--timers 961 | (seq-remove #'tmr--timer-finishedp) 962 | (seq-sort-by #'tmr--timer-end-date #'time-less-p))) 963 | 964 | (defun tmr-mode-line--update () 965 | "Updates `tmr-mode-line-string' based on the current timer state." 966 | (setq 967 | tmr-mode-line-string 968 | (if-let* ((active-timers (tmr-mode-line--get-active-timers))) 969 | (let* ((truncate (and tmr-mode-line-max-timers 970 | (length> active-timers tmr-mode-line-max-timers))) 971 | (timers-to-show (if truncate 972 | (seq-take active-timers 973 | tmr-mode-line-max-timers) 974 | active-timers))) 975 | (concat 976 | " " tmr-mode-line-prefix " " 977 | (string-join (mapcar #'tmr-mode-line--format-timer timers-to-show) 978 | tmr-mode-line-separator) 979 | (when truncate 980 | (format " +%d" (- (length active-timers) tmr-mode-line-max-timers))) 981 | " ")) 982 | "")) 983 | (force-mode-line-update t)) 984 | 985 | ;;;###autoload 986 | (define-minor-mode tmr-mode-line-mode 987 | "Display TMR May Ring timers in the global mode line." 988 | :global t 989 | :group 'tmr-mode-line 990 | (if tmr-mode-line-mode 991 | (progn 992 | (unless global-mode-string (setq global-mode-string '(""))) 993 | (unless (memq 'tmr-mode-line-string global-mode-string) 994 | (setq global-mode-string 995 | (append global-mode-string '(tmr-mode-line-string)))) 996 | (setq tmr-mode-line--update-timer 997 | (run-at-time t 1 #'tmr-mode-line--update)) 998 | (add-hook 'tmr--update-hook #'tmr-mode-line--update)) 999 | (when tmr-mode-line--update-timer 1000 | (cancel-timer tmr-mode-line--update-timer) 1001 | (setq tmr-mode-line--update-timer nil)) 1002 | (setq tmr-mode-line-string nil) 1003 | (remove-hook 'tmr--update-hook #'tmr-mode-line--update))) 1004 | 1005 | ;;;; Ask if there are timers before exiting Emacs 1006 | 1007 | (defun tmr-kill-emacs-query-function () 1008 | "Ask before exiting Emacs if there are any active TMR timers." 1009 | (if (not (and tmr--timers (seq-remove #'tmr--timer-finishedp tmr--timers))) 1010 | t 1011 | (tmr-tabulated-view 1012 | (get-buffer-create "*tmr-tabulated-view*") 1013 | '((display-buffer-reuse-mode-window display-buffer-at-bottom) 1014 | (mode . tmr-tabulated-mode) 1015 | (window-height . fit-window-to-buffer) 1016 | (dedicated . t) 1017 | (preserve-size . (t . t)))) 1018 | (yes-or-no-p "TMR has running timers; exit anyway? "))) 1019 | 1020 | (add-hook 'kill-emacs-query-functions #'tmr-kill-emacs-query-function) 1021 | 1022 | (provide 'tmr) 1023 | ;;; tmr.el ends here 1024 | --------------------------------------------------------------------------------