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: Thu, 5 Jan 2023 17:00:28 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488C85A03D9C437CECAE676F3FA9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <Y7aMNfGy41IQp5F3@protected.localdomain>

> The library thingatpt+.el extends thingatpt.el
> EmacsWiki: Thing At Point Plus:
> https://www.emacswiki.org/emacs/ThingAtPointPlus
> 
> Though itself is not used extensively in many of
> your libraries, Drew. At least I did grep on many.

I try to have my libraries _not_ depend on
each other needlessly.  I try to avoid having
them be "package" sacks of stuff.  Better that
you should be able to load several or just a
few or just one, depending on what you want.

Typically I SOFT-require a library and so take
advantage of it only IF you _load_ it.  And in
some cases certain commands in a library might
themselves really require a particular library
(in which case they're either not defined if
that library isn't available or they raise an
error telling you it's needed).

My libraries DO make use of thingatpt+.el
extensively - IF it's loaded.  Anytime a
library of mine uses THING stuff it takes
advantage of thingatpt+.el enhancements, 
if it's loaded.

Typical is the use of a function to obtain 
a default value for something.  E.g., in
Bookmark+ the default value of option
`bmkp-new-bookmark-default-names' includes
`region-or-non-nil-symbol-name-nearest-point'
if that's `fboundp'. 

[That thingatpt+ function returns the text
 in the region, if it's active and not empty.
 Otherwise it returns the name of the symbol
 nearest point (other than `nil'), within max
 search distances `tap-near-point-x-distance'
 (left/right) and `tap-near-point-y-distance'
 (up/ down).]

And function `bmkp-read-variable' uses as
default the `symbol-nearest-point' if that
thingatpt+ function is defined; otherwise
just `symbol-at-point'.

And if available `bmkp-thing-at-point' uses
the thingatpt+ version of `thing-at-point';
else it uses the vanilla version.

And so on, for all of my libraries.

A library HARD-requires thingatpt+.el only
when no (usable, however poor) substitute
for some needed functionality is available
with vanilla thingatpt.el.  It's rare that
a library absolutely needs thingatpt+. It's
more common that some part of a library
(e.g. some command) needs thingatpt+, in
which case that part of the code does the
requiring itself.
___

> There is 'string and 'string-contents, really good.
> 
> Though in various modes 'string should be re-defined to support
> various quotes in various modes, let us say in Perl.

Send me the relevant info.  The code uses
(eq (char-syntax (char-after)) ?\"), and it
uses `syntax-ppss'.  So I'd expect that it
already DTRT for strings with different
delimiters.  But suggestions welcome.

> I have examined (thing-at-point 'list):
> - it works on '(1 "OK" 2) and then I can choose
>   (thing-at-point 'list-contents) to get the elements
> - but it does not work on (list 1 2 3), as there I get
>   the element `list' by using 'list-contents, that is now
>   what I expected, but OK, it is more generalized "list".

I guess you mean that you get the string
"list 1 2 3".  That's correct - that's the
text that's the list content.

You'll need to clarify.  I suggest you do
that off-list.  If the text `(list 1 2 3)' is
in a buffer and you try (thing-at-point 'list)
then that literal, textual list is the string
you get and should get, IMO.  It's not about
evaluating code and then returning the thing
that's the result of that evaluation.  It's
about getting a textual thing (e.g. list) at
point.

> The concept of elementary things basically teach
> computer to recognize where is the point.

I don't follow you there.

> Things at point are elementary contexts.

Or there.

> It is possible to teach computer to recognize stuff, and then act upon
> it in unified way.

Or there.  Maybe try to be more specific.

> Unification to one key is helpful. No need to remember too many keys.
> 
> Contexts may be expanded by looking into major mode, buffer file name,
> position in the file, various elements of the file, TODO states, and
> similar.

Feel free to communicate any _specific_
suggestions for thingatpt+.el.

> I defined this:
> (defun rcd-tap-iso-date-start ()
>   "Move point to the beginning of the ISO date."
>   (when (thing-at-point-looking-at rcd-rx-iso-date)
>     (goto-char (match-beginning 0))))
> (defun rcd-tap-iso-date-end ()...)
> (put 'iso-date 'beginning-op 'rcd-tap-iso-date-start)
> (put 'iso-date 'end-op 'rcd-tap-iso-date-end)
> 
> Then on 2023-01-05 the (thing-at-point 'iso-date)
> gives result: "2023-01-05"
> jump quickly to messages and calls from that day.

You might also be interested in my `find-where.el'.
It lets you move forward/back to the beginning/end
of the next/previous thing etc. (repeatably).	

https://www.emacswiki.org/emacs/FindWhere

By default, movement is to the START position
of something, but really the <where>, in
relation to the <what>, is up to you.  The
default behavior is thus different from the
standard Emacs `forward|backward-THING'
behavior, which moves just PAST the THING
rather than just TO it.

More generally, `find-where.el' finds (and
optionally moves to) the next/previous place
where <something> is true.  <Something> can
be anything - a predicate.

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

  reply	other threads:[~2023-01-05 17:00 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     ` Drew Adams [this message]
2023-01-06 15:49       ` [External] : " Jean Louis
2023-01-06 16:23       ` Jean Louis
2023-01-06 17:30         ` Drew Adams
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=SJ0PR10MB5488C85A03D9C437CECAE676F3FA9@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.