jrosdahl / fancy-dabbrev Goto Github PK
View Code? Open in Web Editor NEWEmacs dabbrev-expand with preview and popup menu
License: BSD 3-Clause "New" or "Revised" License
Emacs dabbrev-expand with preview and popup menu
License: BSD 3-Clause "New" or "Revised" License
Is it possible to add vterm support for commands completion and also completion for files and directories in the cwd.
There is an incomplete solution in the vterm repo.
Do you know how to use dabbrev with a completion framework such as ivy-counsel?
I like to have a command counsel-dabbrev
which just shows me all the dabbrev candidates:
I do not want to use popup menus etc.
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!
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.
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
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
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:
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:
(fancy-dabbrev-is-showing-preview)
so anyone who wants to check this can do so easily & customize the exact behavior.Note that I'm happy to submit a PR for any of these.
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)
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
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))))
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 :)
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-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.add-hook
to change the fancy-dabbrev-indent-command
variable on a per-mode basis.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.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.)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.What do you think?
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?
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:
fancy-dabbrev-indent-function
which could point to 'tab-to-tab-stop
for example.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).A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.