From 4d78a860b9ee2b830d6b9fc67e55c83d516df0c4 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 16 Aug 2007 04:24:57 +0000 Subject: (cl-transform-lambda): Preserve the match-data. --- lisp/emacs-lisp/cl-macs.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 5a79a6424e0..e4a84e44e64 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -266,15 +266,19 @@ its argument list allows full Common Lisp conventions." (nconc (nreverse simple-args) (list '&rest (car (pop bind-lets)))) (nconc (let ((hdr (nreverse header))) - (require 'help-fns) - (cons (help-add-fundoc-usage - (if (stringp (car hdr)) (pop hdr)) - ;; orig-args can contain &cl-defs (an internal CL - ;; thingy that I do not understand), so remove it. - (let ((x (memq '&cl-defs orig-args))) - (if (null x) orig-args - (delq (car x) (remq (cadr x) orig-args))))) - hdr)) + ;; Macro expansion can take place in the middle of + ;; apparently harmless computation, so it should not + ;; touch the match-data. + (save-match-data + (require 'help-fns) + (cons (help-add-fundoc-usage + (if (stringp (car hdr)) (pop hdr)) + ;; orig-args can contain &cl-defs (an internal + ;; CL thingy I don't understand), so remove it. + (let ((x (memq '&cl-defs orig-args))) + (if (null x) orig-args + (delq (car x) (remq (cadr x) orig-args))))) + hdr))) (list (nconc (list 'let* bind-lets) (nreverse bind-forms) body))))))) -- cgit v1.2.3 From 578bbaf55b6a34022dd4c8ce3f2eedc96f4fb08a Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 17 Aug 2007 22:04:18 +0000 Subject: (copyright-update-year, copyright-update) (copyright-fix-years): Fix bug: Handle nil copyright-limit. --- lisp/ChangeLog | 5 +++++ lisp/emacs-lisp/copyright.el | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 69d753121ea..6c64d493124 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2007-08-17 Kimit Yada (tiny change) + + * emacs-lisp/copyright.el (copyright-update-year, copyright-update) + (copyright-fix-years): Fix bug: Handle nil copyright-limit. + 2007-08-17 Bob Rogers (tiny change) * progmode/cperl-mode.el (cperl-look-at-leading-count) diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index ed1d01023fb..d3f0056c413 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -84,7 +84,10 @@ When this is `function', only ask when called non-interactively." (defun copyright-update-year (replace noquery) (when (re-search-forward copyright-regexp - (if copyright-limit (+ (point) copyright-limit)) t) + (if copyright-limit + (+ (point) copyright-limit) + t) + 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 @@ -164,7 +167,10 @@ interactively." "\\(the Free Software Foundation;\ either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\ version \\([0-9]+\\), or (at" - (if copyright-limit (+ (point) copyright-limit)) t) + (if copyright-limit + (+ (point) copyright-limit) + t) + t) (not (string= (match-string 3) copyright-current-gpl-version)) (or noquery (y-or-n-p (concat "Replace GPL version by " @@ -187,7 +193,10 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx." (widen) (goto-char (point-min)) (if (re-search-forward copyright-regexp - (if copyright-limit (+ (point) copyright-limit)) t) + (if copyright-limit + (+ (point) copyright-limit) + t) + t) (let ((s (match-beginning 2)) (e (copy-marker (1+ (match-end 2)))) (p (make-marker)) -- cgit v1.2.3 From c2659333c28521b1ca9263d5a9dae88d853e7292 Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Fri, 17 Aug 2007 22:16:59 +0000 Subject: Revert last change. --- lisp/ChangeLog | 5 ----- lisp/emacs-lisp/copyright.el | 15 +++------------ 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6c64d493124..69d753121ea 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,8 +1,3 @@ -2007-08-17 Kimit Yada (tiny change) - - * emacs-lisp/copyright.el (copyright-update-year, copyright-update) - (copyright-fix-years): Fix bug: Handle nil copyright-limit. - 2007-08-17 Bob Rogers (tiny change) * progmode/cperl-mode.el (cperl-look-at-leading-count) diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index d3f0056c413..ed1d01023fb 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -84,10 +84,7 @@ When this is `function', only ask when called non-interactively." (defun copyright-update-year (replace noquery) (when (re-search-forward copyright-regexp - (if copyright-limit - (+ (point) copyright-limit) - t) - t) + (if copyright-limit (+ (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 @@ -167,10 +164,7 @@ interactively." "\\(the Free Software Foundation;\ either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\ version \\([0-9]+\\), or (at" - (if copyright-limit - (+ (point) copyright-limit) - t) - t) + (if copyright-limit (+ (point) copyright-limit)) t) (not (string= (match-string 3) copyright-current-gpl-version)) (or noquery (y-or-n-p (concat "Replace GPL version by " @@ -193,10 +187,7 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx." (widen) (goto-char (point-min)) (if (re-search-forward copyright-regexp - (if copyright-limit - (+ (point) copyright-limit) - t) - t) + (if copyright-limit (+ (point) copyright-limit)) t) (let ((s (match-beginning 2)) (e (copy-marker (1+ (match-end 2)))) (p (make-marker)) -- cgit v1.2.3 From 30a718e6b77f4f0c422f748dd14ea772b7fa2a1a Mon Sep 17 00:00:00 2001 From: Vinicius Jose Latorre Date: Mon, 20 Aug 2007 15:52:47 +0000 Subject: preceding-sexp --- lisp/ChangeLog | 6 +++ lisp/emacs-lisp/lisp-mode.el | 107 ++++++++++++++++++++++--------------------- 2 files changed, 61 insertions(+), 52 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e5390ccf057..eefd54257a4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2007-08-20 Johannes Weiner (tiny change) + + * emacs-lisp/lisp-mode.el (preceding-sexp): New fun, the code was + extracted from `eval-last-sexp-1'. + (eval-last-sexp-1): Call `preceding-sexp'. + 2007-08-19 Glenn Morris * Makefile.in (custom-deps, finder-data, autoloads, recompile) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d41c0af3d73..8b3e5a71c61 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -537,62 +537,65 @@ If CHAR is not a character, return nil." string)))) +(defun preceding-sexp () + "Return sexp before the point." + (let ((opoint (point)) + ignore-quotes + expr) + (save-excursion + (with-syntax-table emacs-lisp-mode-syntax-table + ;; If this sexp appears to be enclosed in `...' + ;; then ignore the surrounding quotes. + (setq ignore-quotes + (or (eq (following-char) ?\') + (eq (preceding-char) ?\'))) + (forward-sexp -1) + ;; If we were after `?\e' (or similar case), + ;; use the whole thing, not just the `e'. + (when (eq (preceding-char) ?\\) + (forward-char -1) + (when (eq (preceding-char) ??) + (forward-char -1))) + + ;; Skip over `#N='s. + (when (eq (preceding-char) ?=) + (let (labeled-p) + (save-excursion + (skip-chars-backward "0-9#=") + (setq labeled-p (looking-at "\\(#[0-9]+=\\)+"))) + (when labeled-p + (forward-sexp -1)))) + + (save-restriction + ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in + ;; `variable' so that the value is returned, not the + ;; name + (if (and ignore-quotes + (eq (following-char) ?`)) + (forward-char)) + (narrow-to-region (point-min) opoint) + (setq expr (read (current-buffer))) + ;; If it's an (interactive ...) form, it's more + ;; useful to show how an interactive call would + ;; use it. + (and (consp expr) + (eq (car expr) 'interactive) + (setq expr + (list 'call-interactively + (list 'quote + (list 'lambda + '(&rest args) + expr + 'args))))) + expr))))) + + (defun eval-last-sexp-1 (eval-last-sexp-arg-internal) "Evaluate sexp before point; print value in minibuffer. With argument, print output into current buffer." (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))) - (let ((value - (eval (let ((stab (syntax-table)) - (opoint (point)) - ignore-quotes - expr) - (save-excursion - (with-syntax-table emacs-lisp-mode-syntax-table - ;; If this sexp appears to be enclosed in `...' - ;; then ignore the surrounding quotes. - (setq ignore-quotes - (or (eq (following-char) ?\') - (eq (preceding-char) ?\'))) - (forward-sexp -1) - ;; If we were after `?\e' (or similar case), - ;; use the whole thing, not just the `e'. - (when (eq (preceding-char) ?\\) - (forward-char -1) - (when (eq (preceding-char) ??) - (forward-char -1))) - - ;; Skip over `#N='s. - (when (eq (preceding-char) ?=) - (let (labeled-p) - (save-excursion - (skip-chars-backward "0-9#=") - (setq labeled-p (looking-at "\\(#[0-9]+=\\)+"))) - (when labeled-p - (forward-sexp -1)))) - - (save-restriction - ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in - ;; `variable' so that the value is returned, not the - ;; name - (if (and ignore-quotes - (eq (following-char) ?`)) - (forward-char)) - (narrow-to-region (point-min) opoint) - (setq expr (read (current-buffer))) - ;; If it's an (interactive ...) form, it's more - ;; useful to show how an interactive call would - ;; use it. - (and (consp expr) - (eq (car expr) 'interactive) - (setq expr - (list 'call-interactively - (list 'quote - (list 'lambda - '(&rest args) - expr - 'args))))) - expr))))))) - (eval-last-sexp-print-value value)))) + (eval-last-sexp-print-value (eval (preceding-sexp))))) + (defun eval-last-sexp-print-value (value) (let ((unabbreviated (let ((print-length nil) (print-level nil)) -- cgit v1.2.3