diff options
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/cl-indent.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/copyright.el | 44 | ||||
-rw-r--r-- | lisp/emacs-lisp/elp.el | 28 | ||||
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 52 | ||||
-rw-r--r-- | lisp/emacs-lisp/lisp.el | 6 | ||||
-rw-r--r-- | lisp/emacs-lisp/re-builder.el | 45 |
7 files changed, 116 insertions, 63 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index a4ae751cab7..0a12f6fae9f 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2900,7 +2900,7 @@ If FORM is a lambda or a macro, byte-compile it as a function." (byte-defop-compiler char-after 0-1) (byte-defop-compiler set-buffer 1) ;;(byte-defop-compiler set-mark 1) ;; obsolete -(byte-defop-compiler19 forward-word 1) +(byte-defop-compiler19 forward-word 0-1) (byte-defop-compiler19 char-syntax 1) (byte-defop-compiler19 nreverse 1) (byte-defop-compiler19 car-safe 1) diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el index c5e13a4c00f..a203155673c 100644 --- a/lisp/emacs-lisp/cl-indent.el +++ b/lisp/emacs-lisp/cl-indent.el @@ -458,7 +458,7 @@ If nil, indent backquoted lists as data, i.e., like quoted lists." (forward-char 1) (forward-sexp 3) (backward-sexp) - (looking-at ":"))) + (looking-at ":\\|\\sw+"))) '(4 4 (&whole 4 &rest 4) &body) (get 'defun 'common-lisp-indent-function)) path state indent-point sexp-column normal-indent)) diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index 6a95c60f859..3d160f54606 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -54,6 +54,13 @@ The second \\( \\) construct must match the years." :group 'copyright :type 'regexp) +(defcustom copyright-years-regexp + "\\(\\s *\\)\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" + "*Match additional copyright notice years. +The second \\( \\) construct must match the years." + :group 'copyright + :type 'regexp) + (defcustom copyright-query 'function "*If non-nil, ask user before changing copyright. @@ -77,6 +84,23 @@ When this is `function', only ask when called non-interactively." (defun copyright-update-year (replace noquery) (when (re-search-forward copyright-regexp (+ (point) copyright-limit) t) + ;; If the years are continued onto multiple lined + ;; that are marked as comments, skip to the end of the years anyway. + (while (save-excursion + (and (eq (following-char) ?,) + (progn (forward-char 1) t) + (progn (skip-chars-forward " \t") (eolp)) + comment-start-skip + (save-match-data + (forward-line 1) + (and (looking-at comment-start-skip) + (goto-char (match-end 0)))) + (save-match-data + (looking-at copyright-years-regexp)))) + (forward-line 1) + (re-search-forward comment-start-skip) + (re-search-forward copyright-years-regexp)) + ;; Note that `current-time-string' isn't locale-sensitive. (setq copyright-current-year (substring (current-time-string) -4)) (unless (string= (buffer-substring (- (match-end 2) 2) (match-end 2)) @@ -100,26 +124,6 @@ When this is `function', only ask when called non-interactively." (eq (char-after (+ (point) size -2)) ?-))) ;; This is a range so just replace the end part. (delete-char size) - ;; Detect if this is using the following shorthand: - ;; (C) 1993, 94, 95, 1998, 2000, 01, 02, 2003 - (if (and - ;; Check that the last year was 4-chars and same century. - (eq size -4) - (equal (buffer-substring (- (point) 4) (- (point) 2)) - (substring copyright-current-year 0 2)) - ;; Check that there are 2-char years as well. - (save-excursion - (re-search-backward "[^0-9][0-9][0-9][^0-9]" - (line-beginning-position) t)) - ;; Make sure we don't remove the first century marker. - (save-excursion - (forward-char size) - (re-search-backward - (concat (buffer-substring (point) (+ (point) 2)) - "[0-9][0-9]") - (line-beginning-position) t))) - ;; Remove the century marker of the last entry. - (delete-region (- (point) 4) (- (point) 2))) ;; Insert a comma with the preferred number of spaces. (insert (save-excursion diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el index 44400dcaa2c..f8d41f200d2 100644 --- a/lisp/emacs-lisp/elp.el +++ b/lisp/emacs-lisp/elp.el @@ -513,7 +513,7 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]." (numberp elp-report-limit) (< cc elp-report-limit)) nil - (insert symname) + (elp-output-insert-symname symname) (insert-char 32 (+ elp-field-len (- (length symname)) 2)) ;; print stuff out, formatting it nicely (insert callcnt) @@ -525,6 +525,32 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]." (insert atstr)) (insert "\n")))) +(defvar elp-results-symname-map + (let ((map (make-sparse-keymap))) + (define-key map [mouse-2] 'elp-results-jump-to-definition-by-mouse) + (define-key map "\C-m" 'elp-results-jump-to-definition) + map) + "Keymap used on the function name column." ) + +(defun elp-results-jump-to-definition-by-mouse (event) + "Jump to the definition of the function under the place specified by EVENT." + (interactive "e") + (posn-set-point (event-end event)) + (elp-results-jump-to-definition)) + +(defun elp-results-jump-to-definition () + "Jump to the definition of the function under the point." + (interactive) + (find-function (get-text-property (point) 'elp-symname))) + +(defun elp-output-insert-symname (symname) + ;; Insert SYMNAME with text properties. + (insert (propertize symname + 'elp-symname (intern symname) + 'keymap elp-results-symname-map + 'mouse-face 'highlight + 'help-echo (substitute-command-keys "\\{elp-results-symname-map}")))) + ;;;###autoload (defun elp-results () "Display current profiling results. diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d471ad79538..e2aac327ddc 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -363,7 +363,7 @@ if that value is non-nil." (when (stringp default) (if (string-match ":+" default) (substring default (match-end 0)) - default)))) + default)))) ;; Used in old LispM code. (defalias 'common-lisp-mode 'lisp-mode) @@ -459,21 +459,37 @@ alternative printed representations that can be displayed." If CHAR is not a character, return nil." (and (integerp char) (eventp char) - (let ((c (event-basic-type char))) - (concat - "?" - (mapconcat - (lambda (modif) - (cond ((eq modif 'super) "\\s-") - (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-)))) - (event-modifiers char) "") - (cond - ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c)) - ((eq c 127) "\\C-?") - (t - (condition-case nil - (string c) - (error nil)))))))) + (let ((c (event-basic-type char)) + (mods (event-modifiers char)) + string) + ;; Prevent ?A from turning into ?\S-a. + (if (and (memq 'shift mods) + (zerop (logand char ?\S-\^@)) + (not (let ((case-fold-search nil)) + (char-equal c (upcase c))))) + (setq c (upcase c) mods nil)) + ;; What string are we considering using? + (condition-case nil + (setq string + (concat + "?" + (mapconcat + (lambda (modif) + (cond ((eq modif 'super) "\\s-") + (t (string ?\\ (upcase (aref (symbol-name modif) 0)) ?-)))) + mods "") + (cond + ((memq c '(?\; ?\( ?\) ?\{ ?\} ?\[ ?\] ?\" ?\' ?\\)) (string ?\\ c)) + ((eq c 127) "\\C-?") + (t + (string c))))) + (error nil)) + ;; Verify the string reads a CHAR, not to some other character. + ;; If it doesn't, return nil instead. + (and string + (= (car (read-from-string string)) char) + string)))) + (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in minibuffer. @@ -555,13 +571,15 @@ With argument, print output into current buffer." )))) +(defvar eval-last-sexp-fake-value (make-symbol "t")) + (defun eval-last-sexp (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in minibuffer. Interactively, with prefix argument, print output into current buffer." (interactive "P") (if (null eval-expression-debug-on-error) (eval-last-sexp-1 eval-last-sexp-arg-internal) - (let ((old-value (make-symbol "t")) new-value value) + (let ((old-value eval-last-sexp-fake-value) new-value value) (let ((debug-on-error old-value)) (setq value (eval-last-sexp-1 eval-last-sexp-arg-internal)) (setq new-value debug-on-error)) diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el index 25fde86cd96..46d3d2625a1 100644 --- a/lisp/emacs-lisp/lisp.el +++ b/lisp/emacs-lisp/lisp.el @@ -176,7 +176,8 @@ If variable `beginning-of-defun-function' is non-nil, its value is called as a function to find the defun's beginning." (interactive "p") (and (eq this-command 'beginning-of-defun) - (or (eq last-command 'beginning-of-defun) (push-mark))) + (or inhibit-mark-movement (eq last-command 'beginning-of-defun) + (push-mark))) (and (beginning-of-defun-raw arg) (progn (beginning-of-line) t))) @@ -226,7 +227,8 @@ If variable `end-of-defun-function' is non-nil, its value is called as a function to find the defun's end." (interactive "p") (and (eq this-command 'end-of-defun) - (or (eq last-command 'end-of-defun) (push-mark))) + (or inhibit-mark-movement (eq last-command 'end-of-defun) + (push-mark))) (if (or (null arg) (= arg 0)) (setq arg 1)) (if end-of-defun-function (if (> arg 0) diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el index c6112c4a105..77a12167c30 100644 --- a/lisp/emacs-lisp/re-builder.el +++ b/lisp/emacs-lisp/re-builder.el @@ -45,7 +45,7 @@ ;; call `reb-force-update' ("\C-c\C-u") which should reveal the error. ;; The target buffer can be changed with `reb-change-target-buffer' -;; ("\C-c\C-b"). Changing the target buffer automatically removes +;; ("\C-c\C-b"). Changing the target buffer automatically removes ;; the overlays from the old buffer and displays the new one in the ;; target window. @@ -135,6 +135,7 @@ Can either be `read', `string', `sregex' or `lisp-re'." (const :tag "String syntax" string) (const :tag "`sregex' syntax" sregex) (const :tag "`lisp-re' syntax" lisp-re) + (const :tag "`rx' syntax" rx) (value: string))) (defcustom reb-auto-match-limit 200 @@ -228,22 +229,20 @@ Except for Lisp syntax this is the same as `reb-regexp'.") "Buffer to use for the RE Builder.") ;; Define the local "\C-c" keymap -(defvar reb-mode-map nil +(defvar reb-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-c" 'reb-toggle-case) + (define-key map "\C-c\C-q" 'reb-quit) + (define-key map "\C-c\C-w" 'reb-copy) + (define-key map "\C-c\C-s" 'reb-next-match) + (define-key map "\C-c\C-r" 'reb-prev-match) + (define-key map "\C-c\C-i" 'reb-change-syntax) + (define-key map "\C-c\C-e" 'reb-enter-subexp-mode) + (define-key map "\C-c\C-b" 'reb-change-target-buffer) + (define-key map "\C-c\C-u" 'reb-force-update) + map) "Keymap used by the RE Builder.") -(if (not reb-mode-map) - (progn - (setq reb-mode-map (make-sparse-keymap)) - (define-key reb-mode-map "\C-c\C-c" 'reb-toggle-case) - (define-key reb-mode-map "\C-c\C-q" 'reb-quit) - (define-key reb-mode-map "\C-c\C-w" 'reb-copy) - (define-key reb-mode-map "\C-c\C-s" 'reb-next-match) - (define-key reb-mode-map "\C-c\C-r" 'reb-prev-match) - (define-key reb-mode-map "\C-c\C-i" 'reb-change-syntax) - (define-key reb-mode-map "\C-c\C-e" 'reb-enter-subexp-mode) - (define-key reb-mode-map "\C-c\C-b" 'reb-change-target-buffer) - (define-key reb-mode-map "\C-c\C-u" 'reb-force-update))) - (defun reb-mode () "Major mode for interactively building Regular Expressions. \\{reb-mode-map}" @@ -261,7 +260,9 @@ Except for Lisp syntax this is the same as `reb-regexp'.") (cond ((eq reb-re-syntax 'lisp-re) ; Pull in packages (require 'lisp-re)) ; as needed ((eq reb-re-syntax 'sregex) ; sregex is not autoloaded - (require 'sregex))) ; right now.. + (require 'sregex)) ; right now.. + ((eq reb-re-syntax 'rx) ; rx-to-string is autoloaded + (require 'rx))) ; require rx anyway (reb-mode-common)) ;; Use the same "\C-c" keymap as `reb-mode' and use font-locking from @@ -320,7 +321,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.") (defsubst reb-lisp-syntax-p () "Return non-nil if RE Builder uses a Lisp syntax." - (memq reb-re-syntax '(lisp-re sregex))) + (memq reb-re-syntax '(lisp-re sregex rx))) (defmacro reb-target-binding (symbol) "Return binding for SYMBOL in the RE Builder target buffer." @@ -364,7 +365,7 @@ Except for Lisp syntax this is the same as `reb-regexp'.") (reb-update-modestring)))) (defun reb-force-update () - "Forces an update in the RE Builder target window without a match limit." + "Force an update in the RE Builder target window without a match limit." (interactive) (let ((reb-auto-match-limit nil)) @@ -466,10 +467,10 @@ Optional argument SYNTAX must be specified if called non-interactively." (list (intern (completing-read "Select syntax: " (mapcar (lambda (el) (cons (symbol-name el) 1)) - '(read string lisp-re sregex)) + '(read string lisp-re sregex rx)) nil t (symbol-name reb-re-syntax))))) - (if (memq syntax '(read string lisp-re sregex)) + (if (memq syntax '(read string lisp-re sregex rx)) (let ((buffer (get-buffer reb-buffer))) (setq reb-re-syntax syntax) (if buffer @@ -604,6 +605,8 @@ optional fourth argument FORCE is non-nil." (lre-compile-string (eval (car (read-from-string re))))) ((eq reb-re-syntax 'sregex) (apply 'sregex (eval (car (read-from-string re))))) + ((eq reb-re-syntax 'rx) + (rx-to-string (eval (car (read-from-string re))))) (t re))) (defun reb-update-regexp () @@ -670,7 +673,7 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions." (overlay-put overlay 'priority i))) (setq i (1+ i)))))) (let ((count (if subexp submatches matches))) - (message"%s %smatch%s%s" + (message "%s %smatch%s%s" (if (= 0 count) "No" (int-to-string count)) (if subexp "subexpression " "") (if (= 1 count) "" "es") |