all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Jean Louis <bugs@gnu.support>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: RE: [External] : ThingAtPointPlus, and extending things at point
Date: Fri, 6 Jan 2023 17:30:28 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488A0BA7126C0ACD8101C02F3FB9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <Y7hLFYT6jkMEiD+C@protected.localdomain>

> it finds string in Perl, like:
> print 'string';
> (thing-at-point 'string-contents)
> it finds:
> #("string" 0 6 (face font-lock-string-face fontified t))
> 
> but not that it finds it in Elisp mode, because it is not string, and
> also not in mail mode

Of course.  It respects the meaning of "string", i.e.,
the "string" syntax that's defined _in the current
major mode_.  What else would you have it do?

If for some reason you need to have interpretation
take place wrt some other syntax table temporarily,
then just wrap the code that needs that with macro
`with-syntax-table'.  If there's a Python major mode
for Emacs, with a Python syntax table (such as, e.g.
`py-syntable'), (with-syntax-table py-syntable...).

> people often quote in this way `'. What is the name of
> that type of quoting?

Dunno.  It's the way Emacs has always quoted sexps
in its doc.  And much more than just Emacs, going
back decades.

More recently, Emacs started converting `...' to
curly quotes.  This is too bad, IMHO - harder to
insert/type and so also harder to search for.
But it's considered "prettier" and more "modern"...
"On n'arrete pas le progres..."

> Thanks, I find the function `fw-to-next-thing' very useful in this
> unification of functions. It is reinventing the wheel what GNU
> Hyperbole already has, with extensions.

Maybe so.  Does it allow for arbitrary predicates,
arbitrary/unlimited Lisp code?

> I can imagine that `fw-to-next-thing' must be slower function right?
> It is much slower then just using regular expression search.

Read the Commentary.  It begins:

;;; Commentary:
;;
;;    Find where something is true.
;;
;;  Get or go to the next place where some predicate is satisfied.
;;
;;  But first, you don't really need this library! ;-)
;;
;;  In Emacs and Emacs Lisp there are multiple ways to find things.
;;  And in many cases it will be simpler or more efficient to use
;;  another way than to take advantage of this library.
;;
;;  What this library offers is some convenience sometimes, and a
;;  certain kind of generality: Specify what you want to find by a
;;  predicate.  The predicate is tested at successive places, forward
;;  or backward, until it is satisfied.

It then goes on to describe the default behavior
and implementation, it's strengths and weaknesses.
In particular, it says:

;;  Clearly, this move-one-char-and-test approach is not the way to go
;;  for ordinary string searching.  Emacs uses an efficient,
;;  Boyer-Moore string-search algorithm (see
;;  https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm),
;;  which essentially moves forward in chunks that are as long as what
;;  your search string matches, rather than moving just a character at
;;  a time before each match attempt.
;;
;;  So if you want to search for a sequence of characters, just use
;;  `(re-)search-forward' or similar.  And if you need an additional
;;  test at a match position (e.g., check a text or overlay property)
;;  you can easily add that.  So forget about this library for
;;  ordinary buffer search.
;;
;;  Still, you might find this library convenient for some things,
;;  even in cases where there is an easy alternative.  The abstraction
;;  of defining a destination by a predicate that holds there can be
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;;  helpful.

Providing the abstraction I underlined is the sweet-spot
use case.

> https://www.emacswiki.org/emacs/FindWhere
> 
> > For example, you can find a text THING, such as the next vector with
> > 13 elements, and have it returned along with its bounds (start and
> > end positions).
> 
> That is useful. Let us say I wish to collect all the anchors in the
> file, I can do it easier.


  reply	other threads:[~2023-01-06 17:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 10:12 Any packages using ThingAtPointPlus for activation? Jean Louis
2023-01-02 17:08 ` [External] : " Drew Adams
2023-01-03 12:41   ` Jean Louis
2023-01-03 19:54     ` Drew Adams
2023-01-03 20:23       ` Jean Louis
2023-01-03 22:47         ` Drew Adams
2023-01-04  8:46           ` Jean Louis
2023-01-04 15:42             ` Drew Adams
2023-01-04 16:03             ` Eduardo Ochs
2023-01-05  5:42               ` Jean Louis
2023-01-05  8:37   ` ThingAtPointPlus, and extending things at point Jean Louis
2023-01-05 17:00     ` [External] : " Drew Adams
2023-01-06 15:49       ` Jean Louis
2023-01-06 16:23       ` Jean Louis
2023-01-06 17:30         ` Drew Adams [this message]
2023-01-06 17:43           ` Jean Louis
2023-01-06 18:21             ` Drew Adams
2023-01-03  6:16 ` Any packages using ThingAtPointPlus for activation? Eduardo Ochs
2023-01-03 13:10   ` Jean Louis

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=SJ0PR10MB5488A0BA7126C0ACD8101C02F3FB9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=bugs@gnu.support \
    --cc=help-gnu-emacs@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.