Annotation of 43BSD/contrib/emacs/lisp/echistory.el, revision 1.1

1.1     ! root        1: ;; Electric Command History Mode
        !             2: ;; Copyright (C) 1985 Richard M. Stallman and K. Shane Hartman
        !             3: 
        !             4: ;; This file is part of GNU Emacs.
        !             5: 
        !             6: ;; GNU Emacs is distributed in the hope that it will be useful,
        !             7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
        !             8: ;; accepts responsibility to anyone for the consequences of using it
        !             9: ;; or for whether it serves any particular purpose or works at all,
        !            10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
        !            11: ;; License for full details.
        !            12: 
        !            13: ;; Everyone is granted permission to copy, modify and redistribute
        !            14: ;; GNU Emacs, but only under the conditions described in the
        !            15: ;; GNU Emacs General Public License.   A copy of this license is
        !            16: ;; supposed to have been given to you along with GNU Emacs so you
        !            17: ;; can know your rights and responsibilities.  It should be in a
        !            18: ;; file named COPYING.  Among other things, the copyright notice
        !            19: ;; and this notice must be preserved on all copies.
        !            20: 
        !            21: 
        !            22: (require 'electric)                    ; command loop
        !            23: (require 'chistory)                    ; history lister
        !            24: 
        !            25: (defun Electric-command-history-redo-expression (&optional noconfirm)
        !            26:   "Edit current history line in minibuffer and execute result.
        !            27: With prefix argument NOCONFIRM, execute current line as is without editing."
        !            28:   (interactive "P")
        !            29:   (let (todo)
        !            30:     (save-excursion
        !            31:       (set-buffer "*Command History*")
        !            32:       (beginning-of-line)
        !            33:       (setq todo (read (current-buffer)))
        !            34:       (if (boundp 'electric-history-in-progress)
        !            35:          (if todo (throw 'electric-history-quit (list noconfirm todo)))))))
        !            36: 
        !            37: (defconst electric-history-map (make-keymap))
        !            38: (fillarray electric-history-map 'Electric-history-undefined)
        !            39: (define-key electric-history-map "\e" (make-keymap))
        !            40: (fillarray (lookup-key electric-history-map "\e") 'Electric-history-undefined)
        !            41: (define-key electric-history-map "\C-u" 'universal-argument)
        !            42: (define-key electric-history-map " " 'Electric-command-history-redo-expression)
        !            43: (define-key electric-history-map "!" 'Electric-command-history-redo-expression)
        !            44: (define-key electric-history-map "\e\C-x" 'eval-sexp)
        !            45: (define-key electric-history-map "\e\C-d" 'down-list)
        !            46: (define-key electric-history-map "\e\C-u" 'backward-up-list)
        !            47: (define-key electric-history-map "\e\C-b" 'backward-sexp)
        !            48: (define-key electric-history-map "\e\C-f" 'forward-sexp)
        !            49: (define-key electric-history-map "\e\C-a" 'beginning-of-defun)
        !            50: (define-key electric-history-map "\e\C-e" 'end-of-defun)
        !            51: (define-key electric-history-map "\e\C-n" 'forward-list)
        !            52: (define-key electric-history-map "\e\C-p" 'backward-list)
        !            53: (define-key electric-history-map "q" 'Electric-history-quit)
        !            54: (define-key electric-history-map "\C-c" nil)
        !            55: (define-key electric-history-map "\C-c\C-c" 'Electric-history-quit)
        !            56: (define-key electric-history-map "\C-]" 'Electric-history-quit)
        !            57: (define-key electric-history-map "\C-z" 'suspend-emacs)
        !            58: (define-key electric-history-map "\C-h" 'Helper-help)
        !            59: (define-key electric-history-map "?" 'Helper-describe-bindings)
        !            60: (define-key electric-history-map "\e>" 'end-of-buffer)
        !            61: (define-key electric-history-map "\e<" 'beginning-of-buffer)
        !            62: (define-key electric-history-map "\n" 'next-line)
        !            63: (define-key electric-history-map "\r" 'next-line)
        !            64: (define-key electric-history-map "\177" 'previous-line)  
        !            65: (define-key electric-history-map "\C-n" 'next-line)
        !            66: (define-key electric-history-map "\C-p" 'previous-line)
        !            67: (define-key electric-history-map "\ev" 'scroll-down)
        !            68: (define-key electric-history-map "\C-v" 'scroll-up)
        !            69: (define-key electric-history-map "\C-l" 'recenter)
        !            70: (define-key electric-history-map "\e\C-v" 'scroll-other-window)
        !            71: 
        !            72: (defvar electric-command-history-hook nil
        !            73:   "If non-nil, its value is called by  electric-command-history.")
        !            74: 
        !            75: (defun electric-command-history ()
        !            76:   "Major mode for examining and redoing commands from  command-history.
        !            77: The number of command listed is controlled by  list-command-history-max.
        !            78: The command history is filtered by  list-command-history-filter  if non-nil.
        !            79: Combines typeout Command History list window with menu like selection
        !            80: of an expression from the history for re-evaluation in the *original* buffer.
        !            81: 
        !            82: The history displayed is filtered by  list-command-history-filter  if non-nil.
        !            83: 
        !            84: This pops up a window with the Command History listing.  If the very
        !            85: next character typed is Space, the listing is killed and the previous
        !            86: window configuration is restored.  Otherwise, you can browse in the
        !            87: Command History with  Return  moving down and  Delete  moving up, possibly
        !            88: selecting an expression to be redone with Space or quitting with `Q'.
        !            89: 
        !            90: Like Emacs-Lisp Mode except that characters do not insert themselves and
        !            91: Tab and linefeed do not indent.  Instead these commands are provided:
        !            92: Space or !     edit then evaluate current line in history inside
        !            93:                   the ORIGINAL buffer which invoked this mode.
        !            94:                   The previous window configuration is restored
        !            95:                   unless the invoked command changes it.
        !            96: C-c C-c, C-], Q        Quit and restore previous window configuration.
        !            97: LFD, RET       Move to the next line in the history.
        !            98: DEL            Move to the previous line in the history.
        !            99: ?              Provides a complete list of commands.
        !           100: 
        !           101: Calls the value of  electric-command-history-hook  if that is non-nil
        !           102: The Command History listing is recomputed each time this mode is invoked."
        !           103:   (interactive)
        !           104:   (let ((electric-history-in-progress t)
        !           105:        (old-buffer (current-buffer))
        !           106:        (todo))
        !           107:     (unwind-protect
        !           108:        (setq todo
        !           109:              (catch 'electric-history-quit
        !           110:                (save-window-excursion
        !           111:                  (save-window-excursion
        !           112:                    (list-command-history)
        !           113:                    (set-buffer "*Command History*")
        !           114:                    (Command-history-setup 'electric-command-history
        !           115:                                           "Electric History"
        !           116:                                           electric-history-map))
        !           117:                  (Electric-pop-up-window "*Command History*")
        !           118:                  (run-hooks 'electric-command-history-hook)
        !           119:                  (let ((mode-line-format "-- %[%m%]  %M  ----%3p-%-"))
        !           120:                    (if (eobp)
        !           121:                        (progn (ding)
        !           122:                               (message "No command history.")
        !           123:                               (throw 'electric-history-quit nil))
        !           124:                      (let ((Helper-mode-name "Electric History")
        !           125:                            (Helper-major-mode 'electric-command-history)
        !           126:                            (Helper-return-blurb "return to History"))
        !           127:                        (Electric-command-loop 'electric-history-quit "->" t)))))))
        !           128:       (set-buffer "*Command History*")
        !           129:       (Command-history-setup)
        !           130:       (bury-buffer (current-buffer)))
        !           131:     (if (consp todo)
        !           132:        (progn (set-buffer old-buffer)
        !           133:               (if (car todo)
        !           134:                   (apply (car (car (cdr todo))) (cdr (car (cdr todo))))
        !           135:                 (edit-and-eval-command "Redo: " (car (cdr todo))))))))
        !           136: 
        !           137: (defun Electric-history-undefined ()
        !           138:   (interactive)
        !           139:   (ding)
        !           140:   (message "Type C-h for help, ? for commands, C-c to quit, Space to execute")
        !           141:   (sit-for 4))
        !           142: 
        !           143: (defun Electric-history-quit ()
        !           144:   "Quit Electric Command History, restoring previous window configuration."
        !           145:   (interactive)
        !           146:   (if (boundp 'electric-history-in-progress)
        !           147:       (progn (message "")
        !           148:             (throw 'electric-history-quit nil))))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.