universal-ctags / citre

A superior code reading & auto-completion tool with pluggable backends.
GNU General Public License v3.0
320 stars 26 forks source link

Finding definitions Failed Fallback and Exposing Identifier for Lookup #169

Closed t6ui closed 3 months ago

t6ui commented 3 months ago
(defun citre-jump-or-grep ()
  (interactive)
  (require 'citre)
  (let* ((identifier (if (region-active-p)
                         (buffer-substring-no-properties (region-beginning) (region-end))
                       (thing-at-point 'symbol t)))
         (defs (citre-get-definitions))
         (buf (current-buffer)))
    (if (null defs)
        (consult-ripgrep current-prefix-arg identifier)
      (progn (citre-jump-show defs)
             (citre-after-jump-action buf)))))

I have been working on a custom function named citre-jump-or-grep to improve my workflow. While implementing this function, I identified a couple of potential enhancements that could benefit other users as well:

  1. Introduction of an Error Fallback Hook: Would it be possible to introduce a new variable, potentially named citre-jump-error-fallback-function, that users could customize?
  2. Exposing the Searched Identifier: Could the package be enhanced to expose the identifier that citre is attempting to find? Having this identifier readily available would facilitate users in extending functionality, reducing the need to retrieve the identifier manually within their custom functions.

Best regards!

AmaiKinono commented 3 months ago

Introduction of an Error Fallback Hook

I don't think this is within the scope of Citre, as users could wrap Citre commands to create their own command rather easily.

However, we may want to modify Citre commands, so when they are not called interactively, they should return a fail status rather than throwing an error. This will make it easier for users to wrap Citre commands.

Exposing the Searched Identifier

Citre's symbol-at-point function is defined in the tags backend. Although it's largely customized for the tags backend, it is also used by global backend and another backend I'm currently working on, so the dependency is a bit messy here.

There are plans to extract at least part of it to form a basis for all backends. When that's done, we could expose a user API from it.

t6ui commented 3 months ago

@AmaiKinono Understood, thank you.