all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Any packages using ThingAtPointPlus for activation?
@ 2023-01-02 10:12 Jean Louis
  2023-01-02 17:08 ` [External] : " Drew Adams
  2023-01-03  6:16 ` Any packages using ThingAtPointPlus for activation? Eduardo Ochs
  0 siblings, 2 replies; 19+ messages in thread
From: Jean Louis @ 2023-01-02 10:12 UTC (permalink / raw)
  To: Help GNU Emacs; +Cc: Drew Adams

Dear Drew,

Regarding your library:
https://www.emacswiki.org/emacs/ThingAtPointPlus

You probably know Hyperbole and how M-RET works in Hyperbole. I like
the concept and wish to use M-RET in similar fashion, though without
Hyperbole package, so to jump to various functions by using
thing-at-point plus. It gives me freedom to easier define what I need,
and if nothing found I can still include Hyperbole function on the
end.

The concept to "jump" based on some things at point, is useful. I jump
faster to various pieces of information.

Here is the preliminary function that shows the concept:

(defun hyperscope-action-button (&optional prefix)
  (interactive "p")
  (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point 'uuid)))
	;; the above would find UUID in databases or Org files and jump there.
	((thing-at-point 'url) (browse-url (thing-at-point 'url)))
	;; the above browse the URL
	((thing-at-point 'email) (rcd-write-email user-full-name user-mail-address (thing-at-point 'email) (thing-at-point 'email)))
	;; the above writes the e-mail to email address found at point
	((thing-at-point 'symbol) 
	 (let ((symbol (intern (thing-at-point 'symbol))))
	   (cond ((fboundp symbol)
		  (find-function symbol))
		 ((boundp symbol)
		  (find-variable symbol))
		 (t (rcd-warning-message "Could not find symbol `%s'" symbol)))))
		 ;; the above finds definition of a function similar like xref but works outside of Emacs Lisp mode
	((thing-at-point 'number) (hyperscope-isolate (thing-at-point 'number)))
	;; the above would jump to elementary object in Hyperscope database
	(t (rcd-message "Hyperscope action not defined.")))))
	;; Or I get warning

;; Easy to define global key
(keymap-global-set "M-RET" #'hyperscope-action-button)

I want to expand the concept by following thinking:

- M-RET -- jump to default function
- C-u 0 M-RET -- capture thing at point
- C-u 1 M-RET -- share thing at point
- C-u 2 M-RET -- etc. etc. etc.

Point of this e-mail:
---------------------

Before I continue expanding the concept, it is better I ask you and others about previous work.

Do you know of any existing package(s), apart from Hyperbole, that
deal in similar way with action keys andjumping based on what is found
under the point?

On MELPA, I see related packages, that have useful functions:
https://melpa.org/#/?q=at-point

And M-x package-list-packages did not give me some more relevant
information about "thing" and "jump".



Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-02 10:12 Any packages using ThingAtPointPlus for activation? Jean Louis
@ 2023-01-02 17:08 ` Drew Adams
  2023-01-03 12:41   ` Jean Louis
  2023-01-05  8:37   ` ThingAtPointPlus, and extending things at point Jean Louis
  2023-01-03  6:16 ` Any packages using ThingAtPointPlus for activation? Eduardo Ochs
  1 sibling, 2 replies; 19+ messages in thread
From: Drew Adams @ 2023-01-02 17:08 UTC (permalink / raw)
  To: Jean Louis, Help GNU Emacs

> Regarding your library `thingatpt+.el':
> 
> You probably know Hyperbole and how M-RET works in Hyperbole.

Nope, sorry.  I probably don't know about most things
available with Emacs - many, anyway.

> [I wish] to jump to various functions by using
> thing-at-point plus. It gives me freedom to easier
> define what I need, and if nothing found I can still
> include Hyperbole function on the end.
> 
> The concept to "jump" based on some things at point, 
> is useful. I jump faster to various pieces of information.
> 
> Here is the preliminary function that shows the concept:
> 
> (defun hyperscope-action-button (&optional prefix)
>   (interactive "p")
>   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point
> 'uuid)))

I suggest you don't invoke `thing-at-point' multiple
times needlessly.  Use `let', to do the work only once.

> 	((thing-at-point 'url)...)
> 	((thing-at-point 'email)...)
> 	((thing-at-point 'symbol)
> 	 (let ((symbol (intern (thing-at-point 'symbol))))
> 	   (cond ((fboundp symbol)
> 		  (find-function symbol))
> 		 ((boundp symbol)
> 		  (find-variable symbol))
> 		 (t (rcd-warning-message "...")))))
>    ...

Don't use (`thing-at-point 'symbol) for this.
Perhaps unfortunately, Emacs has that return text at
point that has symbol syntax - in the current mode.
It doesn't return a Lisp symbol name at point
(unless you're in `emacs-lisp-mode').

Use `symbol-at-point' (or, if you want only currently
defined Elisp symbols, `tap-symbol-at-point').  They
return a Lisp symbol - no need to intern.

If you want, instead of doing such a `cond' here,
just define functions `lisp-function-at-point' and
`lisp-var-at-point'.  Then you can use those anytime
you like, not just here.  The code and Commentary in
`thingatpt+.el' shows you how to do that.  E.g.,

(defun lisp-function-at-point
  "Return a Lisp function at point, or nil."
  (tap-form-at-point 'symbol 'fboundp))

`tap-form-at-point' (and vanilla `form-at-point')
returns a Lisp object corresponding the textual
THING that's its first object, provided that that
Lisp object satisfies the PREDICATE that is its
second object.

You can also define a function to give you the
bounds (limits) of a thing, e.g., the bounds of
the Lisp function named at point:

(put 'lisp-function 'tap-bounds-of-thing-at-point
     'tap-bounds-of-lisp-function-at-point)

(defun tap-bounds-of-lisp-function-at-point ()
  "Return bounds of the Lisp function at point.
Return nil if none is found."
  (and (lisp-function-at-point)
       (tap-bounds-of-thing-at-point 'symbol)))

> Do you know of any existing package(s), apart from Hyperbole, that
> deal in similar way with action keys and jumping based on what is found
> under the point?

I'm the wrong person to ask about what packages
are available for things.

But the Emacs manual, node `Xref' tells you about
ways to find the source code (definitions) for
existing "identifiers", which can be any "syntactical
subunit of [a] program: a function, a subroutine, a
method, a class, a data type, a macro, etc."

https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html

That may help to some extent.  But you apparently
want to jump to other kinds of things.

Bookmarks do that - you can define a bookmark type
for "jumping" to anything.  That's the original
purpose of Emacs bookmarks.  And "jump" can mean
whatever you like.  You can use thing-at-point
to get the name of a thing of a particular kind at
point, and then jump to it using a bookmark.

Hopefully others will have other suggestions.



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

* Re: Any packages using ThingAtPointPlus for activation?
  2023-01-02 10:12 Any packages using ThingAtPointPlus for activation? Jean Louis
  2023-01-02 17:08 ` [External] : " Drew Adams
@ 2023-01-03  6:16 ` Eduardo Ochs
  2023-01-03 13:10   ` Jean Louis
  1 sibling, 1 reply; 19+ messages in thread
From: Eduardo Ochs @ 2023-01-03  6:16 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs, Drew Adams

On Mon, 2 Jan 2023 at 07:13, Jean Louis <bugs@gnu.support> wrote:
>
> Dear Drew,
>
> Regarding your library:
> https://www.emacswiki.org/emacs/ThingAtPointPlus
>
> You probably know Hyperbole and how M-RET works in Hyperbole. I like
> the concept and wish to use M-RET in similar fashion, though without
> Hyperbole package, so to jump to various functions by using
> thing-at-point plus. It gives me freedom to easier define what I need,
> and if nothing found I can still include Hyperbole function on the
> end.
>
> The concept to "jump" based on some things at point, is useful. I jump
> faster to various pieces of information.
>
> Here is the preliminary function that shows the concept:
>
> (defun hyperscope-action-button (&optional prefix)
>   (interactive "p")
>   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point 'uuid)))
>         ;; the above would find UUID in databases or Org files and jump there.
>         ((thing-at-point 'url) (browse-url (thing-at-point 'url)))
>         ;; the above browse the URL
>         ((thing-at-point 'email) (rcd-write-email user-full-name user-mail-address (thing-at-point 'email) (thing-at-point 'email)))
>         ;; the above writes the e-mail to email address found at point
>         ((thing-at-point 'symbol)
>          (let ((symbol (intern (thing-at-point 'symbol))))
>            (cond ((fboundp symbol)
>                   (find-function symbol))
>                  ((boundp symbol)
>                   (find-variable symbol))
>                  (t (rcd-warning-message "Could not find symbol `%s'" symbol)))))
>                  ;; the above finds definition of a function similar like xref but works outside of Emacs Lisp mode
>         ((thing-at-point 'number) (hyperscope-isolate (thing-at-point 'number)))
>         ;; the above would jump to elementary object in Hyperscope database
>         (t (rcd-message "Hyperscope action not defined.")))))
>         ;; Or I get warning
>
> ;; Easy to define global key
> (keymap-global-set "M-RET" #'hyperscope-action-button)
>
> I want to expand the concept by following thinking:
>
> - M-RET -- jump to default function
> - C-u 0 M-RET -- capture thing at point
> - C-u 1 M-RET -- share thing at point
> - C-u 2 M-RET -- etc. etc. etc.
>
> Point of this e-mail:
> ---------------------
>
> Before I continue expanding the concept, it is better I ask you and others about previous work.
>
> Do you know of any existing package(s), apart from Hyperbole, that
> deal in similar way with action keys andjumping based on what is found
> under the point?
>
> On MELPA, I see related packages, that have useful functions:
> https://melpa.org/#/?q=at-point
>
> And M-x package-list-packages did not give me some more relevant
> information about "thing" and "jump".

Hi Jean Louis,

just one comment... `hyperscope-action-button' is written in a way
that I don't like: it doesn't let us inspect what is the thing at
point before doing something with the thing at point, and so it is
hard to debug. I would factor it in at least two functions, and the
lower-level one would be something like this, but I've omitted the
case that tests for interned symbols...

(defun ee-thing-at-point ()
  (cond ((thing-at-point 'symbol) (list 'symbol (thing-at-point 'symbol)))
        ((thing-at-point 'url)    (list 'url    (thing-at-point 'url)))
        ((thing-at-point 'email)  (list 'email  (thing-at-point 'email)))
        ((thing-at-point 'number) (list 'number (thing-at-point 'number)))
))

In eev I have something similar to that, but that classifies the
current buffer into several kinds instead of classifying the thing
around point into several kinds. It is here,

  http://angg.twu.net/eev-current/eev-hlinks.el.html#ee-fhl-main-program
  (find-eev "eev-hlinks.el" "ee-fhl-main-program")

and it is written in a way in which I can replace the code that
interprets the "program" by something more elegant without having to
change the "program" itself... which is good, because I think that the
current interpreter is not very well-written. But the current version
has a debugging mode that is decently good - try `M-1 M-h M-h' to see
what it shows.

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev



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

* Re: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-02 17:08 ` [External] : " Drew Adams
@ 2023-01-03 12:41   ` Jean Louis
  2023-01-03 19:54     ` Drew Adams
  2023-01-05  8:37   ` ThingAtPointPlus, and extending things at point Jean Louis
  1 sibling, 1 reply; 19+ messages in thread
From: Jean Louis @ 2023-01-03 12:41 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2023-01-02 20:10]:
> > (defun hyperscope-action-button (&optional prefix)
> >   (interactive "p")
> >   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point
> > 'uuid)))
> 
> I suggest you don't invoke `thing-at-point' multiple
> times needlessly.  Use `let', to do the work only once.

I would rather like to have universal thing at point that would
identify all possible elements at once and give me list of it.

I understand repetitions, I may consider let later, maybe not. It is
not matter of speed now, neither style. It is thinkering stage.

> Don't use (`thing-at-point 'symbol) for this.
> Perhaps unfortunately, Emacs has that return text at
> point that has symbol syntax - in the current mode.
> It doesn't return a Lisp symbol name at point
> (unless you're in `emacs-lisp-mode').

> Use `symbol-at-point' (or, if you want only currently
> defined Elisp symbols, `tap-symbol-at-point').  They
> return a Lisp symbol - no need to intern.

Alright, but I would like to recognize only symbols which are defined,
like functions and variables and not symbols which are not defined.

How do I recognize if function is defined?

I use (fboundp 'system-move-file-to-trash) ➜ t

How I recognize if variable is one variable defined anywhere globally?

Judging by the inspection of command {C-h v} it is following:

- I should use (boundp SYMBOL) to recognize if it is variable

> If you want, instead of doing such a `cond' here,
> just define functions `lisp-function-at-point' and
> `lisp-var-at-point'.  Then you can use those anytime
> you like, not just here.  The code and Commentary in
> `thingatpt+.el' shows you how to do that.  E.g.,
> 
> (defun lisp-function-at-point
>   "Return a Lisp function at point, or nil."
>   (tap-form-at-point 'symbol 'fboundp))
> 
> `tap-form-at-point' (and vanilla `form-at-point')
> returns a Lisp object corresponding the textual
> THING that's its first object, provided that that
> Lisp object satisfies the PREDICATE that is its
> second object.

That is great.

> Bookmarks do that - you can define a bookmark type
> for "jumping" to anything.  That's the original
> purpose of Emacs bookmarks.  And "jump" can mean
> whatever you like.  You can use thing-at-point
> to get the name of a thing of a particular kind at
> point, and then jump to it using a bookmark.

Does it mean I would need to bookmark it first before using a bookmark?

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: Any packages using ThingAtPointPlus for activation?
  2023-01-03  6:16 ` Any packages using ThingAtPointPlus for activation? Eduardo Ochs
@ 2023-01-03 13:10   ` Jean Louis
  0 siblings, 0 replies; 19+ messages in thread
From: Jean Louis @ 2023-01-03 13:10 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: Help GNU Emacs, Drew Adams

* Eduardo Ochs <eduardoochs@gmail.com> [2023-01-03 09:17]:
> just one comment... `hyperscope-action-button' is written in a way
> that I don't like: it doesn't let us inspect what is the thing at
> point before doing something with the thing at point, and so it is
> hard to debug. I would factor it in at least two functions, and the
> lower-level one would be something like this, but I've omitted the
> case that tests for interned symbols...
> 
> (defun ee-thing-at-point ()
>   (cond ((thing-at-point 'symbol) (list 'symbol (thing-at-point 'symbol)))
>         ((thing-at-point 'url)    (list 'url    (thing-at-point 'url)))
>         ((thing-at-point 'email)  (list 'email  (thing-at-point 'email)))
>         ((thing-at-point 'number) (list 'number (thing-at-point 'number)))
> ))

I accept the good idea. I would move into that soon anyway. This is
yet time of thinkering. It is all based on the concept of jumping to
various tings as it is already implemented in Hyperbole.

I wish to bypass Hyperbole, use things with priority myself, and let
the rest be handled by Hyperbole eventually.

Using M-RET is great thing as it is easily accessible action button as
demonstrated in Hyperbole.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-03 12:41   ` Jean Louis
@ 2023-01-03 19:54     ` Drew Adams
  2023-01-03 20:23       ` Jean Louis
  0 siblings, 1 reply; 19+ messages in thread
From: Drew Adams @ 2023-01-03 19:54 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > > (defun hyperscope-action-button (&optional prefix)
> > >   (interactive "p")
> > >   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point
> > > 'uuid)))
> >
> > I suggest you don't invoke `thing-at-point' multiple
> > times needlessly.  Use `let', to do the work only once.
> 
> I would rather like to have universal thing at point that would
> identify all possible elements at once and give me list of it.

(That seems unrelated to the text you quoted.)

Feel free to code what you (think you) want. ;-)

I don't see the point of that, but that doesn't
mean it has no point.  Why would you want to
spend time gathering all (of some set, presumably)
the possible things at point?

I suppose I can imagine your wanting to try to get
THING1 first, and if there is none, then try to
get THING2, etc. That's something else again.  You
could easily write code that does that, given a
list of THINGS.  Cf. `run-hook-with-args-until-success'.

> I understand repetitions, I may consider let later, maybe not. It is
> not matter of speed now, neither style. It is thinkering stage.

Using `let', so you eval some sexp only once,
isn't only (or necessarily at all) a matter
of speed.  Among other things, it can also
make your code more readable: it becomes
clear what's already been done, and you can
give variables names that are relevant to the
current context.  E.g., you might use some
function that returns a list only for its
Boolean value (nil or not), and in the current
context that value might have a particular use
or meaning - so naming it can make your code
(especially if the defun is large) more
readable.

(Of course, this kind of thing is personal style.)

> > Don't use (`thing-at-point 'symbol) for this.
> > Perhaps unfortunately, Emacs has that return text at
> > point that has symbol syntax - in the current mode.
> > It doesn't return a Lisp symbol name at point
> > (unless you're in `emacs-lisp-mode').
> 
> > Use `symbol-at-point' (or, if you want only currently
> > defined Elisp symbols, `tap-symbol-at-point').  They
> > return a Lisp symbol - no need to intern.
> 
> Alright, but I would like to recognize only symbols which are defined,
> like functions and variables and not symbols which are not defined.
> 
> How do I recognize if function is defined?

As I said: `fboundp'.  Or if you want to include only
real functions (not macros etc.), then `functionp'.

> I use (fboundp 'system-move-file-to-trash) ➜ t

Yep.  I showed the use of `fboundp' in the example
code I sent.

> How I recognize if variable is one variable defined anywhere globally?

I don't understand the question.  Can you rephrase it?

> Judging by the inspection of command {C-h v} it is following:
> - I should use (boundp SYMBOL) to recognize if it is variable

Yes, if you want a bound variable, and not just a
var that's only declared with a vacuous defvar:
(defvar foo).

> > Bookmarks do that - you can define a bookmark type
> > for "jumping" to anything.  That's the original
> > purpose of Emacs bookmarks.  And "jump" can mean
> > whatever you like.  You can use thing-at-point
> > to get the name of a thing of a particular kind at
> > point, and then jump to it using a bookmark.
> 
> Does it mean I would need to bookmark it first before using a bookmark?

Of course.  If you don't bookmark it there's no
bookmark for it.

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

* Re: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-03 19:54     ` Drew Adams
@ 2023-01-03 20:23       ` Jean Louis
  2023-01-03 22:47         ` Drew Adams
  0 siblings, 1 reply; 19+ messages in thread
From: Jean Louis @ 2023-01-03 20:23 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2023-01-03 22:55]:
> > > > (defun hyperscope-action-button (&optional prefix)
> > > >   (interactive "p")
> > > >   (cond ((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point
> > > > 'uuid)))
> > >
> > > I suggest you don't invoke `thing-at-point' multiple
> > > times needlessly.  Use `let', to do the work only once.
> > 
> > I would rather like to have universal thing at point that would
> > identify all possible elements at once and give me list of it.
> 
> (That seems unrelated to the text you quoted.)

Seem to be. Though Eduardo created concept function that finds the
thing at point among many. When such function would exist and be
polished, then using `let' also becomes easier. You referred to let
inside of `cond' but me, I would let using `let' to get the preferred
thing-at-point before the `cond'. That could be possible when
thing-at-point would be recognized by some priority by some function.

> I don't see the point of that, but that doesn't
> mean it has no point.  Why would you want to
> spend time gathering all (of some set, presumably)
> the possible things at point?

It is because you did not meet GNU Hyperbole,
https://www.gnu.org/s/hyperbole, The Everyday Hypertextual Information
Manager, and tried M-RET on various things.

Even while writing this I have used M-RET to jump quickly to word
definition, and URL, and what else. It shortens my work.

The point of gathering things at point, those whihc may be usable, is
to shorten work, depending on what user wish and want.

For example in your paragraph below, I know nothing about
`run-hook-with-args-until-success' but I can press M-RET on it which
is for me faster than figuring out if it is function or variable. By
using quicker jump, I go straight to source or description and
understand about it better. 

> I suppose I can imagine your wanting to try to get THING1 first, and
> if there is none, then try to get THING2, etc. That's something else
> again.  You could easily write code that does that, given a list of
> THINGS.  Cf. `run-hook-with-args-until-success'.

That is not just about things which are defined, there are different
meanings and different actions depending of the context, and when all
get gathered into one key, then using text becomes easier. If it is
URL, go and jump for it, but if I do prefix, maybe I want URL
downloaded. That is all handy as it shortens work. What if it looks as
file like "/tmp/my-file.txt"? Why not visit the file if I clicked on
it. What if it is PDF, and wish to open it with external viewer? And
PDF is on remote host? Something like https://www.example.com/my.pdf
would then need only M-RET (referring to GNU Hyperbole concept) for
the my.pdf to be downloaded and opened in external viewer, or with
prefix internal Docview, or with different prefix to be printed. 

It is object relationship recognition and jump from and to each other.

Imagine screen or temporary buffer with profile of a person:

UUID 8b592aaaaa71-b8fc-4f45-8f7f-69ef0528ba17

Joe Doe

Kawasaki Road,
Wakimaki, 12345

Phone (mobile): +12345678901
E-mail: wakimaki@example.com

I would also need to implement automatic buttons, with `buttonize' or
similar function so that those preferred things get marked, or
underlined or become visible hyperlinks. 

In fact I would like doing it only temporarily, while a key is
held. Something like holding `C-backspace' and while holding it to see
the hyperlinks, and when releasing it, to remove visible hyperlinks.

Then M-RET on UUID goes to the full profile of a person, and then:

- with prefix C-1 M-RET, go to listing of cash accounts for which
  person is responsible, we talk money;

- with different prefix, see his balances and outstanding demands;

- with different prefix, see his pictures;

- with different prefix, see his ID documents

- with different prefix, go into communication screen, to communicate
  with that person, initiate call, SMS, XMPP message, e-mail, receive
  call and make note, etc.

- on mobile phone, ask if to call, or send SMS by using Twilio;

- on e-mail, compose e-mail

- on XMPP, compose chat message

And so on.

The point is that single key, any key, or on this case Hyperbole's
well known M-RET becomes universal hyperlinking tool.

Then it is very easy to teach staff members:

- File receipt for accounting by using prefix C-1 (in Dired) -- and
  here they will already know it is M-RET key to be used with that
  prefix.

- See accounting for person with prefix C-2

- Visit communication center for that person with prefix C-3

It is much shorter to teach people, as once they know M-RET (or other
key) then many things get connected together all around one key, with
slight differences.

Better so, rather than teaching them how to invoke M-x functions where
each function has different name and are easier to forget.

> > How do I recognize if function is defined?
> 
> As I said: `fboundp'.  Or if you want to include only
> real functions (not macros etc.), then `functionp'.

Good, thank you, that I don't forget it.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-03 20:23       ` Jean Louis
@ 2023-01-03 22:47         ` Drew Adams
  2023-01-04  8:46           ` Jean Louis
  0 siblings, 1 reply; 19+ messages in thread
From: Drew Adams @ 2023-01-03 22:47 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> You referred to let
> inside of `cond' but me, I would let using `let' to 
> get the preferred thing-at-point before the `cond'. 

No, I didn't.  I meant what you said: use `let' to
bind a var to the THING you want.  Then use `cond' or
`cl-case' or whatever to test that value using the var.

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

* Re: [External] : Any packages using ThingAtPointPlus for activation?
  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
  0 siblings, 2 replies; 19+ messages in thread
From: Jean Louis @ 2023-01-04  8:46 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2023-01-04 01:48]:
> > You referred to let
> > inside of `cond' but me, I would let using `let' to 
> > get the preferred thing-at-point before the `cond'. 
> 
> No, I didn't.  I meant what you said: use `let' to
> bind a var to the THING you want.  Then use `cond' or
> `cl-case' or whatever to test that value using the var.

`cond' is the one to recognize which type of thing at point is
there, as I need to recognize among many various conditions, and they
may not be only thing at point.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-04  8:46           ` Jean Louis
@ 2023-01-04 15:42             ` Drew Adams
  2023-01-04 16:03             ` Eduardo Ochs
  1 sibling, 0 replies; 19+ messages in thread
From: Drew Adams @ 2023-01-04 15:42 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > > You referred to let
> > > inside of `cond' but me, I would let using `let' to
> > > get the preferred thing-at-point before the `cond'.
> >
> > No, I didn't.  I meant what you said: use `let' to
> > bind a var to the THING you want.  Then use `cond' or
> > `cl-case' or whatever to test that value using the var.
> 
> `cond' is the one to recognize which type of
> thing at point is there, as I need to recognize
> among many various conditions, and they
> may not be only thing at point.

Sorry, I forgot your original code.  Yes, you're
checking for a given THING in each `cond' clause.
And then you use the same `thing-at-point' call
again, after knowing that you've found a THING
of the given type, in order to do something with it.

My original reply was OK; my reply quoted above was
mistaken, as I'd forgotten what you were doing.

You could nevertheless avoid repeating the same
`thing-at-point' call in each clause, if you
wanted.  I agree that in most cases the time
spent, and the added noise (repetition) in the
code, are both negligible.

But if you did want to avoid the repetition you
could do this:

(let (thg) ; Just bind it.
  (cond ((setq thg (thing-at-point 'uuid))
         (rcd-db-uuid-action thg))
        ((setq thg (thing-at-point 'url))
         (browse-url thg))
        ...))

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

* Re: [External] : Any packages using ThingAtPointPlus for activation?
  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
  1 sibling, 1 reply; 19+ messages in thread
From: Eduardo Ochs @ 2023-01-04 16:03 UTC (permalink / raw)
  To: Drew Adams, Help GNU Emacs

On Wed, 4 Jan 2023 at 06:41, Jean Louis <bugs@gnu.support> wrote:
>
> * Drew Adams <drew.adams@oracle.com> [2023-01-04 01:48]:
> > > You referred to let
> > > inside of `cond' but me, I would let using `let' to
> > > get the preferred thing-at-point before the `cond'.
> >
> > No, I didn't.  I meant what you said: use `let' to
> > bind a var to the THING you want.  Then use `cond' or
> > `cl-case' or whatever to test that value using the var.
>
> `cond' is the one to recognize which type of thing at point is
> there, as I need to recognize among many various conditions, and they
> may not be only thing at point.

Hi Jean and all,

for the sake of completeness, here is the prototype that I wrote:

  http://angg.twu.net/elisp/eev-rcd-tap-1.el
  http://angg.twu.net/elisp/eev-rcd-tap-1.el.html
  http://angg.twu.net/eev-videos/2023-eev-rcd-tap-1.mp4

It is similar to the module of eev that implements the function
`find-here-links', that creates links to "here". The first step of
`find-here-links' is to decide in what kind of "here" we are, and it
has to handle many cases. All my first attempts to (re)write it
yielded ugly code, and I found that that implementation with a little
DSL was much more readable.

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev



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

* Re: [External] : Any packages using ThingAtPointPlus for activation?
  2023-01-04 16:03             ` Eduardo Ochs
@ 2023-01-05  5:42               ` Jean Louis
  0 siblings, 0 replies; 19+ messages in thread
From: Jean Louis @ 2023-01-05  5:42 UTC (permalink / raw)
  To: Eduardo Ochs; +Cc: Drew Adams, Help GNU Emacs

* Eduardo Ochs <eduardoochs@gmail.com> [2023-01-04 19:05]:
> Hi Jean and all,
> 
> for the sake of completeness, here is the prototype that I wrote:
> 
>   http://angg.twu.net/elisp/eev-rcd-tap-1.el

I have been testing it. Thanks.

I am interested in quick, user friendly way of invoking functions with
multiple variations by using single key, not necessarily only on thing
at point, there are variations involved. A "word" may be special word
like database table name, I may need or want to browse the entries
straight.

I have often functions like:

(rcd-db-get-entry "hyobjects" "hyobjects_link" id hs-db) 
as that one fetch value of column "hyobjects_link" from table
"hyobjects" by unique key ID from database "hs-db".

And Emacs will not recognize "hyobjects" but my function can do that.

General idea is to expand or bypass Hyperbole's usage of a single key
to become smart in various context.

There is function `read-multiple-choice' (blocking the interface)
which can be used for few choices. 

If there is active region, I wish to choose if to capture it or do
what else with it.

So I have made `read-multiple-choice' to be automatic:

(defun rcd-multiple-choice-by-listo (list rcd-function &optional prompt description quit-on-any)
  "Run RCD-FUNCTION on results of multiple choice LIST of strings.

It uses `q' char to quit thus its value will not be used.
PROMPT is optional just as DESCRIPTION.

QUIT-ON-ANY will not return to main menu after running the function."
  (let* ((prompt (or prompt "Choose: "))
	 (choices '((?q "Quit")))
	 (key ?b)
	 (quit))
    (mapc (lambda (item)
	    (when (= key ?q) (setq key (1+ key)))
	    (push (list key item description) choices)
	    (setq key (1+ key)))
	  (seq-sort 'string< list))
    (while (not quit)
      (let* ((resize-mini-windows t) ;; TODO maybe not needed, rather setting max-mini-window-height?
	     (selection (read-multiple-choice prompt (reverse choices)))
	     (new-key (car selection))
	     (value (cadr selection)))
	(setq key new-key)
	(when (or quit-on-any (= ?q key)) (setq quit t))
	(unless (= ?q new-key)
	  (funcall rcd-function value))))))

Then I can do something like:

(defun rcd-db-region-choice ()
  (when (region-active-p)
    (let ((region (rcd-region-string)))
      (rcd-multiple-choice-by-list
       '("Search Hyperscope" "Search people" "Capture region" "rgrep") 
       (lambda (arg) 
	 (cond ((string= arg "Search Hyperscope") (hyperscope-by-name nil region))
	       ((string= arg "Search people") (cf-people-by-name region))
	       ((string= arg "Capture region") (hyperscope-capture-region))
	       ((string= arg "rgrep") (rgrep-current-word-in-el-project))
	       (t (message "%s" arg) (sleep-for 2))))
       "What to do with region?" nil t))))

The above concept will be added to things at point, as if there is
region, there may be special things to choose.

That get included:

(defun hyperscope-action-button ()
  (interactive)
  (cond ((region-active-p) (rcd-db-region-choice))
	((thing-at-point 'uuid) (rcd-db-uuid-action (thing-at-point 'uuid)))
	((thing-at-point 'url) (browse-url (thing-at-point 'url)))
	((thing-at-point 'email) (rcd-write-email user-full-name user-mail-address (thing-at-point 'email) (thing-at-point 'email)))
	((and (thing-at-point 'symbol) (boundp (symbol-at-point))) (find-variable (symbol-at-point)))
	((and (thing-at-point 'symbol) (fboundp (symbol-at-point))) (find-function (symbol-at-point)))
	((thing-at-point 'number) (hyperscope-isolate (thing-at-point 'number)))
	((thing-at-point 'word) (cond ((hyperscope-tap-table) (hyperscope-visit-table (thing-at-point 'word)))
				      (t (funcall (cond ((fboundp 'wordnut-search) 'wordnut-search)
							((fboundp 'dictionary-search) 'dictionary-search))
						  (thing-at-point 'word)))))
	(t (rcd-message "Hyperscope action not defined."))))

(keymap-global-set "M-RET" #'hyperscope-action-button) 

Concept is decades old from Hyperbole. It is to unify common functions
to single key, making the key "smart" by context.

Example of contexts:

- Cursor in mail mode before the line "--text follows this line--"
  where line begins with To, Bcc, Cc, then it should try to expand
  e-mail aliases

- Cursor or point on known e-mail address, that exist in database, ask
  user if to jump to profile or send e-mail?

- Cursor on unknown e-mail address, or phone number, or similar, enter
  in the database first.

- Cursor on known phone number, display contact's name, decide if to
  initiate call, SMS, XMPP, send E-mail, etc. 

  I initiate calls by using:

  (defun termux-call (number)
  "Call NUMBER"
  (let ((command (concat "(am start -a android.intent.action.CALL -d tel:" number)))
    (termux/send-command command)))


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* ThingAtPointPlus, and extending things at point
  2023-01-02 17:08 ` [External] : " Drew Adams
  2023-01-03 12:41   ` Jean Louis
@ 2023-01-05  8:37   ` Jean Louis
  2023-01-05 17:00     ` [External] : " Drew Adams
  1 sibling, 1 reply; 19+ messages in thread
From: Jean Louis @ 2023-01-05  8:37 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

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 am just examining it.

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.

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

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

Things at point are elementary contexts. 

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

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.

Here is how I have defined thing 'iso-date

First I have defined imperfect ISO date regular expression:

(defvar rcd-rx-iso-date (rx (seq (any digit) (any digit) (any digit) (any digit))
			    "-"
			    (or (seq "0" (any digit))
				(seq "1" (any "0-2")))
			    "-"
			    (or (seq (any "0-2") (any digit))
				(seq "3" (any "0-1"))))
  "Regular expression for ISO date.")

It is imperfect as it does not check for number of days in specific month.

(string-match rcd-rx-iso-date "2023-01-05") ➜ 0
(string-match rcd-rx-iso-date "2023-01-32") ➜ nil
(string-match rcd-rx-iso-date "2023-01-31") ➜ 0w
but incorrect for:
(string-match rcd-rx-iso-date "2023-02-31") ➜ 0

then 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 ()
  "Move point to the end of the ISO date."
  (when (thing-at-point-looking-at rcd-rx-iso-date)
    (goto-char (match-end 0))))

and finally definition of thing at point 'iso-date here below:

(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" 0 10 (fontified t))

Thanks to thingatpt.el (by Mike Williams) and thingatpt+.el (by Drew
Adams).

Why is it useful? It is useful in the context, like having list of
people who communicated on 2023-01-05 or 2023-01-04, 

Joe Doe 2023-01-05
Marry 2023-01-04

to jump quickly to messages and calls from that day.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : ThingAtPointPlus, and extending things at point
  2023-01-05  8:37   ` ThingAtPointPlus, and extending things at point Jean Louis
@ 2023-01-05 17:00     ` Drew Adams
  2023-01-06 15:49       ` Jean Louis
  2023-01-06 16:23       ` Jean Louis
  0 siblings, 2 replies; 19+ messages in thread
From: Drew Adams @ 2023-01-05 17:00 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

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

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

* Re: [External] : ThingAtPointPlus, and extending things at point
  2023-01-05 17:00     ` [External] : " Drew Adams
@ 2023-01-06 15:49       ` Jean Louis
  2023-01-06 16:23       ` Jean Louis
  1 sibling, 0 replies; 19+ messages in thread
From: Jean Louis @ 2023-01-06 15:49 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

I find it useful to have this:

;;; Thing at point 'thing-within-spaces

(defun rcd-tap-thing-within-spaces-start ()
    "Move point to the beginning of thing within spaces."
  (re-search-backward (rx whitespace))
  (forward-char 1))

(defun rcd-tap-thing-within-spaces-end ()
    "Move point to the end of thing within spaces."
  (re-search-forward (rx whitespace))
  (backward-char 1))

(put 'thing-within-spaces 'beginning-op 'rcd-tap-thing-within-spaces-start)
(put 'thing-within-spaces 'end-op 'rcd-tap-thing-within-spaces-end)

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: [External] : ThingAtPointPlus, and extending things at point
  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
  1 sibling, 1 reply; 19+ messages in thread
From: Jean Louis @ 2023-01-06 16:23 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

* Drew Adams <drew.adams@oracle.com> [2023-01-05 20:00]:
> 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).

Yes, I have to adopt that approach, you use this:

(require 'naked nil t) ;; (no error if not found): naked-key-description

and then

(if (fbound 'naked-function)
    (naked-function)
  (otherwise-normal-function))

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

I see 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

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

Yes, I was thinking you made it so, low level.

> You might also be interested in my `find-where.el'.

I use following `cond' statement to find your library `find-where.el'
as people often quote in this way `'. What is the name of that type of
quoting?

The action button moves me to find-where.el

	((thing-at-point 'thing-within-grave-and-apostrophe)
	 (let ((thing (thing-at-point 'thing-within-grave-and-apostrophe)))
	   (cond ((file-exists-p thing) (find-file thing))
		 ((and (string-match "\\.el$" thing)
		       (locate-library (substring thing 0 (- (length thing) 3))))
		  (find-library thing)))))

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.

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

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

Thanks.

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

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : ThingAtPointPlus, and extending things at point
  2023-01-06 16:23       ` Jean Louis
@ 2023-01-06 17:30         ` Drew Adams
  2023-01-06 17:43           ` Jean Louis
  0 siblings, 1 reply; 19+ messages in thread
From: Drew Adams @ 2023-01-06 17:30 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

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


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

* Re: [External] : ThingAtPointPlus, and extending things at point
  2023-01-06 17:30         ` Drew Adams
@ 2023-01-06 17:43           ` Jean Louis
  2023-01-06 18:21             ` Drew Adams
  0 siblings, 1 reply; 19+ messages in thread
From: Jean Louis @ 2023-01-06 17:43 UTC (permalink / raw)
  To: Drew Adams; +Cc: Help GNU Emacs

Thanks.

* Drew Adams <drew.adams@oracle.com> [2023-01-06 20:30]:
> > 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?

My above expression was not well. It was meant to be this way:

Thanks, I find the function `fw-to-next-thing' very useful in this
unification of functions, I am trying to create.

My unification of functions is reinventing the wheel what GNU
Hyperbole already has, with extensions.


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* RE: [External] : ThingAtPointPlus, and extending things at point
  2023-01-06 17:43           ` Jean Louis
@ 2023-01-06 18:21             ` Drew Adams
  0 siblings, 0 replies; 19+ messages in thread
From: Drew Adams @ 2023-01-06 18:21 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

> > > 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?
> 
> My above expression was not well. It was meant to be this way:
> 
> Thanks, I find the function `fw-to-next-thing' very useful in this
> unification of functions, I am trying to create.
> 
> My unification of functions is reinventing the wheel what GNU
> Hyperbole already has, with extensions.

Got it.  Thx for the clarification.

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

end of thread, other threads:[~2023-01-06 18:21 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.