Git Product home page Git Product logo

Comments (2)

jrosdahl avatar jrosdahl commented on June 9, 2024

Hi,

Thanks for the list of ideas! I don't think I'll have time to think them through in detail, but some quick comments:

I intuitively want to hit arrow keys and return to select a completion from the popup window instead of tab

I major reason for writing fancy-dabbrev in the first place was that I didn't find a completion package that supported "one key does it all" behavior just like plain dabbrev-expand works. Here's a more detailed discussion. I'm spontaneously not interested in making fancy-dabbrev work like e.g. company-mode where you select candidates with arrow keys since that would just duplicate functionality and make things more complex. Perhaps there is a way for you to customize company-mode instead, using dabbrev as a backend?

Alternative considered: users can use add-hook to change the fancy-dabbrev-indent-command variable on a per-mode basis.

That's what I would suggest to keep things simple.

from fancy-dabbrev.

akirak avatar akirak commented on June 9, 2024

Hello, after experimenting with this package for a while, I reached the following solution:

(defcustom fancy-dabbrev-expansion-key "TAB"
  ""
  :type 'string)

(defun fancy-dabbrev-remap (map)
  (let* ((mode-cmd (keymap-lookup map fancy-dabbrev-expansion-key))
         (remapped-cmd (or mode-cmd
                           (with-temp-buffer
                             (keymap-lookup global-map fancy-dabbrev-expansion-key))))
         (fallback-cmd (or mode-cmd
                           (command-remapping remapped-cmd nil map)))
         (wrapper-cmd (intern (concat "fancy-dabbrev-expand-or-" (symbol-name fallback-cmd)))))
    (fset wrapper-cmd
          `(lambda ()
             (interactive)
             (let ((fancy-dabbrev-indent-command ',fallback-cmd))
               (fancy-dabbrev-expand-or-indent))))
    (define-key map (vector 'remap remapped-cmd) wrapper-cmd)))

With this function, you can remap the key on each map (see below), which would be suitable for use in one's init.el:

(with-eval-after-load 'org-keys
  (fancy-dabbrev-remap org-mode-map))

This seems to work for both major and minor mode maps.

I personally prefer the following wrapper definition. I am using C-e as the expansion key:

;;; Expand the dabbrev only after a self-insertion command, only once
`(lambda ()
    (interactive)
    (if (memq last-command fancy-dabbrev-self-insert-commands)
         (let ((fancy-dabbrev-indent-command ',fallback-cmd))
            (fancy-dabbrev-expand-or-indent))
       (call-interactively ',fallback-cmd)))

What do you think?

from fancy-dabbrev.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.