(defun delete-indentation (&optional arg)
"Join this line to previous and fix up whitespace at join.
+If there is a fill prefix, delete it from the beginning of this line.
With argument, join this line to following line."
(interactive "*P")
(beginning-of-line)
(if (eq (preceding-char) ?\n)
(progn
(delete-region (point) (1- (point)))
+ ;; If the second line started with the fill prefix,
+ ;; delete the prefix.
+ (if (and fill-prefix
+ (string= fill-prefix
+ (buffer-substring (point)
+ (+ (point) (length fill-prefix)))))
+ (delete-region (point) (+ (point) (length fill-prefix))))
(fixup-whitespace))))
(defun fixup-whitespace ()
;; for the sake of completion of names like eval-region, eval-current-buffer.
(defun eval-expression (expression)
"Evaluate EXPRESSION and print value in minibuffer.
-Value is also consed on to front of variable values 's value."
+Value is also consed on to front of the variable `values'."
(interactive "xEval: ")
(setq values (cons (eval expression) values))
(prin1 (car values) t))
(setq command-history (cons command command-history)))
(eval command)))
-;; (defvar repeat-complex-command nil)
-
-(defvar minibuffer-history nil)
-(defvar minibuffer-history-sexp-flag nil)
-(setq minibuffer-history-variable 'minibuffer-history)
-(setq minibuffer-history-position nil)
-
-(define-key minibuffer-local-map "\en" 'next-history-element)
-(define-key minibuffer-local-ns-map "\en" 'next-history-element)
-(define-key minibuffer-local-ns-map "\en" 'next-history-element)
-(define-key minibuffer-local-completion-map "\en" 'next-history-element)
-(define-key minibuffer-local-completion-map "\en" 'next-history-element)
-(define-key minibuffer-local-must-match-map "\en" 'next-history-element)
-
-(define-key minibuffer-local-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-ns-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-completion-map "\ep" 'previous-history-element)
-(define-key minibuffer-local-must-match-map "\ep" 'previous-history-element)
-
(defun repeat-complex-command (arg)
"Edit and re-evaluate last complex command, or ARGth from last.
A complex command is one which used the minibuffer.
(let ((elt (nth (1- arg) command-history))
(minibuffer-history-position arg)
(minibuffer-history-sexp-flag t)
- (repeat-complex-command-flag t)
newcmd)
(if elt
(let ((minibuffer-history-variable ' command-history))
(setq command-history (cons newcmd command-history)))
(eval newcmd))
(ding))))
+\f
+(defvar minibuffer-history nil)
+(defvar minibuffer-history-sexp-flag nil)
+(setq minibuffer-history-variable 'minibuffer-history)
+(setq minibuffer-history-position nil)
+
+(mapcar
+ (function (lambda (key-and-command)
+ (mapcar
+ (function (lambda (keymap)
+ (define-key (symbol-value keymap)
+ (car key-and-command)
+ (cdr key-and-command))))
+ '(minibuffer-local-map
+ minibuffer-local-ns-map
+ minibuffer-local-completion-map
+ minibuffer-local-must-match-map))))
+ '(("\en" . next-history-element) ([next] . next-history-element)
+ ("\ep" . previous-history-element) ([prior] . previous-history-element)
+ ("\er" . previous-matching-history-element)
+ ("\es" . next-matching-history-element)))
+
+(put 'previous-matching-history-element 'enable-recursive-minibuffers t)
+(defun previous-matching-history-element (regexp n)
+ (interactive "sPrevious element matching (regexp): \np")
+ (let ((history (symbol-value minibuffer-history-variable))
+ prevpos
+ (pos minibuffer-history-position))
+ (while (/= n 0)
+ (setq prevpos pos)
+ (setq pos (min (max 1 (+ pos (if (< n 0) -1 1))) (length history)))
+ (if (= pos prevpos)
+ (error (if (= pos 1)
+ "No later matching history item"
+ "No earlier matching history item")))
+ (if (string-match regexp
+ (if minibuffer-history-sexp-flag
+ (prin1-to-string (nth (1- pos) history))
+ (nth (1- pos) history)))
+ (setq n (+ n (if (< n 0) -1 1)))))
+ (setq minibuffer-history-position pos)
+ (erase-buffer)
+ (let ((elt (nth (1- pos) history)))
+ (insert (if minibuffer-history-sexp-flag
+ (prin1-to-string elt)
+ elt)))
+ (goto-char (point-min))))
+
+(put 'next-matching-history-element 'enable-recursive-minibuffers t)
+(defun next-matching-history-element (regexp n)
+ (interactive "sNext element matching (regexp): \np")
+ (previous-matching-history-element regexp (- n)))
(defun next-history-element (n)
"Insert the next element of the minibuffer history into the minibuffer."
(length (symbol-value minibuffer-history-variable)))))
(if (= minibuffer-history-position narg)
(error (if (= minibuffer-history-position 1)
- "No following item in minibuffer history"
- "No preceding item in minibuffer history"))
+ "End of history; no next item"
+ "Beginning of history; no preceding item"))
(erase-buffer)
(setq minibuffer-history-position narg)
(let ((elt (nth (1- minibuffer-history-position)
(defun previous-history-element (n)
"Inserts the previous element of `command-history' into the minibuffer."
(interactive "p")
-;; (if repeat-complex-command-flag
(next-history-element (- n)))
-;; (repeat-complex-command 1)))
-
+\f
(defun goto-line (arg)
"Goto line ARG, counting from line 1 at beginning of buffer."
(interactive "NGoto line: ")
(let ((interprogram-paste (and (= n 0)
interprogram-paste-function
(funcall interprogram-paste-function))))
-;;; RMS: Turn off the interprogram paste feature
-;;; because currently it is wedged: it is always
-;;; giving a null string.
- (setq interprogram-paste nil)
(if interprogram-paste
(progn
;; Disable the interprogram cut function when we add the new