Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avy-dispatch-alist to invoke "isearch-forward-symbol-at-point" on C-s #356

Open
CDitzel opened this issue Nov 16, 2022 · 2 comments
Open

Comments

@CDitzel
Copy link

CDitzel commented Nov 16, 2022

I bound avy-goto-char-timer to C-j. And now I want to bind "isearch-forward-symbol-at-point" to C-j C-s.

I tried to extend the list


(defun avy-highlight-symbol (pt)
(isearch-forward-symbol-at-point pt)
t)
(setf (alist-get ?\C-s avy-dispatch-alist) 'avy-highlight-symbol)

but that does not seem to work. Any ideas how to do that?

@kevinfis
Copy link

If you just want to set "C-s" as bind in avy,
go to avy.el and to find function name:
defcustom avy-dispatch-alist

You can find it's type is character:
:key-type (choice (character :tag "Char")
change it to string:
:key-type (choice ( string :tag "Char")
then eval function: defcustom` avy-dispatch-alist
(by the way, this is not working with M-s,
because the function:(char-to-string (car x)) of avy-show-dispatch-help only accept char type.)

I have tried with cmd: avy-action-kill-move ,it works with C-s.
but for you function, it is not work,
because i am not totally understand elisp ( i just know the type of alist recently),
so maybe you need to reference the function of avy-action-copy in the avy.el
to improve your 'avy-highlight-symbol' function,
or someone familiar could help you.

@kevinfis
Copy link

kevinfis commented Nov 30, 2022

update:
after test, my previous post is bad idea,
if someone want to use Meta or Ctrl key in avy-action(it might be helped to remember less key),
you can refer this post:

  1. get character code, ex:
    (message "%s" ?\M-z) ;; 134217850

  2. redefine: avy-show-dispatch-help:
    (defun avy-show-dispatch-help ()
    "Display action shortucts in echo area."
    (let ((len (length "avy-action-")))
    (message "%s" (mapconcat
    (lambda (x)
    (format "%s: %s "
    (propertize
    ;; redefine =start=
    (if (or (> (car x) 4194304) (= (car x) 32))
    (pcase (car x)
    (32 " ▆▆")
    (67108896 "C-▆▆")
    (134217847 "M-w")
    (134217774 "M-.")
    (134217850 "M-z")
    )
    (char-to-string (car x))
    )
    ;; redefine =end=
    'face 'aw-key-face)
    (substring (symbol-name (cdr x)) len)))
    avy-dispatch-alist
    " "))))

  3. redefine avy-dispatch-alist
    (setq avy-dispatch-alist '((?\ . avy-action-teleport) ;; SPC
    (?\C- . avy-action-mark) ;; C-SPC
    (?\M-w . avy-action-copy)
    (?\M-. . avy-action-yank-line)
    (?\M-z . avy-action-zap-to-char)
    (?x . avy-action-kill-move)
    (?X . avy-action-kill-stay)
    (?t . avy-action-teleport)
    (?y . avy-action-yank)
    (?Y . avy-action-yank-line)
    (?i . avy-action-ispell)
    ))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants