Changes committed gnus/lisp (ChangeLog gnus-registry.el gnus-sum.el)
"Ted Zlatanov" <[email protected]>
| Newsgroups | gmane.emacs.gnus.commits |
|---|---|
| Message-ID | <[email protected]> |
Modified: ChangeLog gnus-registry.el gnus-sum.el * gnus-registry.el (gnus-registry-install): Allow 'ask as an option. (gnus-registry-initialize, gnus-registry-install-p): Use it. (gnus-registry-install-shortcuts): Renamed from gnus-registry-install-shortcuts-and-menus. Installs the shortcuts in the `gnus-registry-mark-map' keymap dynamically from `gnus-registry-marks'. The generated functions update the summary line when a registry mark is added or deleted, and will call `gnus-registry-install-p' (see the comments in the code). (gnus-registry-user-format-function-M): Use concat intelligently. * gnus-sum.el (gnus-summary-make-menu-bar): Add menu entries for all the registry mark functions. Index: ChangeLog diff -u gnus/lisp/ChangeLog:7.1778 gnus/lisp/ChangeLog:7.1779 --- ChangeLog:7.1778 Wed Mar 5 00:19:15 2008 +++ ChangeLog Wed Mar 5 19:52:14 2008 @@ -1,3 +1,18 @@ +2008-03-05 Teodor Zlatanov <[email protected]> + + * gnus-registry.el (gnus-registry-install): Allow 'ask as an option. + (gnus-registry-initialize, gnus-registry-install-p): Use it. + (gnus-registry-install-shortcuts): Renamed from + gnus-registry-install-shortcuts-and-menus. Installs the shortcuts in + the `gnus-registry-mark-map' keymap dynamically from + `gnus-registry-marks'. The generated functions update the summary line + when a registry mark is added or deleted, and will call + `gnus-registry-install-p' (see the comments in the code). + (gnus-registry-user-format-function-M): Use concat intelligently. + + * gnus-sum.el (gnus-summary-make-menu-bar): Add menu entries for all + the registry mark functions. + 2008-03-04 Reiner Steib <[email protected]> * gnus-sum.el (gnus-print-buffer): Honor ps-print-color-p. @@ -5,7 +20,7 @@ 2008-03-04 Teodor Zlatanov <[email protected]> - * gnus-registry.el (gnus-registry-user-format-function-M): Added + * gnus-registry.el (gnus-registry-user-format-function-M): Add formatting function. 2008-03-03 Teodor Zlatanov <[email protected]> Index: gnus-registry.el diff -u gnus/lisp/gnus-registry.el:7.52 gnus/lisp/gnus-registry.el:7.53 --- gnus-registry.el:7.52 Tue Mar 4 23:35:59 2008 +++ gnus-registry.el Wed Mar 5 19:52:14 2008 @@ -132,10 +132,12 @@ :group 'gnus-registry :type '(repeat regexp)) -(defcustom gnus-registry-install nil +(defcustom gnus-registry-install 'ask "Whether the registry should be installed." :group 'gnus-registry - :type 'boolean) + :type '(choice (const :tag "Never Install" nil) + (const :tag "Always Install" t) + (const :tag "Ask Me" ask))) (defcustom gnus-registry-clean-empty t "Whether the empty registry entries should be deleted. @@ -709,17 +711,15 @@ (funcall function mark cell-data))))) ;;; this is ugly code, but I don't know how to do it better - -;;; TODO: clear the gnus-registry-mark-map before running (but I think -;;; gnus-define-keys does it by default) -(defun gnus-registry-install-shortcuts-and-menus () +(defun gnus-registry-install-shortcuts () "Install the keyboard shortcuts and menus for the registry. Uses `gnus-registry-marks' to find what shortcuts to install." - (gnus-registry-do-marks - :char - (lambda (mark data) - (let ((function-format - (format "gnus-registry-%%s-article-%s-mark" mark))) + (let (keys-plist) + (gnus-registry-do-marks + :char + (lambda (mark data) + (let ((function-format + (format "gnus-registry-%%s-article-%s-mark" mark))) ;;; The following generates these functions: ;;; (defun gnus-registry-set-article-Important-mark (&rest articles) @@ -731,62 +731,64 @@ ;;; (interactive (gnus-summary-work-articles current-prefix-arg)) ;;; (gnus-registry-set-article-mark-internal 'Important articles t t)) - (dolist (remove '(t nil)) - (let* ((variant-name (if remove "remove" "set")) - (function-name (format function-format variant-name)) - (shortcut (format "%c" data)) - (shortcut (if remove (upcase shortcut) shortcut))) - (unintern function-name) - (eval - `(defun - ;; function name - ,(intern function-name) - ;; parameter definition - (&rest articles) - ;; documentation - ,(format - "%s the %s mark over process-marked ARTICLES." - (upcase-initials variant-name) - mark) - ;; interactive definition - (interactive - (gnus-summary-work-articles current-prefix-arg)) - ;; actual code - (gnus-registry-set-article-mark-internal - ;; all this just to get the mark, I must be doing it wrong - (intern ,(symbol-name mark)) - articles ,remove t))) - (gnus-message 9 "Defined mark handling function %s" function-name)))))) - ;; I don't know how to do this inside the loop above, because - ;; gnus-define-keys is a macro - (gnus-define-keys (gnus-registry-mark-map "M" gnus-summary-mark-map) - "i" gnus-registry-set-article-Important-mark - "I" gnus-registry-remove-article-Important-mark - "w" gnus-registry-set-article-Work-mark - "W" gnus-registry-remove-article-Work-mark - "l" gnus-registry-set-article-Later-mark - "L" gnus-registry-remove-article-Later-mark - "p" gnus-registry-set-article-Personal-mark - "P" gnus-registry-remove-article-Personal-mark - "t" gnus-registry-set-article-To-Do-mark - "T" gnus-registry-remove-article-To-Do-mark)) + (dolist (remove '(t nil)) + (let* ((variant-name (if remove "remove" "set")) + (function-name (format function-format variant-name)) + (shortcut (format "%c" data)) + (shortcut (if remove (upcase shortcut) shortcut))) + (unintern function-name) + (eval + `(defun + ;; function name + ,(intern function-name) + ;; parameter definition + (&rest articles) + ;; documentation + ,(format + "%s the %s mark over process-marked ARTICLES." + (upcase-initials variant-name) + mark) + ;; interactive definition + (interactive + (gnus-summary-work-articles current-prefix-arg)) + ;; actual code + + ;; if this is called and the user doesn't want the + ;; registry enabled, we'll ask anyhow + (when (eq gnus-registry-install nil) + (setq gnus-registry-install 'ask)) + + ;; now the user is asked if gnus-registry-install is 'ask + (when (gnus-registry-install-p) + (gnus-registry-set-article-mark-internal + ;; all this just to get the mark, I must be doing it wrong + (intern ,(symbol-name mark)) + articles ,remove t) + (dolist (article articles) + (gnus-summary-update-article + article + (assoc article (gnus-data-list nil))))))) + (push (intern function-name) keys-plist) + (push shortcut keys-plist) + (gnus-message + 9 + "Defined mark handling function %s" + function-name)))))) + (gnus-define-keys-1 + '(gnus-registry-mark-map "M" gnus-summary-mark-map) + keys-plist))) ;;; use like this: -;;; (defalias 'gnus-user-format-function-M 'gnus-registry-user-format-function-M) -(defun gnus-registry-user-format-function-M (headers) +;;; (defalias 'gnus-user-format-function-M +;;; 'gnus-registry-user-format-function-M) + (defun gnus-registry-user-format-function-M (headers) (let* ((id (mail-header-message-id headers)) - (marks (when id (gnus-registry-fetch-extra-marks id))) - (out "")) - (dolist (mark marks) - (let ((c (plist-get - (cdr-safe - (assoc mark gnus-registry-marks)) :char))) - (setq out (format "%s%s" - out - (if c - (char-to-string c) - ""))))) - out)) + (marks (when id (gnus-registry-fetch-extra-marks id)))) + (concat (mapcar (lambda(mark) + (list (plist-get + (cdr-safe (assoc mark gnus-registry-marks)) + :char))) + marks)))) (defun gnus-registry-read-mark () "Read a mark name from the user with completion." @@ -1053,10 +1055,12 @@ ;;;###autoload (defun gnus-registry-initialize () +"Initialize the Gnus registry." (interactive) - (setq gnus-registry-install t) + (gnus-message 5 "Initializing the registry") + (setq gnus-registry-install t) ; in case it was 'ask or nil (gnus-registry-install-hooks) - (gnus-registry-install-shortcuts-and-menus) + (gnus-registry-install-shortcuts) (gnus-registry-read)) ;;;###autoload @@ -1088,11 +1092,24 @@ (add-hook 'gnus-registry-unload-hook 'gnus-registry-unload-hook) -(when gnus-registry-install - (gnus-registry-install-hooks) - (gnus-registry-read)) +(defun gnus-registry-install-p () + (interactive) + (when (eq gnus-registry-install 'ask) + (setq gnus-registry-install + (gnus-y-or-n-p + (concat "Enable the Gnus registry? " + "See the variable `gnus-registry-install' " + "to get rid of this query permanently. "))) + (when gnus-registry-install + ;; we just set gnus-registry-install to t, so initialize the registry! + (gnus-registry-initialize))) +;;; we could call it here: (customize-variable 'gnus-registry-install) + gnus-registry-install) + +(when (gnus-registry-install-p) + (gnus-registry-initialize)) -;; TODO: a lot of things +;; TODO: a few things (provide 'gnus-registry) Index: gnus-sum.el diff -u gnus/lisp/gnus-sum.el:7.215 gnus/lisp/gnus-sum.el:7.216 --- gnus-sum.el:7.215 Wed Mar 5 00:19:15 2008 +++ gnus-sum.el Wed Mar 5 19:52:14 2008 @@ -2588,6 +2588,17 @@ ["Set expirable mark" gnus-summary-mark-as-expirable t] ["Set bookmark" gnus-summary-set-bookmark t] ["Remove bookmark" gnus-summary-remove-bookmark t]) + ("Registry Mark" + ["Important" gnus-registry-set-article-Important-mark t] + ["Not Important" gnus-registry-remove-article-Important-mark t] + ["Work" gnus-registry-set-article-Work-mark t] + ["Not Work" gnus-registry-remove-article-Work-mark t] + ["Later" gnus-registry-set-article-Later-mark t] + ["Not Later" gnus-registry-remove-article-Later-mark t] + ["Personal" gnus-registry-set-article-Personal-mark t] + ["Not Personal" gnus-registry-remove-article-Personal-mark t] + ["To Do" gnus-registry-set-article-To-Do-mark t] + ["Not To Do" gnus-registry-remove-article-To-Do-mark t]) ("Limit to" ["Marks..." gnus-summary-limit-to-marks t] ["Subject..." gnus-summary-limit-to-subject t]