all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Tino Calancha <tino.calancha@gmail.com>
Cc: 24627@debbugs.gnu.org
Subject: bug#24627: 24.5; (thing-at-point 'list) may return a non-empty string without a list
Date: Tue, 11 Oct 2016 20:40:12 +0200	[thread overview]
Message-ID: <781dea94-9f15-8bd2-66f5-055b55497471@easy-emacs.de> (raw)
In-Reply-To: <878ttu97e3.fsf@gmail.com>



On 11.10.2016 18:29, Tino Calancha wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> With
>>
>> (defun foo ())
>>
>> at first open paren
>>
>> M-: (thing-at-point 'list t) RET
>>
>> returns the whole thing, right.
>>
>> But at second open paren returns the whole function too - where it
>> should return the empty arg-list
> Following patch do the right thing in my example and your example.
> Feel free to check it with some other examples that you may have:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>  From dc2703a43a7b5dae60f7e88805971472253d4600 Mon Sep 17 00:00:00 2001
> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 12 Oct 2016 01:16:52 +0900
> Subject: [PATCH] (thing-at-point 'list) return nil if no list at point
>
> * lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point):
> Check first if we are at the beginning of a top-level sexp (Bug#24627).
> Escape '[' and ']' in doc string.
> ---
>   lisp/thingatpt.el | 22 +++++++++-------------
>   1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
> index 6d1014b..acacff2 100644
> --- a/lisp/thingatpt.el
> +++ b/lisp/thingatpt.el
> @@ -219,22 +219,18 @@ 'beginning-of-sexp
>   
>   (defun thing-at-point-bounds-of-list-at-point ()
>     "Return the bounds of the list at point.
> -[Internal function used by `bounds-of-thing-at-point'.]"
> +\[Internal function used by `bounds-of-thing-at-point'.\]"
>     (save-excursion
>       (let ((opoint (point))
> -	  (beg (ignore-errors
> -		 (up-list -1)
> -		 (point))))
> +          (beg (if (looking-at-p "(")
> +                   (point)
> +                 (ignore-errors
> +                   (up-list -1)
> +                   (point)))))
>         (ignore-errors
> -	(if beg
> -	    (progn (forward-sexp)
> -		   (cons beg (point)))
> -	  ;; Are we are at the beginning of a top-level sexp?
> -	  (forward-sexp)
> -	  (let ((end (point)))
> -	    (backward-sexp)
> -	    (if (>= opoint (point))
> -		(cons opoint end))))))))
> +        (when beg
> +          (forward-sexp)
> +          (cons beg (point)))))))
>   
>   ;; Defuns
>   

Hmm, what if cursor is inside a string or comment?

BTW "list" might be more universal if understood syntactically
What about writing

(eq 4 (car (syntax-after (point))))






  parent reply	other threads:[~2016-10-11 18:40 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06  9:43 bug#24627: 24.5; (thing-at-point 'list) may return a non-empty string without a list Tino Calancha
2016-10-07  6:42 ` Andreas Röhler
2016-10-11  3:42   ` Tino Calancha
2016-10-11 15:37     ` Andreas Röhler
2016-10-11 16:29       ` Tino Calancha
2016-10-11 16:47         ` Noam Postavsky
2016-10-11 17:09           ` Tino Calancha
2016-10-11 17:15             ` Noam Postavsky
2016-10-11 17:21               ` Tino Calancha
2016-10-11 17:16         ` bug#24627: "internal" designation [was: bug#24627: 24.5; (thing-at-point 'list) ...] Drew Adams
2016-10-11 17:21           ` Drew Adams
2016-10-11 17:20         ` Drew Adams
2016-10-11 19:13           ` Andreas Röhler
2016-10-12  5:11             ` "internal" designation [ Tino Calancha
2016-10-12  6:47               ` Andreas Röhler
2016-10-11 18:40         ` Andreas Röhler [this message]
2016-10-12  4:58           ` bug#24627: 24.5; (thing-at-point 'list) may return a non-empty string without a list Tino Calancha
2016-10-12  7:10             ` Andreas Röhler
2016-10-13  8:50               ` Tino Calancha
2016-10-13 17:50                 ` Andreas Röhler
2016-10-15  9:44                   ` Tino Calancha
2016-10-15 10:26                     ` Andreas Röhler

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=781dea94-9f15-8bd2-66f5-055b55497471@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=24627@debbugs.gnu.org \
    --cc=tino.calancha@gmail.com \
    /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.