comparison lisp/isearch-mode.el @ 5655:b7ae5f44b950

Remove some redundant functions, change others to labels, lisp/ lisp/ChangeLog addition: 2012-05-05 Aidan Kehoe <kehoea@parhasard.net> Remove some redundant functions; turn other utility functions into labels, avoiding visibility in the global namespace, and reducing the size of the dumped binary. * auto-save.el (auto-save-unhex): Removed. * auto-save.el (auto-save-unescape-name): Use #'string-to-number instead of #'auto-save-unhex. * files.el (save-some-buffers): * files.el (save-some-buffers-1): Changed to a label. * files.el (not-modified): * gui.el (make-gui-button): * gui.el (gui-button-action): Changed to a label. * gui.el (insert-gui-button): * indent.el (indent-for-tab-command): * indent.el (insert-tab): Changed to a label. * indent.el (indent-rigidly): * isearch-mode.el: * isearch-mode.el (isearch-ring-adjust): * isearch-mode.el (isearch-ring-adjust1): Changed to a label. * isearch-mode.el (isearch-pre-command-hook): * isearch-mode.el (isearch-maybe-frob-keyboard-macros): Changed to a label. * isearch-mode.el (isearch-highlight): * isearch-mode.el (isearch-make-extent): Changed to a label. * itimer.el: * itimer.el (itimer-decrement): Removed, replaced uses with decf. * itimer.el (itimer-increment): Removed, replaced uses with incf. * itimer.el (itimer-signum): Removed, replaced uses with minusp, plusp. * itimer.el (itimer-name): * itimer.el (check-itimer): Removed, replaced with #'check-type calls. * itimer.el (itimer-value): * itimer.el (check-itimer-coerce-string): Removed. * itimer.el (itimer-restart): * itimer.el (itimer-function): * itimer.el (check-nonnegative-number): Removed. * itimer.el (itimer-uses-arguments): * itimer.el (check-string): Removed. * itimer.el (itimer-function-arguments): * itimer.el (itimer-recorded-run-time): * itimer.el (set-itimer-name): * itimer.el (set-itimer-value): * itimer.el (set-itimer-value-internal): * itimer.el (set-itimer-restart): * itimer.el (set-itimer-function): * itimer.el (set-itimer-is-idle): * itimer.el (set-itimer-recorded-run-time): * itimer.el (get-itimer): * itimer.el (delete-itimer): * itimer.el (start-itimer): * itimer.el (activate-itimer): * itimer.el (itimer-edit-set-field): * itimer.el (itimer-edit-next-field): * itimer.el (itimer-edit-previous-field): Use incf, decf, plusp, minusp and the more general argument type checking macros. * lib-complete.el: * lib-complete.el (lib-complete:better-root): Changed to a label. * lib-complete.el (lib-complete:get-completion-table): Changed to a label. * lib-complete.el (read-library-internal): Include labels. * lib-complete.el (lib-complete:cache-completions): Changed to a label. * minibuf.el (read-buffer): Use #'set-difference, don't reinvent it. * newcomment.el (comment-padright): Use a label instead of repeating a lambda expression. * packages.el (package-get-key): * packages.el (package-get-key-1): Removed, use #'getf instead. * simple.el (kill-backward-chars): Removed; this isn't used. * simple.el (what-cursor-position): (lambda (arg) (format "%S" arg) -> #'prin1-to-string. * simple.el (debug-print-1): Renamed to #'debug-print. * simple.el (debug-print): Removed, #'debug-print-1 was equivalent. * subr.el (integer-to-bit-vector): check-nonnegative-number no longer available. * widget.el (define-widget): * widget.el (define-widget-keywords): Removed, this was long obsolete.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 05 May 2012 18:42:00 +0100
parents ac37a5f7e5be
children 2b8edd304c2b
comparison
equal deleted inserted replaced
5654:ddf56c45634e 5655:b7ae5f44b950
1218 1218
1219 1219
1220 ;;=========================================================== 1220 ;;===========================================================
1221 ;; Search Ring 1221 ;; Search Ring
1222 1222
1223 (defun isearch-ring-adjust1 (advance)
1224 ;; Helper for isearch-ring-adjust
1225 (let* ((ring (if isearch-regexp regexp-search-ring search-ring))
1226 (length (length ring))
1227 (yank-pointer-name (if isearch-regexp
1228 'regexp-search-ring-yank-pointer
1229 'search-ring-yank-pointer))
1230 (yank-pointer (eval yank-pointer-name)))
1231 (if (zerop length)
1232 ()
1233 (set yank-pointer-name
1234 (setq yank-pointer
1235 (mod (+ (or yank-pointer 0)
1236 ;; XEmacs change
1237 (if advance -1 (if yank-pointer 1 0)))
1238 length)))
1239 (setq isearch-string (nth yank-pointer ring)
1240 isearch-message (mapconcat 'isearch-text-char-description
1241 isearch-string "")))))
1242
1243 (defun isearch-ring-adjust (advance) 1223 (defun isearch-ring-adjust (advance)
1244 ;; Helper for isearch-ring-advance and isearch-ring-retreat 1224 ;; Helper for isearch-ring-advance and isearch-ring-retreat
1245 ; (if (cdr isearch-cmds) ;; is there more than one thing on stack? 1225 ; (if (cdr isearch-cmds) ;; is there more than one thing on stack?
1246 ; (isearch-pop-state)) 1226 ; (isearch-pop-state))
1247 (isearch-ring-adjust1 advance) 1227 (labels
1248 (if search-ring-update 1228 ((isearch-ring-adjust1 (advance)
1249 (progn 1229 ;; Helper for isearch-ring-adjust
1250 (isearch-search) 1230 (let* ((ring (if isearch-regexp regexp-search-ring search-ring))
1251 (isearch-update)) 1231 (length (length ring))
1252 (isearch-edit-string) 1232 (yank-pointer-name (if isearch-regexp
1253 ) 1233 'regexp-search-ring-yank-pointer
1254 (isearch-push-state)) 1234 'search-ring-yank-pointer))
1235 (yank-pointer (symbol-value yank-pointer-name)))
1236 (if (zerop length)
1237 ()
1238 (set yank-pointer-name
1239 (setq yank-pointer
1240 (mod (+ (or yank-pointer 0)
1241 ;; XEmacs change
1242 (if advance -1 (if yank-pointer 1 0)))
1243 length)))
1244 (setq isearch-string (nth yank-pointer ring)
1245 isearch-message (mapconcat 'isearch-text-char-description
1246 isearch-string ""))))))
1247 (isearch-ring-adjust1 advance)
1248 (if search-ring-update
1249 (progn
1250 (isearch-search)
1251 (isearch-update))
1252 (isearch-edit-string))
1253 (isearch-push-state)))
1255 1254
1256 (defun isearch-ring-advance () 1255 (defun isearch-ring-advance ()
1257 "Advance to the next search string in the ring." 1256 "Advance to the next search string in the ring."
1258 ;; This could be more general to handle a prefix arg, but who would use it. 1257 ;; This could be more general to handle a prefix arg, but who would use it.
1259 (interactive) 1258 (interactive)
1580 ;; FSF does similar magic in `isearch-other-meta-char', which 1579 ;; FSF does similar magic in `isearch-other-meta-char', which
1581 ;; is horribly complex. I *hope* what we do works in all 1580 ;; is horribly complex. I *hope* what we do works in all
1582 ;; cases. 1581 ;; cases.
1583 (setq this-command (key-binding (this-command-keys)))) 1582 (setq this-command (key-binding (this-command-keys))))
1584 (t 1583 (t
1585 (isearch-maybe-frob-keyboard-macros) 1584 (labels
1586 (if (and this-command 1585 ((isearch-maybe-frob-keyboard-macros ()
1587 (symbolp this-command) 1586 ;; If the command about to be executed is
1588 (get this-command 'isearch-command)) 1587 ;; `self-insert-command' then change the command to
1589 nil ; then continue. 1588 ;; `isearch-printing-char' instead, meaning add the last-
1590 (isearch-done))))) 1589 ;; typed character to the search string.
1591 1590 ;;
1592 (defun isearch-maybe-frob-keyboard-macros () 1591 ;; If `this-command' is a string or a vector (that is, a
1593 ;; 1592 ;; keyboard macro) and it contains only one command, which is
1594 ;; If the command about to be executed is `self-insert-command' then change 1593 ;; bound to self-insert-command, then do the same thing as for
1595 ;; the command to `isearch-printing-char' instead, meaning add the last- 1594 ;; self-inserting commands: arrange for that character to be
1596 ;; typed character to the search string. 1595 ;; added to the search string. If we didn't do this, then
1597 ;; 1596 ;; typing a compose sequence (a la x-compose.el) would
1598 ;; If `this-command' is a string or a vector (that is, a keyboard macro) 1597 ;; terminate the search and insert the character, instead of
1599 ;; and it contains only one command, which is bound to self-insert-command, 1598 ;; searching for that character.
1600 ;; then do the same thing as for self-inserting commands: arrange for that 1599 ;;
1601 ;; character to be added to the search string. If we didn't do this, then 1600 ;; We should continue doing this, since it's pretty much the
1602 ;; typing a compose sequence (a la x-compose.el) would terminate the search 1601 ;; behavior one would expect, but it will stop being so
1603 ;; and insert the character, instead of searching for that character. 1602 ;; necessary once key-translation- map exists and is used by
1604 ;; 1603 ;; x-compose.el and things like it, since the translation will
1605 ;; We should continue doing this, since it's pretty much the behavior one 1604 ;; have been done before we see the keys.
1606 ;; would expect, but it will stop being so necessary once key-translation- 1605 ;;
1607 ;; map exists and is used by x-compose.el and things like it, since the 1606 (cond ((eq this-command 'self-insert-command)
1608 ;; translation will have been done before we see the keys. 1607 (setq this-command 'isearch-printing-char))
1609 ;; 1608 ((and (or (stringp this-command) (vectorp this-command))
1610 (cond ((eq this-command 'self-insert-command) 1609 (eq (key-binding this-command)
1611 (setq this-command 'isearch-printing-char)) 1610 'self-insert-command))
1612 ((and (or (stringp this-command) (vectorp this-command)) 1611 (setq last-command-event
1613 (eq (key-binding this-command) 'self-insert-command)) 1612 (character-to-event (aref this-command 0))
1614 (setq last-command-event (character-to-event (aref this-command 0)) 1613 last-command-char (and (stringp this-command)
1615 last-command-char (and (stringp this-command) 1614 (aref this-command 0))
1616 (aref this-command 0)) 1615 this-command 'isearch-printing-char))
1617 this-command 'isearch-printing-char)) 1616 ((and (null this-command)
1618 ((and (null this-command) 1617 (eq 'key-press (event-type last-command-event))
1619 (eq 'key-press (event-type last-command-event)) 1618 (current-local-map)
1620 (current-local-map) 1619 (let* ((this-command-keys (this-command-keys))
1621 (let* ((this-command-keys (this-command-keys)) 1620 (this-command-keys (or (lookup-key
1622 (this-command-keys (or (lookup-key function-key-map 1621 function-key-map
1623 this-command-keys) 1622 this-command-keys)
1624 this-command-keys)) 1623 this-command-keys))
1625 (lookup-key (lookup-key global-map this-command-keys))) 1624 (lookup-key (lookup-key global-map
1626 (and (eq 'self-insert-command lookup-key) 1625 this-command-keys)))
1627 ;; The feature here that a modification of 1626 (and (eq 'self-insert-command lookup-key)
1628 ;; last-command-event is respected is undocumented, and 1627 ;; The feature here that a modification
1629 ;; only applies when this-command is nil. The design 1628 ;; of last-command-event is respected is
1630 ;; isn't reat, and I welcome suggestions for a better 1629 ;; undocumented, and only applies when
1631 ;; one. 1630 ;; this-command is nil. The design isn't
1632 (setq last-command-event 1631 ;; great, and I welcome suggestions for a
1633 (find-if 'key-press-event-p this-command-keys 1632 ;; better one.
1634 :from-end t) 1633 (setq last-command-event
1635 last-command-char 1634 (find-if 'key-press-event-p
1636 (event-to-character last-command-event) 1635 this-command-keys
1637 this-command 'isearch-printing-char))))))) 1636 :from-end t)
1638 1637 last-command-char
1638 (event-to-character
1639 last-command-event)
1640 this-command
1641 'isearch-printing-char))))))))
1642 (isearch-maybe-frob-keyboard-macros)
1643 (if (and this-command
1644 (symbolp this-command)
1645 (get this-command 'isearch-command))
1646 nil ; then continue.
1647 (isearch-done))))))
1639 1648
1640 ;;;======================================================== 1649 ;;;========================================================
1641 ;;; Highlighting 1650 ;;; Highlighting
1642 1651
1643 (defvar isearch-extent nil) 1652 (defvar isearch-extent nil)
1644 1653
1645 ;; this face is initialized by faces.el since isearch is preloaded. 1654 ;; this face is initialized by faces.el since isearch is preloaded.
1646 ;(make-face 'isearch) 1655 ;(make-face 'isearch)
1647 1656
1648 (defun isearch-make-extent (begin end)
1649 (let ((x (make-extent begin end (current-buffer))))
1650 ;; make the isearch extent always take precedence over any mouse-
1651 ;; highlighted extents we may be passing through, since isearch, being
1652 ;; modal, is more interesting (there's nothing they could do with a
1653 ;; mouse-highlighted extent while in the midst of a search anyway).
1654 (set-extent-priority x (+ mouse-highlight-priority 2))
1655 (set-extent-face x 'isearch)
1656 (setq isearch-extent x)))
1657
1658 (defun isearch-highlight (begin end) 1657 (defun isearch-highlight (begin end)
1659 (if (null search-highlight) 1658 (labels
1660 nil 1659 ((isearch-make-extent (begin end)
1661 ;; make sure isearch-extent is in the current buffer 1660 (let ((x (make-extent begin end (current-buffer))))
1662 (or (and (extentp isearch-extent) 1661 ;; make the isearch extent always take precedence over any mouse-
1663 (extent-live-p isearch-extent)) 1662 ;; highlighted extents we may be passing through, since isearch,
1664 (isearch-make-extent begin end)) 1663 ;; being modal, is more interesting (there's nothing they could do
1665 (set-extent-endpoints isearch-extent begin end (current-buffer)))) 1664 ;; with a mouse-highlighted extent while in the midst of a search
1665 ;; anyway).
1666 (set-extent-priority x (+ mouse-highlight-priority 2))
1667 (set-extent-face x 'isearch)
1668 (setq isearch-extent x))))
1669 (if (null search-highlight)
1670 nil
1671 ;; make sure isearch-extent is in the current buffer
1672 (or (and (extentp isearch-extent)
1673 (extent-live-p isearch-extent))
1674 (isearch-make-extent begin end))
1675 (set-extent-endpoints isearch-extent begin end (current-buffer)))))
1666 1676
1667 ;; This used to have a TOTALLY flag that also deleted the extent. I 1677 ;; This used to have a TOTALLY flag that also deleted the extent. I
1668 ;; don't think this is necessary any longer, as isearch-highlight can 1678 ;; don't think this is necessary any longer, as isearch-highlight can
1669 ;; simply move the extent to another buffer. The IGNORED argument is 1679 ;; simply move the extent to another buffer. The IGNORED argument is
1670 ;; for the code that calls this function with an argument. --hniksic 1680 ;; for the code that calls this function with an argument. --hniksic