GNU bug report logs - #29499
25.3; bounds-of-thing-at-point for nested s-expressions?

Previous Next

Package: emacs;

Reported by: James Nguyen <jamesn <at> fastmail.com>

Date: Wed, 29 Nov 2017 07:55:01 UTC

Severity: minor

Tags: fixed

Found in version 25.3

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29499 in the body.
You can then email your comments to 29499 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29499; Package emacs. (Wed, 29 Nov 2017 07:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to James Nguyen <jamesn <at> fastmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 29 Nov 2017 07:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: James Nguyen <jamesn <at> fastmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.3; bounds-of-thing-at-point for nested s-expressions?
Date: Tue, 28 Nov 2017 23:54:17 -0800
I’m curious if this is expected?

;; (bounds-of-thing-at-point ‘sexp)

Cursor is after ending paren of line.

(+ 1 1) ;; M-: (bounds-of-thing-at-point ‘sexp) -> returns (x . y)

(+ 1 1
   (+ 1 1) ;; M-: (bounds-of-thing-at-point ‘sexp) -> returns nil
   )



In GNU Emacs 25.3.1 (x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version 10.12.6 (Build 16G29))
 of 2017-09-14 built on d12frosted.local
Windowing system distributor 'Apple', version 10.3.1504
Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs-plus/25.3/share/info/emacs
 --prefix=/usr/local/Cellar/emacs-plus/25.3 --with-xml2 --without-dbus
 --with-gnutls --with-imagemagick --with-modules --with-rsvg --with-ns
 --disable-ns-self-contained'

Configured features:
JPEG RSVG IMAGEMAGICK NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS MODULES

Important settings:
  value of $LC_ALL: C
  value of $LC_COLLATE: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark activated
C-h C-g is undefined
Quit
Starting new Ispell process /usr/local/bin/ispell with default dictionary...
Spell-checking *scratch* using ispell with default dictionary...
Spell-checking suspended; use C-u M-$ to resume
Type C-x 1 to delete the help window.
nil [2 times]
(179 . 194)
nil
(203 . 210)

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired format-spec rfc822 mml
mml-sec password-cache epg epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra
help-fns help-mode easymenu cl-loaddefs pcase cl-lib ispell thingatpt
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 199060 6158)
 (symbols 48 20009 0)
 (miscs 40 66 230)
 (strings 32 16544 6055)
 (string-bytes 1 474807)
 (vectors 16 33203)
 (vector-slots 8 653079 5045)
 (floats 8 161 225)
 (intervals 56 240 18)
 (buffers 976 18))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29499; Package emacs. (Sun, 14 Jul 2019 18:43:02 GMT) Full text and rfc822 format available.

Message #8 received at 29499 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: James Nguyen <jamesn <at> fastmail.com>
Cc: 29499 <at> debbugs.gnu.org
Subject: Re: bug#29499: 25.3; bounds-of-thing-at-point for nested
 s-expressions?
Date: Sun, 14 Jul 2019 20:42:52 +0200
James Nguyen <jamesn <at> fastmail.com> writes:

> I’m curious if this is expected?
>
> ;; (bounds-of-thing-at-point ‘sexp)
>
> Cursor is after ending paren of line.
>
> (+ 1 1) ;; M-: (bounds-of-thing-at-point ‘sexp) -> returns (x . y)
>
> (+ 1 1
>    (+ 1 1) ;; M-: (bounds-of-thing-at-point ‘sexp) -> returns nil
>    )

The problem is that thingatpt wants to go to the end of the current
sexp, and uses forward-sexp for that.  The amusing thing about
forward-sexp is that it won't error if there's nothing to advance to
(like at the end of a buffer), but if it hits a ")" immediately, it
signals an error, making bounds-of-thing-at-point return nil.

The patch below fixes the problem, but I'm not very familiar with the
thingatpt code.  Does anybody think this makes sense?

diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 60a20e2d18..319f4b2cf8 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -194,7 +194,9 @@ thing-at-point--end-of-sexp
     (if (or (eq char-syntax ?\))
 	    (and (eq char-syntax ?\") (nth 3 (syntax-ppss))))
 	(forward-char 1)
-      (forward-sexp 1))))
+      (condition-case _
+          (forward-sexp 1)
+        (scan-error nil)))))
 
 (define-obsolete-function-alias 'end-of-sexp
   'thing-at-point--end-of-sexp "25.1"


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29499; Package emacs. (Fri, 26 Jul 2019 06:01:01 GMT) Full text and rfc822 format available.

Message #11 received at 29499 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: James Nguyen <jamesn <at> fastmail.com>
Cc: 29499 <at> debbugs.gnu.org
Subject: Re: bug#29499: 25.3; bounds-of-thing-at-point for nested
 s-expressions?
Date: Fri, 26 Jul 2019 08:00:14 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> The problem is that thingatpt wants to go to the end of the current
> sexp, and uses forward-sexp for that.  The amusing thing about
> forward-sexp is that it won't error if there's nothing to advance to
> (like at the end of a buffer), but if it hits a ")" immediately, it
> signals an error, making bounds-of-thing-at-point return nil.
>
> The patch below fixes the problem, but I'm not very familiar with the
> thingatpt code.  Does anybody think this makes sense?

There weren't any comments, but it does seem to fix the reported issue,
so I've applied the patch.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 26 Jul 2019 06:01:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 29499 <at> debbugs.gnu.org and James Nguyen <jamesn <at> fastmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 26 Jul 2019 06:01:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Aug 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 241 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.