From: Vinicius Jose Latorre <viniciusjl@ig.com.br>
To: rms@gnu.org
Cc: emacs-devel@gnu.org
Subject: Re: [hannes@saeurebad.de: [PATCH] Extract last-sexp from eval-last-sexp-1]
Date: Mon, 20 Aug 2007 12:56:18 -0300 [thread overview]
Message-ID: <46C9B9A2.5000205@ig.com.br> (raw)
In-Reply-To: <E1IN8zb-0001Qk-5D@fencepost.gnu.org>
Richard Stallman wrote:
> Would someone please install this tiny change, but rename the new
> function to `preceding-sexp'?
>
Done in trunk and Emacs 22 branch.
> ------- Start of forwarded message -------
> X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY
> autolearn=failed version=3.1.0
> Date: Mon, 20 Aug 2007 00:08:06 +0200
> From: Johannes Weiner <hannes@saeurebad.de>
> To: emacs-devel@gnu.org
> Mail-Followup-To: emacs-devel@gnu.org
> MIME-Version: 1.0
> Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi"
> Content-Disposition: inline
> Subject: [PATCH] Extract last-sexp from eval-last-sexp-1
>
>
> - --Qxx1br4bt0+wmkIi
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
>
> Hi Emacs-hackers,
>
> here is a patch that extracts last-sexp from already existing code so that one
> can use last-sexp for other purposes too.
>
> Note: I ripped out the let-binding of `stap' in the original code because it
> looked stale. Please correct me if I am wrong.
>
> Thank you all!
>
> Hannes
>
> - --Qxx1br4bt0+wmkIi
> Content-Type: text/x-diff; charset=us-ascii
> Content-Disposition: inline; filename="emacs-extract-last-sexp.patch"
>
> diff -Naur emacs.orig/lisp/emacs-lisp/lisp-mode.el emacs/lisp/emacs-lisp/lisp-mode.el
> - --- emacs.orig/lisp/emacs-lisp/lisp-mode.el 2007-08-20 00:00:43.000000000 +0200
> +++ emacs/lisp/emacs-lisp/lisp-mode.el 2007-08-20 00:00:58.000000000 +0200
> @@ -538,63 +538,63 @@
> (= (car (read-from-string string)) char)
> string))))
>
> +(defun last-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 (last-sexp)))))
>
> (defun eval-last-sexp-print-value (value)
> (let ((unabbreviated (let ((print-length nil) (print-level nil))
>
> - --Qxx1br4bt0+wmkIi
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
>
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-devel
> - --Qxx1br4bt0+wmkIi--
> ------- End of forwarded message ------
prev parent reply other threads:[~2007-08-20 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 15:16 [hannes@saeurebad.de: [PATCH] Extract last-sexp from eval-last-sexp-1] Richard Stallman
2007-08-20 15:56 ` Vinicius Jose Latorre [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46C9B9A2.5000205@ig.com.br \
--to=viniciusjl@ig.com.br \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.