unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29499: 25.3; bounds-of-thing-at-point for nested s-expressions?
@ 2017-11-29  7:54 James Nguyen
  2019-07-14 18:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: James Nguyen @ 2017-11-29  7:54 UTC (permalink / raw)
  To: 29499

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))






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#29499: 25.3; bounds-of-thing-at-point for nested s-expressions?
  2017-11-29  7:54 bug#29499: 25.3; bounds-of-thing-at-point for nested s-expressions? James Nguyen
@ 2019-07-14 18:42 ` Lars Ingebrigtsen
  2019-07-26  6:00   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-14 18:42 UTC (permalink / raw)
  To: James Nguyen; +Cc: 29499

James Nguyen <jamesn@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





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#29499: 25.3; bounds-of-thing-at-point for nested s-expressions?
  2019-07-14 18:42 ` Lars Ingebrigtsen
@ 2019-07-26  6:00   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-26  6:00 UTC (permalink / raw)
  To: James Nguyen; +Cc: 29499

Lars Ingebrigtsen <larsi@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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-26  6:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-29  7:54 bug#29499: 25.3; bounds-of-thing-at-point for nested s-expressions? James Nguyen
2019-07-14 18:42 ` Lars Ingebrigtsen
2019-07-26  6:00   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).