diff options
| author | Stefan Monnier | 2014-09-22 10:10:53 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2014-09-22 10:10:53 -0400 |
| commit | 601a0cfe861eac8ed706a2bb3380c5788a1ef701 (patch) | |
| tree | 14eead96e680f0b9f649db3ea36fddfd0aca8133 | |
| parent | efd314de5564b4fa082d22ffaa3bfdc7c9c7efaf (diff) | |
| download | emacs-601a0cfe861eac8ed706a2bb3380c5788a1ef701.tar.gz emacs-601a0cfe861eac8ed706a2bb3380c5788a1ef701.zip | |
Use lexical-bindin in Ibuffer.
* lisp/ibuffer.el (ibuffer-do-toggle-read-only): `arg' is unused.
(ibuffer-compile-format): Simplify.
(ibuffer-clear-summary-columns): Simplify.
* lisp/ibuf-ext.el (ibuffer-generate-filter-groups): Don't use the third
elem of dotimes when we don't refer to the iteration var from it.
(ibuffer-toggle-sorting-mode): Avoid add-to-list.
* lisp/ibuf-macs.el (define-ibuffer-column, define-ibuffer-op):
Silence byte-compiler.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/ibuf-ext.el | 19 | ||||
| -rw-r--r-- | lisp/ibuf-macs.el | 9 | ||||
| -rw-r--r-- | lisp/ibuffer.el | 61 |
4 files changed, 56 insertions, 45 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e79080ab3d8..3fa8ca5a749 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,17 @@ | |||
| 1 | 2014-09-22 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2014-09-22 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | Use lexical-bindin in Ibuffer. | ||
| 4 | * ibuffer.el (ibuffer-do-toggle-read-only): `arg' is unused. | ||
| 5 | (ibuffer-compile-format): Simplify. | ||
| 6 | (ibuffer-clear-summary-columns): Simplify. | ||
| 7 | * ibuf-ext.el (ibuffer-generate-filter-groups): Don't use the third | ||
| 8 | elem of dotimes when we don't refer to the iteration var from it. | ||
| 9 | (ibuffer-toggle-sorting-mode): Avoid add-to-list. | ||
| 10 | * ibuf-macs.el (define-ibuffer-column, define-ibuffer-op): | ||
| 11 | Silence byte-compiler. | ||
| 12 | |||
| 13 | 2014-09-22 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 14 | |||
| 3 | * font-lock.el (font-lock-compile-keyword): Don't confuse a lambda | 15 | * font-lock.el (font-lock-compile-keyword): Don't confuse a lambda |
| 4 | expression for a list. | 16 | expression for a list. |
| 5 | 17 | ||
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index a3c5b062401..4b13b9ab11b 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; ibuf-ext.el --- extensions for ibuffer | 1 | ;;; ibuf-ext.el --- extensions for ibuffer -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -523,9 +523,9 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." | |||
| 523 | ibuffer-filter-groups | 523 | ibuffer-filter-groups |
| 524 | (append ibuffer-filter-groups | 524 | (append ibuffer-filter-groups |
| 525 | (list (cons "Default" nil)))))) | 525 | (list (cons "Default" nil)))))) |
| 526 | ;; (dolist (hidden ibuffer-hidden-filter-groups) | 526 | ;; (dolist (hidden ibuffer-hidden-filter-groups) |
| 527 | ;; (setq filter-group-alist (ibuffer-delete-alist | 527 | ;; (setq filter-group-alist (ibuffer-delete-alist |
| 528 | ;; hidden filter-group-alist))) | 528 | ;; hidden filter-group-alist))) |
| 529 | (let ((vec (make-vector (length filter-group-alist) nil)) | 529 | (let ((vec (make-vector (length filter-group-alist) nil)) |
| 530 | (i 0)) | 530 | (i 0)) |
| 531 | (dolist (filtergroup filter-group-alist) | 531 | (dolist (filtergroup filter-group-alist) |
| @@ -540,12 +540,13 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." | |||
| 540 | (cl-incf i) | 540 | (cl-incf i) |
| 541 | (setq bmarklist lamers)))) | 541 | (setq bmarklist lamers)))) |
| 542 | (let (ret) | 542 | (let (ret) |
| 543 | (dotimes (j i ret) | 543 | (dotimes (j i) |
| 544 | (let ((bufs (aref vec j))) | 544 | (let ((bufs (aref vec j))) |
| 545 | (unless (and noempty (null bufs)) | 545 | (unless (and noempty (null bufs)) |
| 546 | (push (cons (car (nth j filter-group-alist)) | 546 | (push (cons (car (nth j filter-group-alist)) |
| 547 | bufs) | 547 | bufs) |
| 548 | ret)))))))) | 548 | ret)))) |
| 549 | ret)))) | ||
| 549 | 550 | ||
| 550 | ;;;###autoload | 551 | ;;;###autoload |
| 551 | (defun ibuffer-filters-to-filter-group (name) | 552 | (defun ibuffer-filters-to-filter-group (name) |
| @@ -1100,9 +1101,9 @@ Default sorting modes are: | |||
| 1100 | Major Mode - the name of the major mode of the buffer | 1101 | Major Mode - the name of the major mode of the buffer |
| 1101 | Size - the size of the buffer" | 1102 | Size - the size of the buffer" |
| 1102 | (interactive) | 1103 | (interactive) |
| 1103 | (let ((modes (mapcar 'car ibuffer-sorting-functions-alist))) | 1104 | (let ((modes (mapcar #'car ibuffer-sorting-functions-alist))) |
| 1104 | (add-to-list 'modes 'recency) | 1105 | (cl-pushnew 'recency modes) |
| 1105 | (setq modes (sort modes 'string-lessp)) | 1106 | (setq modes (sort modes #'string-lessp)) |
| 1106 | (let ((next (or (car-safe (cdr-safe (memq ibuffer-sorting-mode modes))) | 1107 | (let ((next (or (car-safe (cdr-safe (memq ibuffer-sorting-mode modes))) |
| 1107 | (car modes)))) | 1108 | (car modes)))) |
| 1108 | (setq ibuffer-sorting-mode next) | 1109 | (setq ibuffer-sorting-mode next) |
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index a475e1eccb9..96701ee4d39 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; ibuf-macs.el --- macros for ibuffer | 1 | ;;; ibuf-macs.el --- macros for ibuffer -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -111,6 +111,7 @@ change its definition, you should explicitly call | |||
| 111 | ,(if inline | 111 | ,(if inline |
| 112 | `(push '(,sym ,bod) ibuffer-inline-columns) | 112 | `(push '(,sym ,bod) ibuffer-inline-columns) |
| 113 | `(defun ,sym (buffer mark) | 113 | `(defun ,sym (buffer mark) |
| 114 | (ignore mark) ;Silence byte-compiler if mark is unused. | ||
| 114 | ,bod)) | 115 | ,bod)) |
| 115 | (put (quote ,sym) 'ibuffer-column-name | 116 | (put (quote ,sym) 'ibuffer-column-name |
| 116 | ,(if (stringp name) | 117 | ,(if (stringp name) |
| @@ -204,7 +205,8 @@ macro for exactly what it does. | |||
| 204 | (declare (indent 2) (doc-string 3)) | 205 | (declare (indent 2) (doc-string 3)) |
| 205 | `(progn | 206 | `(progn |
| 206 | (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) | 207 | (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) |
| 207 | "" "ibuffer-do-") (symbol-name op))) | 208 | "" "ibuffer-do-") |
| 209 | (symbol-name op))) | ||
| 208 | ,args | 210 | ,args |
| 209 | ,(if (stringp documentation) | 211 | ,(if (stringp documentation) |
| 210 | documentation | 212 | documentation |
| @@ -247,6 +249,9 @@ macro for exactly what it does. | |||
| 247 | (_ | 249 | (_ |
| 248 | 'ibuffer-map-marked-lines)) | 250 | 'ibuffer-map-marked-lines)) |
| 249 | #'(lambda (buf mark) | 251 | #'(lambda (buf mark) |
| 252 | ;; Silence warning for code that doesn't | ||
| 253 | ;; use `mark'. | ||
| 254 | (ignore mark) | ||
| 250 | ,(if (eq modifier-p :maybe) | 255 | ,(if (eq modifier-p :maybe) |
| 251 | `(let ((ibuffer-tmp-previous-buffer-modification | 256 | `(let ((ibuffer-tmp-previous-buffer-modification |
| 252 | (buffer-modified-p buf))) | 257 | (buffer-modified-p buf))) |
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el index 0f219e143b2..2bff41b8024 100644 --- a/lisp/ibuffer.el +++ b/lisp/ibuffer.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; ibuffer.el --- operate on buffers like dired | 1 | ;;; ibuffer.el --- operate on buffers like dired -*- lexical-binding:t -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2000-2014 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -907,7 +907,7 @@ width and the longest string in LIST." | |||
| 907 | (when (zerop columns) | 907 | (when (zerop columns) |
| 908 | (setq columns 1)) | 908 | (setq columns 1)) |
| 909 | (while list | 909 | (while list |
| 910 | (dotimes (i (1- columns)) | 910 | (dotimes (_ (1- columns)) |
| 911 | (insert (concat (car list) (make-string (- max (length (car list))) | 911 | (insert (concat (car list) (make-string (- max (length (car list))) |
| 912 | ?\s))) | 912 | ?\s))) |
| 913 | (setq list (cdr list))) | 913 | (setq list (cdr list))) |
| @@ -1275,7 +1275,7 @@ a new window in the current frame, splitting vertically." | |||
| 1275 | :modifier-p t) | 1275 | :modifier-p t) |
| 1276 | (set-buffer-modified-p (not (buffer-modified-p)))) | 1276 | (set-buffer-modified-p (not (buffer-modified-p)))) |
| 1277 | 1277 | ||
| 1278 | (define-ibuffer-op ibuffer-do-toggle-read-only (&optional arg) | 1278 | (define-ibuffer-op ibuffer-do-toggle-read-only (&optional _arg);FIXME:arg unused! |
| 1279 | "Toggle read only status in marked buffers. | 1279 | "Toggle read only status in marked buffers. |
| 1280 | With optional ARG, make read-only only if ARG is not negative." | 1280 | With optional ARG, make read-only only if ARG is not negative." |
| 1281 | (:opstring "toggled read only status in" | 1281 | (:opstring "toggled read only status in" |
| @@ -1520,7 +1520,7 @@ If point is on a group name, this function operates on that group." | |||
| 1520 | ;; We use these variables to keep track of which variables | 1520 | ;; We use these variables to keep track of which variables |
| 1521 | ;; inside the generated function we need to bind, since | 1521 | ;; inside the generated function we need to bind, since |
| 1522 | ;; binding variables in Emacs takes time. | 1522 | ;; binding variables in Emacs takes time. |
| 1523 | str-used tmp1-used tmp2-used global-strlen-used) | 1523 | (vars-used ())) |
| 1524 | (dolist (form format) | 1524 | (dolist (form format) |
| 1525 | (push | 1525 | (push |
| 1526 | ;; Generate a form based on a particular format entry, like | 1526 | ;; Generate a form based on a particular format entry, like |
| @@ -1546,8 +1546,8 @@ If point is on a group name, this function operates on that group." | |||
| 1546 | ;; This is a complex case; they want it limited to a | 1546 | ;; This is a complex case; they want it limited to a |
| 1547 | ;; minimum size. | 1547 | ;; minimum size. |
| 1548 | (setq min-used t) | 1548 | (setq min-used t) |
| 1549 | (setq str-used t strlen-used t global-strlen-used t | 1549 | (setq strlen-used t) |
| 1550 | tmp1-used t tmp2-used t) | 1550 | (setq vars-used '(str strlen tmp1 tmp2)) |
| 1551 | ;; Generate code to limit the string to a minimum size. | 1551 | ;; Generate code to limit the string to a minimum size. |
| 1552 | (setq minform `(progn | 1552 | (setq minform `(progn |
| 1553 | (setq str | 1553 | (setq str |
| @@ -1559,7 +1559,8 @@ If point is on a group name, this function operates on that group." | |||
| 1559 | strlen) | 1559 | strlen) |
| 1560 | align))))) | 1560 | align))))) |
| 1561 | (when (or (not (integerp max)) (> max 0)) | 1561 | (when (or (not (integerp max)) (> max 0)) |
| 1562 | (setq str-used t max-used t) | 1562 | (setq max-used t) |
| 1563 | (cl-pushnew 'str vars-used) | ||
| 1563 | ;; Generate code to limit the string to a maximum size. | 1564 | ;; Generate code to limit the string to a maximum size. |
| 1564 | (setq maxform `(progn | 1565 | (setq maxform `(progn |
| 1565 | (setq str | 1566 | (setq str |
| @@ -1587,8 +1588,9 @@ If point is on a group name, this function operates on that group." | |||
| 1587 | ;; don't even understand it, and I wrote it five | 1588 | ;; don't even understand it, and I wrote it five |
| 1588 | ;; minutes ago. | 1589 | ;; minutes ago. |
| 1589 | (insertgenfn | 1590 | (insertgenfn |
| 1590 | (ibuffer-aif (get sym 'ibuffer-column-summarizer) | 1591 | (if (get sym 'ibuffer-column-summarizer) |
| 1591 | ;; I really, really wish Emacs Lisp had closures. | 1592 | ;; I really, really wish Emacs Lisp had closures. |
| 1593 | ;; FIXME: Elisp does have them now. | ||
| 1592 | (lambda (arg sym) | 1594 | (lambda (arg sym) |
| 1593 | `(insert | 1595 | `(insert |
| 1594 | (let ((ret ,arg)) | 1596 | (let ((ret ,arg)) |
| @@ -1596,7 +1598,7 @@ If point is on a group name, this function operates on that group." | |||
| 1596 | (cons ret (get ',sym | 1598 | (cons ret (get ',sym |
| 1597 | 'ibuffer-column-summary))) | 1599 | 'ibuffer-column-summary))) |
| 1598 | ret))) | 1600 | ret))) |
| 1599 | (lambda (arg sym) | 1601 | (lambda (arg _sym) |
| 1600 | `(insert ,arg)))) | 1602 | `(insert ,arg)))) |
| 1601 | (mincompform `(< strlen ,(if (integerp min) | 1603 | (mincompform `(< strlen ,(if (integerp min) |
| 1602 | min | 1604 | min |
| @@ -1624,10 +1626,9 @@ If point is on a group name, this function operates on that group." | |||
| 1624 | `(when ,maxcompform | 1626 | `(when ,maxcompform |
| 1625 | ,maxform))) | 1627 | ,maxform))) |
| 1626 | outforms) | 1628 | outforms) |
| 1627 | (push (append | 1629 | (push `(setq str ,callform |
| 1628 | `(setq str ,callform) | 1630 | ,@(when strlen-used |
| 1629 | (when strlen-used | 1631 | `(strlen (length str)))) |
| 1630 | `(strlen (length str)))) | ||
| 1631 | outforms) | 1632 | outforms) |
| 1632 | (setq outforms | 1633 | (setq outforms |
| 1633 | (append outforms | 1634 | (append outforms |
| @@ -1640,25 +1641,17 @@ If point is on a group name, this function operates on that group." | |||
| 1640 | `(let ,letbindings | 1641 | `(let ,letbindings |
| 1641 | ,@outforms))))) | 1642 | ,@outforms))))) |
| 1642 | result)) | 1643 | result)) |
| 1643 | (setq result | 1644 | ;; We don't want to unconditionally load the byte-compiler. |
| 1644 | ;; We don't want to unconditionally load the byte-compiler. | 1645 | (funcall (if (or ibuffer-always-compile-formats |
| 1645 | (funcall (if (or ibuffer-always-compile-formats | 1646 | (featurep 'bytecomp)) |
| 1646 | (featurep 'bytecomp)) | 1647 | #'byte-compile |
| 1647 | #'byte-compile | 1648 | #'identity) |
| 1648 | #'identity) | 1649 | ;; Here, we actually create a lambda form which |
| 1649 | ;; Here, we actually create a lambda form which | 1650 | ;; inserts all the generated forms for each entry |
| 1650 | ;; inserts all the generated forms for each entry | 1651 | ;; in the format string. |
| 1651 | ;; in the format string. | 1652 | `(lambda (buffer mark) |
| 1652 | (nconc (list 'lambda '(buffer mark)) | 1653 | (let ,vars-used |
| 1653 | `((let ,(append (when str-used | 1654 | ,@(nreverse result)))))) |
| 1654 | '(str)) | ||
| 1655 | (when global-strlen-used | ||
| 1656 | '(strlen)) | ||
| 1657 | (when tmp1-used | ||
| 1658 | '(tmp1)) | ||
| 1659 | (when tmp2-used | ||
| 1660 | '(tmp2))) | ||
| 1661 | ,@(nreverse result)))))))) | ||
| 1662 | 1655 | ||
| 1663 | (defun ibuffer-recompile-formats () | 1656 | (defun ibuffer-recompile-formats () |
| 1664 | "Recompile `ibuffer-formats'." | 1657 | "Recompile `ibuffer-formats'." |
| @@ -1676,8 +1669,8 @@ If point is on a group name, this function operates on that group." | |||
| 1676 | 1669 | ||
| 1677 | (defun ibuffer-clear-summary-columns (format) | 1670 | (defun ibuffer-clear-summary-columns (format) |
| 1678 | (dolist (form format) | 1671 | (dolist (form format) |
| 1679 | (ibuffer-awhen (and (consp form) | 1672 | (when (and (consp form) |
| 1680 | (get (car form) 'ibuffer-column-summarizer)) | 1673 | (get (car form) 'ibuffer-column-summarizer)) |
| 1681 | (put (car form) 'ibuffer-column-summary nil)))) | 1674 | (put (car form) 'ibuffer-column-summary nil)))) |
| 1682 | 1675 | ||
| 1683 | (defun ibuffer-check-formats () | 1676 | (defun ibuffer-check-formats () |