Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/lisp/isearch-mode.el Fri May 04 21:12:51 2012 +0100 +++ b/lisp/isearch-mode.el Sat May 05 18:42:00 2012 +0100 @@ -1220,38 +1220,37 @@ ;;=========================================================== ;; Search Ring -(defun isearch-ring-adjust1 (advance) - ;; Helper for isearch-ring-adjust - (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) - (length (length ring)) - (yank-pointer-name (if isearch-regexp - 'regexp-search-ring-yank-pointer - 'search-ring-yank-pointer)) - (yank-pointer (eval yank-pointer-name))) - (if (zerop length) - () - (set yank-pointer-name - (setq yank-pointer - (mod (+ (or yank-pointer 0) - ;; XEmacs change - (if advance -1 (if yank-pointer 1 0))) - length))) - (setq isearch-string (nth yank-pointer ring) - isearch-message (mapconcat 'isearch-text-char-description - isearch-string ""))))) - (defun isearch-ring-adjust (advance) ;; Helper for isearch-ring-advance and isearch-ring-retreat ; (if (cdr isearch-cmds) ;; is there more than one thing on stack? ; (isearch-pop-state)) - (isearch-ring-adjust1 advance) - (if search-ring-update - (progn - (isearch-search) - (isearch-update)) - (isearch-edit-string) - ) - (isearch-push-state)) + (labels + ((isearch-ring-adjust1 (advance) + ;; Helper for isearch-ring-adjust + (let* ((ring (if isearch-regexp regexp-search-ring search-ring)) + (length (length ring)) + (yank-pointer-name (if isearch-regexp + 'regexp-search-ring-yank-pointer + 'search-ring-yank-pointer)) + (yank-pointer (symbol-value yank-pointer-name))) + (if (zerop length) + () + (set yank-pointer-name + (setq yank-pointer + (mod (+ (or yank-pointer 0) + ;; XEmacs change + (if advance -1 (if yank-pointer 1 0))) + length))) + (setq isearch-string (nth yank-pointer ring) + isearch-message (mapconcat 'isearch-text-char-description + isearch-string "")))))) + (isearch-ring-adjust1 advance) + (if search-ring-update + (progn + (isearch-search) + (isearch-update)) + (isearch-edit-string)) + (isearch-push-state))) (defun isearch-ring-advance () "Advance to the next search string in the ring." @@ -1582,60 +1581,70 @@ ;; cases. (setq this-command (key-binding (this-command-keys)))) (t - (isearch-maybe-frob-keyboard-macros) - (if (and this-command - (symbolp this-command) - (get this-command 'isearch-command)) - nil ; then continue. - (isearch-done))))) - -(defun isearch-maybe-frob-keyboard-macros () - ;; - ;; If the command about to be executed is `self-insert-command' then change - ;; the command to `isearch-printing-char' instead, meaning add the last- - ;; typed character to the search string. - ;; - ;; If `this-command' is a string or a vector (that is, a keyboard macro) - ;; and it contains only one command, which is bound to self-insert-command, - ;; then do the same thing as for self-inserting commands: arrange for that - ;; character to be added to the search string. If we didn't do this, then - ;; typing a compose sequence (a la x-compose.el) would terminate the search - ;; and insert the character, instead of searching for that character. - ;; - ;; We should continue doing this, since it's pretty much the behavior one - ;; would expect, but it will stop being so necessary once key-translation- - ;; map exists and is used by x-compose.el and things like it, since the - ;; translation will have been done before we see the keys. - ;; - (cond ((eq this-command 'self-insert-command) - (setq this-command 'isearch-printing-char)) - ((and (or (stringp this-command) (vectorp this-command)) - (eq (key-binding this-command) 'self-insert-command)) - (setq last-command-event (character-to-event (aref this-command 0)) - last-command-char (and (stringp this-command) - (aref this-command 0)) - this-command 'isearch-printing-char)) - ((and (null this-command) - (eq 'key-press (event-type last-command-event)) - (current-local-map) - (let* ((this-command-keys (this-command-keys)) - (this-command-keys (or (lookup-key function-key-map - this-command-keys) - this-command-keys)) - (lookup-key (lookup-key global-map this-command-keys))) - (and (eq 'self-insert-command lookup-key) - ;; The feature here that a modification of - ;; last-command-event is respected is undocumented, and - ;; only applies when this-command is nil. The design - ;; isn't reat, and I welcome suggestions for a better - ;; one. - (setq last-command-event - (find-if 'key-press-event-p this-command-keys - :from-end t) - last-command-char - (event-to-character last-command-event) - this-command 'isearch-printing-char))))))) - + (labels + ((isearch-maybe-frob-keyboard-macros () + ;; If the command about to be executed is + ;; `self-insert-command' then change the command to + ;; `isearch-printing-char' instead, meaning add the last- + ;; typed character to the search string. + ;; + ;; If `this-command' is a string or a vector (that is, a + ;; keyboard macro) and it contains only one command, which is + ;; bound to self-insert-command, then do the same thing as for + ;; self-inserting commands: arrange for that character to be + ;; added to the search string. If we didn't do this, then + ;; typing a compose sequence (a la x-compose.el) would + ;; terminate the search and insert the character, instead of + ;; searching for that character. + ;; + ;; We should continue doing this, since it's pretty much the + ;; behavior one would expect, but it will stop being so + ;; necessary once key-translation- map exists and is used by + ;; x-compose.el and things like it, since the translation will + ;; have been done before we see the keys. + ;; + (cond ((eq this-command 'self-insert-command) + (setq this-command 'isearch-printing-char)) + ((and (or (stringp this-command) (vectorp this-command)) + (eq (key-binding this-command) + 'self-insert-command)) + (setq last-command-event + (character-to-event (aref this-command 0)) + last-command-char (and (stringp this-command) + (aref this-command 0)) + this-command 'isearch-printing-char)) + ((and (null this-command) + (eq 'key-press (event-type last-command-event)) + (current-local-map) + (let* ((this-command-keys (this-command-keys)) + (this-command-keys (or (lookup-key + function-key-map + this-command-keys) + this-command-keys)) + (lookup-key (lookup-key global-map + this-command-keys))) + (and (eq 'self-insert-command lookup-key) + ;; The feature here that a modification + ;; of last-command-event is respected is + ;; undocumented, and only applies when + ;; this-command is nil. The design isn't + ;; great, and I welcome suggestions for a + ;; better one. + (setq last-command-event + (find-if 'key-press-event-p + this-command-keys + :from-end t) + last-command-char + (event-to-character + last-command-event) + this-command + 'isearch-printing-char)))))))) + (isearch-maybe-frob-keyboard-macros) + (if (and this-command + (symbolp this-command) + (get this-command 'isearch-command)) + nil ; then continue. + (isearch-done)))))) ;;;======================================================== ;;; Highlighting @@ -1645,24 +1654,25 @@ ;; this face is initialized by faces.el since isearch is preloaded. ;(make-face 'isearch) -(defun isearch-make-extent (begin end) - (let ((x (make-extent begin end (current-buffer)))) - ;; make the isearch extent always take precedence over any mouse- - ;; highlighted extents we may be passing through, since isearch, being - ;; modal, is more interesting (there's nothing they could do with a - ;; mouse-highlighted extent while in the midst of a search anyway). - (set-extent-priority x (+ mouse-highlight-priority 2)) - (set-extent-face x 'isearch) - (setq isearch-extent x))) - (defun isearch-highlight (begin end) - (if (null search-highlight) - nil - ;; make sure isearch-extent is in the current buffer - (or (and (extentp isearch-extent) - (extent-live-p isearch-extent)) - (isearch-make-extent begin end)) - (set-extent-endpoints isearch-extent begin end (current-buffer)))) + (labels + ((isearch-make-extent (begin end) + (let ((x (make-extent begin end (current-buffer)))) + ;; make the isearch extent always take precedence over any mouse- + ;; highlighted extents we may be passing through, since isearch, + ;; being modal, is more interesting (there's nothing they could do + ;; with a mouse-highlighted extent while in the midst of a search + ;; anyway). + (set-extent-priority x (+ mouse-highlight-priority 2)) + (set-extent-face x 'isearch) + (setq isearch-extent x)))) + (if (null search-highlight) + nil + ;; make sure isearch-extent is in the current buffer + (or (and (extentp isearch-extent) + (extent-live-p isearch-extent)) + (isearch-make-extent begin end)) + (set-extent-endpoints isearch-extent begin end (current-buffer))))) ;; This used to have a TOTALLY flag that also deleted the extent. I ;; don't think this is necessary any longer, as isearch-highlight can