Git Product home page Git Product logo

fancy-dabbrev's People

Contributors

ideasman42 avatar jrosdahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fancy-dabbrev's Issues

Request/Suggestion: support a customizable tab function

I use tab-to-tab-stop as the action for pressing tab, however fancy-dabbrev assumes indent-for-tab-command, this also means it's less practical to assign fancy-dabbrev-expand-or-indent to other keys.

Example using advice to workaround this (see link)


Suggestions:

  • Add a customizable fancy-dabbrev-indent-function which could point to 'tab-to-tab-stop for example.
  • Add a version of fancy-dabbrev-expand-or-indent that returns t on success, nil in the case indent would run (may be nice to do this with fancy-dabbrev-expand-or-indent so it could be used to construct functionality defined in elisp).

It doesn't work in orgmode

It works in my init.el file, but it doesn't work in my .org files.
It looks great, I hope that could be solved.

These are my settings:

;; Load fancy-dabbrev.el:
(require 'fancy-dabbrev)
;; Enable fancy-dabbrev previews everywhere:
(global-fancy-dabbrev-mode)
;; Bind fancy-dabbrev-expand and fancy-dabbrev-backward to your keys of
;; choice, here "TAB" and "Shift+TAB":
(global-set-key (kbd "TAB") 'fancy-dabbrev-expand)
(global-set-key (kbd "<backtab>") 'fancy-dabbrev-backward)
;; If you want TAB to indent the line like it usually does when the cursor
;; is not next to an expandable word, use 'fancy-dabbrev-expand-or-indent
;; instead of `fancy-dabbrev-expand`:
;; (global-set-key (kbd "TAB") 'fancy-dabbrev-expand-or-indent)
;; (global-set-key (kbd "<backtab>") 'fancy-dabbrev-backward)
(require 'popup)

dabbrev--substitute-expansion: Wrong type argument: arrayp, nil

Tried out the package after your latest updates, works find with a clean configuration but after applying some configuration of dabbrev I get the error stated in the title. The error appears when I execute fancy-dabbrev-expand the second time, first time there are no problems.

I just discovered this and haven't had time to dig into what part of the configuration is causing this but it is one of these lines.

(use-package dabbrev
  :straight (:type built-in)
  :custom
  (dabbrev-case-replace nil)
  (dabbrev-backward-only nil)
  (dabbrev-case-distinction nil)
  (dabbrev-case-fold-search t)
  (dabbrev-check-all-buffers t)
  (dabbrev-abbrev-char-regexp nil)
  (dabbrev-eliminate-newlines nil)
  (dabbrev-check-other-buffers t)
  (dabbrev-upcase-means-case-search t))

I will try to have a look at this myself but perhaps you can spot the bug in your code or if I have some invalid configuration.

Thansk for a great package!

Making sure case matches the sentence

Hi,

Not sure if this is a fancy-dabbrev or dabbrev issue, but what is the best way to make sure the expanded word matches expected case?

For example, when I write "we need to l", fancy-dabbrev suggests to expand the last character to "look", which is great, but when I complete the word it comes out as "we need to Look". Is there a setting to match the already started case (so L expands to Look and l expands to look) or make sure the expansion is always lowercase?

Thank you and apologies if this is already covered by documentation. I reviewed the existing configuration settings and could not really find one that fits the bill.

Edgars

Request/Suggestion: support for limiting completion to when the preview is visible

Hi, this is an incredibly handy package, I've managed to tweak it's behavior using advice but thought it would be worth posting an issue, since the functionality could be supported more cleanly in the package.

My preferred default behavior when pressing the complete key is as follows:

  • When there is a preview, complete.
  • When there isn't, perform indent-for-tab-command.

Currently I sometimes press the key for fancy-dabbrev-expand-or-indent and even when no completion is possible, it's showing an error instead of calling indent-for-tab-command.

I've managed to workaround this (see link)


This could be solved in a few ways, some suggestions:

  • Add (fancy-dabbrev-is-showing-preview) so anyone who wants to check this can do so easily & customize the exact behavior.
  • Add a custom setting so complete is only attempted when the preview is visible.

Note that I'm happy to submit a PR for any of these.

Ability to preview and expand next word

Dabbrev supports expanding also after a space character. E.g. after having "detail " in my text and doing dabbrev-expand I get "detail oriented".

It appears fancy dabbrev does not support showing a preview and expanding also after a space character. So in my case after "detail " I would already see the preview for the next word "oriented".

Would it be possible to add this feature?

Thank you,

Edgars

Making fancy-dabbrev expansion triggers more configurable

I like the lightweight fancy-dabbrev popoup and want to experiment with using it more. But as with #13 and #11, the global binding of tab is a bit brittle, so I was thinking about what one could do there.

Also, I intuitively want to hit arrow keys and return to select a completion from the popup window instead of tab, so tweaking key bindings was on my mind anyway.

Here's a couple of ideas I'd like to share to see if they're any good :)

  • Introduce an alist (I think?) like fancy-dabbrev-indent-command-per-mode that pairs mode names with their tab key overrides to make fancy-dabbrev-expand-or-indent flexible enough to call not just 1 globally set fancy-dabbrev-indent-command, but whichever command is needed by a mode.
    • Org uses org-cycle that wraps indent-for-tab-command in some special case handling, for example. Other modes can do the same. Users would expect the default tab behavior to be retained, but fancy-dabbrev-expand-or-indent at the moment would enforce indent-for-tab-command, which might not always be accurate. Should help with #13?
    • fancy-dabbrev-expand-or-indent could be extended: match the current (major) mode to an entry from the fancy-dabbrev-indent-command-per-mode, falling back to fancy-dabbrev-indent-command if none is found.
    • Alternative considered: users can use add-hook to change the fancy-dabbrev-indent-command variable on a per-mode basis.
  • Use a transient key map when the popup is visible for fancy-dabbrev bindings.
    • Users can configure their key bindings for fancy-dabbrev actions in the transient keymap. E.g. I could add arrow key support in my init.el to select prev/next suggestion, and RET to expand, too, without a global key binding of RET similar to how TAB and fancy-dabbrev-expand-or-indent are bound.
    • Binding the tab key in a transient map should "win" over buffer- or mode-local key bindings. So fancy-dabbrev could just bind tab to fancy-dabbrev-expand. If no dabbrev is active, the transient map is not active, and tab does what it would do usually. (I need to test this more to check if that's true.)
    • This package could ditch the approach of a global key binding for fancy-dabbrev-expand-or-indent with its fallback to the default tab function completely, because the transient key map is not active most of the time.
    • Downsides: This assumes that dabbrev "just works" when users type, and that the fancy-dabbrev popup is triggered reliably, i.e. modes don't mess with that or prevent it from working. Global tab key binding triggering a fancy-dabbrev function might work more reliably if this isn't the case?

What do you think?

Message suppression isn't working for `*Messages*`

When typing with fancy-dabbrev mode my message buffer is flooded with Scanning for dabbrevs...done:

(tested with emacs28 from master).

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Scanning for dabbrevs...done

Temporary disabling make-progress-reporter, progress-reporter-update & progress-reporter-done should resolve the issue.

Advising these functions with a disabled message function could also work.

I use this macro for tasks like this:

(defmacro fancy-dabbrev--with-advice (fn-orig where fn-advice &rest body)
  "Execute BODY with advice added WHERE using FN-ADVICE temporarily added to FN-ORIG."
  `
  (let ((fn-advice-var ,fn-advice))
    (unwind-protect
      (progn
        (advice-add ,fn-orig ,where fn-advice-var)
        ,@body)
      (advice-remove ,fn-orig fn-advice-var))))

TAB: using fancy-dabbrev-expand-or-indent breaks TAB on Magit

Hello,

you say:

;; If you want TAB to indent the line like it usually does when the cursor
;; is not next to an expandable word, use 'fancy-dabbrev-expand-or-indent
;; instead of `fancy-dabbrev-expand`:
(global-set-key (kbd "<tab>") 'fancy-dabbrev-expand-or-indent)

but it breaks TAB on a Magit buffer. There, TAB is bound to magit-section-toggle.

It probably breaks other modes.

I am not sure on the best fix.

Thanks for the package! cheers

Is it possible to do expansion for "."

Lets say I have:

foo.hello
foo.bye

foo.

When I have the cursor after the ".", and I do try to do fancy-dabbrev-expand it doesn't work

I get:

syntax: ((statement 42211)), indent: 28

Why is that?

Add minor mode keymap so that tab & shift-tab are bound by default when fancy-dabbrev is active.

Hi thanks for writing this, I was using pabbrev before and this is much better.

The only annoyance I found so far is that setting the global "TAB" key doesnt work in a lot of modes since its often used for language specific indentation and other features. (I did notice #14 and another issue related to org mode which seem to be similar).

I lifted some code from pabbrev and patched fancy-dabbrev.el to fix this:

diff --git fancy-dabbrev.el fancy-dabbrev.el
index be7e1914f4b5351a3d3974f37024bbecbf905ebb..cfea313bd095aab5f3aafbbbeae16b3ea9eedf4a 100644
--- fancy-dabbrev.el
+++ fancy-dabbrev.el
@@ -614,6 +614,21 @@ That is, if `this-command' is not one of
   (when (fancy-dabbrev--is-fancy-dabbrev-command last-command)
     (fancy-dabbrev--insert-expansion fancy-dabbrev--entered-abbrev)))
 
+;; Pierre: This should do the basic to hook tab & shift-tab to
+;; fancy-dabbrev-expand. This is lifted from pabbrev, that mode also keep
+;; track of the previous binding to tab and call it, I assume when there's no
+;; expansion, which is probably ideal but its a fair bit of code I dont
+;; understand and this is all I need for now.
+(defvar fancy-dabbrev-mode-map
+  (let ((map (make-sparse-keymap)))
+    ;; \t works in tty but gets overridden by the [tab] binding elsewhere.
+    (define-key map "\t" 'fancy-dabbrev-expand-or-indent)
+    ;; This is not needed since function-key-map remaps a `tab' into a \t.
+    ;; (define-key map (kbd "TAB") 'fancy-dabbrev-expand)
+    (define-key map (kbd "<backtab>") 'fancy-dabbrev-backward)
+    map)
+  "Keymap for fancy-dabbrev-minor-mode.")
+
 ;;;###autoload
 (define-minor-mode fancy-dabbrev-mode
   "Toggle `fancy-dabbrev-mode'.
@@ -624,6 +639,7 @@ the mode if ARG is omitted or nil.
 
 When `fancy-dabbrev-mode' is enabled, fancy-dabbrev's preview
 functionality is activated."
+  :keymap fancy-dabbrev-mode-map
   :lighter " FD"
   :init-value nil
   (if fancy-dabbrev-mode

There's probably a more configurable way to do this but this is good enough for my use cases, hopefully this is helpful for others.

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.