help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Any packages using ThingAtPointPlus for activation?


From: Drew Adams
Subject: RE: [External] : Any packages using ThingAtPointPlus for activation?
Date: Mon, 2 Jan 2023 17:08:19 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]