diff options
| author | Katsumi Yamaoka | 2012-12-04 08:22:12 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2012-12-04 08:22:12 +0000 |
| commit | 46a2cc4470732ec3d8ac152932704bbcf394ee67 (patch) | |
| tree | 849560f8345609f829ae90d2fcf3869e0c2150fd | |
| parent | ce3e7725b44e2785814cfb9bb68496e7ff95da3c (diff) | |
| download | emacs-46a2cc4470732ec3d8ac152932704bbcf394ee67.tar.gz emacs-46a2cc4470732ec3d8ac152932704bbcf394ee67.zip | |
gmm-utils.el (gmm-flet, gmm-labels): New macros.
gnus-sync.el (gnus-sync-lesync-call)
message.el (message-read-from-minibuffer): Use gmm-flet.
gnus-score.el (gnus-score-decode-text-parts): Use gmm-labels.
gnus-util.el (gnus-macroexpand-all): Remove.
| -rw-r--r-- | lisp/gnus/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/gnus/gmm-utils.el | 60 | ||||
| -rw-r--r-- | lisp/gnus/gnus-score.el | 52 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sync.el | 3 | ||||
| -rw-r--r-- | lisp/gnus/gnus-util.el | 21 | ||||
| -rw-r--r-- | lisp/gnus/message.el | 2 |
6 files changed, 102 insertions, 47 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 0aef3732ad5..f625771cdb9 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2012-12-04 Katsumi Yamaoka <yamaoka@jpl.org> | ||
| 2 | |||
| 3 | * gmm-utils.el (gmm-flet, gmm-labels): New macros. | ||
| 4 | |||
| 5 | * gnus-sync.el (gnus-sync-lesync-call) | ||
| 6 | * message.el (message-read-from-minibuffer): Use gmm-flet. | ||
| 7 | |||
| 8 | * gnus-score.el (gnus-score-decode-text-parts): Use gmm-labels. | ||
| 9 | |||
| 10 | * gnus-util.el (gnus-macroexpand-all): Remove. | ||
| 11 | |||
| 1 | 2012-12-03 Andreas Schwab <schwab@linux-m68k.org> | 12 | 2012-12-03 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 13 | ||
| 3 | * gnus-sum.el (gnus-summary-mode-map): Bind gnus-summary-widget-forward | 14 | * gnus-sum.el (gnus-summary-mode-map): Bind gnus-summary-widget-forward |
diff --git a/lisp/gnus/gmm-utils.el b/lisp/gnus/gmm-utils.el index 975b83370ba..3d504d73cee 100644 --- a/lisp/gnus/gmm-utils.el +++ b/lisp/gnus/gmm-utils.el | |||
| @@ -417,6 +417,66 @@ coding-system." | |||
| 417 | (write-region start end filename append visit lockname)) | 417 | (write-region start end filename append visit lockname)) |
| 418 | (write-region start end filename append visit lockname mustbenew))) | 418 | (write-region start end filename append visit lockname mustbenew))) |
| 419 | 419 | ||
| 420 | ;; `flet' and `labels' got obsolete since Emacs 24.3. | ||
| 421 | (defmacro gmm-flet (bindings &rest body) | ||
| 422 | "Make temporary overriding function definitions. | ||
| 423 | |||
| 424 | \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" | ||
| 425 | `(let (fn origs) | ||
| 426 | (dolist (bind ',bindings) | ||
| 427 | (setq fn (car bind)) | ||
| 428 | (push (cons fn (and (fboundp fn) (symbol-function fn))) origs) | ||
| 429 | (fset fn (cons 'lambda (cdr bind)))) | ||
| 430 | (unwind-protect | ||
| 431 | (progn ,@body) | ||
| 432 | (dolist (orig origs) | ||
| 433 | (if (cdr orig) | ||
| 434 | (fset (car orig) (cdr orig)) | ||
| 435 | (fmakunbound (car orig))))))) | ||
| 436 | (put 'gmm-flet 'lisp-indent-function 1) | ||
| 437 | |||
| 438 | ;; An alist of original function names and those unique names. | ||
| 439 | (defvar gmm-labels-environment) | ||
| 440 | |||
| 441 | (defun gmm-labels-expand (form) | ||
| 442 | "Expand funcalls in FORM according to `gmm-labels-environment'. | ||
| 443 | This function is a subroutine that `gmm-labels' uses to convert any | ||
| 444 | `(FN ...)' and #'FN elements in FORM into `(funcall UN ...)' and `UN' | ||
| 445 | respectively if `(FN . UN)' is listed in `gmm-labels-environment'." | ||
| 446 | (cond ((or (not (consp form)) (memq (car form) '(\` backquote quote))) | ||
| 447 | form) | ||
| 448 | ((assq (car form) gmm-labels-environment) | ||
| 449 | `(funcall ,(cdr (assq (car form) gmm-labels-environment)) | ||
| 450 | ,@(mapcar #'gmm-labels-expand (cdr form)))) | ||
| 451 | ((eq (car form) 'function) | ||
| 452 | (if (and (assq (cadr form) gmm-labels-environment) | ||
| 453 | (not (cddr form))) | ||
| 454 | (cdr (assq (cadr form) gmm-labels-environment)) | ||
| 455 | (cons 'function (mapcar #'gmm-labels-expand (cdr form))))) | ||
| 456 | (t | ||
| 457 | (mapcar #'gmm-labels-expand form)))) | ||
| 458 | |||
| 459 | (defmacro gmm-labels (bindings &rest body) | ||
| 460 | "Make temporary function bindings. | ||
| 461 | The lexical scoping is handled via `lexical-let' rather than relying | ||
| 462 | on `lexical-binding'. | ||
| 463 | |||
| 464 | \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" | ||
| 465 | (let (gmm-labels-environment def defs) | ||
| 466 | (dolist (binding bindings) | ||
| 467 | (push (cons (car binding) | ||
| 468 | (make-symbol (format "--gmm-%s--" (car binding)))) | ||
| 469 | gmm-labels-environment)) | ||
| 470 | `(lexical-let ,(mapcar #'cdr gmm-labels-environment) | ||
| 471 | (setq ,@(dolist (env gmm-labels-environment (nreverse defs)) | ||
| 472 | (setq def (cdr (assq (car env) bindings))) | ||
| 473 | (push (cdr env) defs) | ||
| 474 | (push `(lambda ,(car def) | ||
| 475 | ,@(mapcar #'gmm-labels-expand (cdr def))) | ||
| 476 | defs))) | ||
| 477 | ,@(mapcar #'gmm-labels-expand body)))) | ||
| 478 | (put 'gmm-labels 'lisp-indent-function 1) | ||
| 479 | |||
| 420 | (provide 'gmm-utils) | 480 | (provide 'gmm-utils) |
| 421 | 481 | ||
| 422 | ;;; gmm-utils.el ends here | 482 | ;;; gmm-utils.el ends here |
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el index b7061960839..f7a507fd1d7 100644 --- a/lisp/gnus/gnus-score.el +++ b/lisp/gnus/gnus-score.el | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | (require 'gnus-win) | 33 | (require 'gnus-win) |
| 34 | (require 'message) | 34 | (require 'message) |
| 35 | (require 'score-mode) | 35 | (require 'score-mode) |
| 36 | (require 'gmm-utils) | ||
| 36 | 37 | ||
| 37 | (defcustom gnus-global-score-files nil | 38 | (defcustom gnus-global-score-files nil |
| 38 | "List of global score files and directories. | 39 | "List of global score files and directories. |
| @@ -1718,33 +1719,36 @@ score in `gnus-newsgroup-scored' by SCORE." | |||
| 1718 | nil) | 1719 | nil) |
| 1719 | 1720 | ||
| 1720 | (defun gnus-score-decode-text-parts () | 1721 | (defun gnus-score-decode-text-parts () |
| 1721 | (labels ((mm-text-parts (handle) | 1722 | (gmm-labels |
| 1722 | (cond ((stringp (car handle)) | 1723 | ((mm-text-parts |
| 1723 | (let ((parts (mapcan #'mm-text-parts (cdr handle)))) | 1724 | (handle) |
| 1724 | (if (equal "multipart/alternative" (car handle)) | 1725 | (cond ((stringp (car handle)) |
| 1725 | ;; pick the first supported alternative | 1726 | (let ((parts (mapcan #'mm-text-parts (cdr handle)))) |
| 1726 | (list (car parts)) | 1727 | (if (equal "multipart/alternative" (car handle)) |
| 1727 | parts))) | 1728 | ;; pick the first supported alternative |
| 1728 | 1729 | (list (car parts)) | |
| 1729 | ((bufferp (car handle)) | 1730 | parts))) |
| 1730 | (when (string-match "^text/" (mm-handle-media-type handle)) | 1731 | |
| 1731 | (list handle))) | 1732 | ((bufferp (car handle)) |
| 1732 | 1733 | (when (string-match "^text/" (mm-handle-media-type handle)) | |
| 1733 | (t (mapcan #'mm-text-parts handle)))) | 1734 | (list handle))) |
| 1734 | (my-mm-display-part (handle) | 1735 | |
| 1735 | (when handle | 1736 | (t (mapcan #'mm-text-parts handle)))) |
| 1736 | (save-restriction | 1737 | (my-mm-display-part |
| 1737 | (narrow-to-region (point) (point)) | 1738 | (handle) |
| 1738 | (mm-display-inline handle) | 1739 | (when handle |
| 1739 | (goto-char (point-max)))))) | 1740 | (save-restriction |
| 1741 | (narrow-to-region (point) (point)) | ||
| 1742 | (mm-display-inline handle) | ||
| 1743 | (goto-char (point-max)))))) | ||
| 1740 | 1744 | ||
| 1741 | (let (;(mm-text-html-renderer 'w3m-standalone) | 1745 | (let (;(mm-text-html-renderer 'w3m-standalone) |
| 1742 | (handles (mm-dissect-buffer t))) | 1746 | (handles (mm-dissect-buffer t))) |
| 1743 | (save-excursion | 1747 | (save-excursion |
| 1744 | (article-goto-body) | 1748 | (article-goto-body) |
| 1745 | (delete-region (point) (point-max)) | 1749 | (delete-region (point) (point-max)) |
| 1746 | (mapc #'my-mm-display-part (mm-text-parts handles)) | 1750 | (mapc #'my-mm-display-part (mm-text-parts handles)) |
| 1747 | handles)))) | 1751 | handles)))) |
| 1748 | 1752 | ||
| 1749 | (defun gnus-score-body (scores header now expire &optional trace) | 1753 | (defun gnus-score-body (scores header now expire &optional trace) |
| 1750 | (if gnus-agent-fetching | 1754 | (if gnus-agent-fetching |
diff --git a/lisp/gnus/gnus-sync.el b/lisp/gnus/gnus-sync.el index 493025cbe1d..e2a71f0ee01 100644 --- a/lisp/gnus/gnus-sync.el +++ b/lisp/gnus/gnus-sync.el | |||
| @@ -88,6 +88,7 @@ | |||
| 88 | (require 'gnus) | 88 | (require 'gnus) |
| 89 | (require 'gnus-start) | 89 | (require 'gnus-start) |
| 90 | (require 'gnus-util) | 90 | (require 'gnus-util) |
| 91 | (require 'gmm-utils) | ||
| 91 | 92 | ||
| 92 | (defvar gnus-topic-alist) ;; gnus-group.el | 93 | (defvar gnus-topic-alist) ;; gnus-group.el |
| 93 | (eval-when-compile | 94 | (eval-when-compile |
| @@ -176,7 +177,7 @@ and `gnus-topic-alist'. Also see `gnus-variable-list'." | |||
| 176 | (defun gnus-sync-lesync-call (url method headers &optional kvdata) | 177 | (defun gnus-sync-lesync-call (url method headers &optional kvdata) |
| 177 | "Make an access request to URL using KVDATA and METHOD. | 178 | "Make an access request to URL using KVDATA and METHOD. |
| 178 | KVDATA must be an alist." | 179 | KVDATA must be an alist." |
| 179 | (flet ((json-alist-p (list) (gnus-sync-json-alist-p list))) ; temp patch | 180 | (gmm-flet ((json-alist-p (list) (gnus-sync-json-alist-p list))) ; temp patch |
| 180 | (let ((url-request-method method) | 181 | (let ((url-request-method method) |
| 181 | (url-request-extra-headers headers) | 182 | (url-request-extra-headers headers) |
| 182 | (url-request-data (if kvdata (json-encode kvdata) nil))) | 183 | (url-request-data (if kvdata (json-encode kvdata) nil))) |
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index f5e1077f8c4..7b1e2b5c792 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el | |||
| @@ -1938,27 +1938,6 @@ to case differences." | |||
| 1938 | (string-equal (downcase str1) (downcase prefix)) | 1938 | (string-equal (downcase str1) (downcase prefix)) |
| 1939 | (string-equal str1 prefix)))))) | 1939 | (string-equal str1 prefix)))))) |
| 1940 | 1940 | ||
| 1941 | (eval-and-compile | ||
| 1942 | (if (fboundp 'macroexpand-all) | ||
| 1943 | (defalias 'gnus-macroexpand-all 'macroexpand-all) | ||
| 1944 | (defun gnus-macroexpand-all (form &optional environment) | ||
| 1945 | "Return result of expanding macros at all levels in FORM. | ||
| 1946 | If no macros are expanded, FORM is returned unchanged. | ||
| 1947 | The second optional arg ENVIRONMENT specifies an environment of macro | ||
| 1948 | definitions to shadow the loaded ones for use in file byte-compilation." | ||
| 1949 | (if (consp form) | ||
| 1950 | (let ((idx 1) | ||
| 1951 | (len (length (setq form (copy-sequence form)))) | ||
| 1952 | expanded) | ||
| 1953 | (while (< idx len) | ||
| 1954 | (setcar (nthcdr idx form) (gnus-macroexpand-all (nth idx form) | ||
| 1955 | environment)) | ||
| 1956 | (setq idx (1+ idx))) | ||
| 1957 | (if (eq (setq expanded (macroexpand form environment)) form) | ||
| 1958 | form | ||
| 1959 | (gnus-macroexpand-all expanded environment))) | ||
| 1960 | form)))) | ||
| 1961 | |||
| 1962 | ;; Simple check: can be a macro but this way, although slow, it's really clear. | 1941 | ;; Simple check: can be a macro but this way, although slow, it's really clear. |
| 1963 | ;; We don't use `bound-and-true-p' because it's not in XEmacs. | 1942 | ;; We don't use `bound-and-true-p' because it's not in XEmacs. |
| 1964 | (defun gnus-bound-and-true-p (sym) | 1943 | (defun gnus-bound-and-true-p (sym) |
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 5a2b4334582..2171dcf3edc 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -8141,7 +8141,7 @@ regexp VARSTR." | |||
| 8141 | (if (fboundp 'mail-abbrevs-setup) | 8141 | (if (fboundp 'mail-abbrevs-setup) |
| 8142 | (let ((minibuffer-setup-hook 'mail-abbrevs-setup) | 8142 | (let ((minibuffer-setup-hook 'mail-abbrevs-setup) |
| 8143 | (minibuffer-local-map message-minibuffer-local-map)) | 8143 | (minibuffer-local-map message-minibuffer-local-map)) |
| 8144 | (flet ((mail-abbrev-in-expansion-header-p nil t)) | 8144 | (gmm-flet ((mail-abbrev-in-expansion-header-p nil t)) |
| 8145 | (read-from-minibuffer prompt initial-contents))) | 8145 | (read-from-minibuffer prompt initial-contents))) |
| 8146 | (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook) | 8146 | (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook) |
| 8147 | (minibuffer-local-map message-minibuffer-local-map)) | 8147 | (minibuffer-local-map message-minibuffer-local-map)) |