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

Using avy-goto-word-1 in a wrapper #46

Closed
kaushalmodi opened this issue May 18, 2015 · 2 comments
Closed

Using avy-goto-word-1 in a wrapper #46

kaushalmodi opened this issue May 18, 2015 · 2 comments

Comments

@kaushalmodi
Copy link

Can you suggest how I can get this functionality without using call-interactively?

(defun my/avy (arg)
      "
        `my/avy' -> `avy-goto-word-1'
    C-u `my/avy' -> `avy-goto-char-2'
C-u C-u `my/avy' -> `avy-goto-line'
"
      (interactive "p")
      (let ((avy-all-windows t) ; search in all windows
            (fci-state-orig fci-mode)
            (fn (cl-case arg
                  (4  'avy-goto-char-2) ; C-u
                  (16 'avy-goto-line) ; C-u C-u
                  (t  'avy-goto-word-1))))
        (if fci-state-orig
            (fci-mode 'toggle))
        (funcall fn)
        (if fci-state-orig
            (fci-mode 'toggle))))

The above wrapper function breaks because now the first arg to avy-goto-word-1 is a manadatory arg char; earlier its only arg was an optional arg to toggle avy-all-windows.

I cannot use call-interactively because then my wrapper function arg gets passed on to the function I am calling interactively.

@abo-abo
Copy link
Owner

abo-abo commented May 18, 2015

What's fci-mode?

In any case, this works:

(defun my/avy (arg)
  "
        `my/avy' -> `avy-goto-word-1'
    C-u `my/avy' -> `avy-goto-char-2'
C-u C-u `my/avy' -> `avy-goto-line'
"
  (interactive "p")
  (let ((avy-all-windows t)
        (fn (cl-case arg
              (4 'avy-goto-char-2)
              (16 'avy-goto-line)
              (t 'avy-goto-word-1)))
        (current-prefix-arg nil))
    (call-interactively fn)))

@kaushalmodi
Copy link
Author

Thanks! (current-prefix-arg nil) is what I needed.

fci-mode is a package that shows a vertical line overlay at your set fill column. It's a helful indicator to tell you how long your code lines should be.

The issue is that the overlay messes up the avi overlays and overlays in many other packages. So it is helpful to disable it temporarily.

Not disabling this temporarily causes this display anomaly. The gray line on the right is the _fci_.

clipboard01

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