diff options
| author | Katsumi Yamaoka | 2012-12-04 23:24:24 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2012-12-04 23:24:24 +0000 |
| commit | 68c2d59da47ba77a9e31e27550c39cc86beb5b67 (patch) | |
| tree | 6071740c48ee9c67108242224e5735982513eb56 | |
| parent | 396376f1aeb072d20f1a8271ee47620b2ba9c15b (diff) | |
| download | emacs-68c2d59da47ba77a9e31e27550c39cc86beb5b67.tar.gz emacs-68c2d59da47ba77a9e31e27550c39cc86beb5b67.zip | |
gmm-utils.el (gmm-labels): Use cl-labels if available
| -rw-r--r-- | lisp/gnus/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/gnus/gmm-utils.el | 36 |
2 files changed, 6 insertions, 34 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index f625771cdb9..2d125753c17 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,5 +1,9 @@ | |||
| 1 | 2012-12-04 Katsumi Yamaoka <yamaoka@jpl.org> | 1 | 2012-12-04 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 2 | ||
| 3 | * gmm-utils.el (gmm-labels): Use cl-labels if available. | ||
| 4 | |||
| 5 | 2012-12-04 Katsumi Yamaoka <yamaoka@jpl.org> | ||
| 6 | |||
| 3 | * gmm-utils.el (gmm-flet, gmm-labels): New macros. | 7 | * gmm-utils.el (gmm-flet, gmm-labels): New macros. |
| 4 | 8 | ||
| 5 | * gnus-sync.el (gnus-sync-lesync-call) | 9 | * gnus-sync.el (gnus-sync-lesync-call) |
diff --git a/lisp/gnus/gmm-utils.el b/lisp/gnus/gmm-utils.el index 3d504d73cee..9be6c66b63a 100644 --- a/lisp/gnus/gmm-utils.el +++ b/lisp/gnus/gmm-utils.el | |||
| @@ -435,46 +435,14 @@ coding-system." | |||
| 435 | (fmakunbound (car orig))))))) | 435 | (fmakunbound (car orig))))))) |
| 436 | (put 'gmm-flet 'lisp-indent-function 1) | 436 | (put 'gmm-flet 'lisp-indent-function 1) |
| 437 | 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) | 438 | (defmacro gmm-labels (bindings &rest body) |
| 460 | "Make temporary function bindings. | 439 | "Make temporary function bindings. |
| 461 | The lexical scoping is handled via `lexical-let' rather than relying | 440 | The lexical scoping is handled via `lexical-let' rather than relying |
| 462 | on `lexical-binding'. | 441 | on `lexical-binding'. |
| 463 | 442 | ||
| 464 | \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" | 443 | \(fn ((FUNC ARGLIST BODY...) ...) FORM...)" |
| 465 | (let (gmm-labels-environment def defs) | 444 | `(,(progn (require 'cl) (if (fboundp 'cl-labels) 'cl-labels 'labels)) |
| 466 | (dolist (binding bindings) | 445 | ,bindings ,@body)) |
| 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) | 446 | (put 'gmm-labels 'lisp-indent-function 1) |
| 479 | 447 | ||
| 480 | (provide 'gmm-utils) | 448 | (provide 'gmm-utils) |