Comments (3)
Sorry for the late response. This would be a really useful feature and a PR is more than welcome! Have you thought about how it's gonna work? It simply fails when there are duplicate heads?
from major-mode-hydra.el.
Sorry for the late response. This would be a really useful feature and a PR is more than welcome! Have you thought about how it's gonna work? It simply fails when there are duplicate heads?
Yes, I implement a simple example in the function major-mode-hydra-generate
(defun major-mode-hydra--generate (mode body heads-plist &optional overwrite-p)
"Generate a major mode hydra for given MODE with given BODY and HEADS-PLIST.
Overwrite existing hydra if OVERWRITE-P is t, otherwise add new heads to it."
(let* ((hydra-name (major-mode-hydra--name-for mode))
(title (when (functionp major-mode-hydra-title-generator)
(funcall major-mode-hydra-title-generator mode)))
(letter-sequence (seq-mapcat (lambda (x)
(seq-map #'car x))
(seq-filter #'listp heads-plist)))
(body (-> body
(lax-plist-put :hint nil)
(major-mode-hydra--put-if-absent :color 'teal)
(major-mode-hydra--put-if-absent :title title)
(major-mode-hydra--put-if-absent :separator major-mode-hydra-separator)
(major-mode-hydra--put-if-absent :quit-key major-mode-hydra-invisible-quit-key)))
(df (if overwrite-p 'pretty-hydra-define 'pretty-hydra-define+)))
(if (equal (-distinct letter-sequence) letter-sequence)
`(,df ,hydra-name ,body ,heads-plist)
(error "There are letters duplicated in the hydra"))))
It extracts the letters from the heads-plist
variable and check if they are duplicates.
This seems to work, but there is probably a faster way to get the letters.
What do you think?
Regards
from major-mode-hydra.el.
Hi @Sasanidas,
Thanks for posting your code snippet. Yes I think it should work. I do have a couple of suggestions though:
- Perhaps you can implement this check in
pretty-hydra-generate
so that it's more generic. You'll find that it's also easier to get all the keys as there is aheads
binding which you can extract keys from. - Could you stick to
-map
and-filter
functions provided bydash.el
to keep it consistent? That's the library I use for sequence manipulation - Would be awesome if the error message mentions the duplicate key(s)
If you're keen, feel free to submit a PR!
from major-mode-hydra.el.
Related Issues (20)
- Pretty hydras not getting a big enough posframe HOT 4
- How to implement inheritance and mixing? HOT 2
- Hydras and global key bindings HOT 4
- Dynamic Title with pretty hydra HOT 2
- Calling a pretty hydra gives "wrong type argument" error HOT 3
- pretty-hydra: The caret character "^" is not displayed properly HOT 3
- major-mode-hydra: Unrecognized keyword mode-hydra in use-package HOT 3
- missing one line with posframe HOT 4
- Differences between hydra and pretty-hydra? HOT 2
- pretty-hydra: columns cannot left-justified, how to solve it? HOT 7
- macro argument HOT 3
- Composing hydras / minor mode support again HOT 4
- how to add a head but hide it from the actual menu HOT 2
- What is with-faicon? HOT 2
- Multibyte characters will be displayed incorrectly. HOT 5
- Add customizable title formatter
- Hide menu? HOT 1
- ⛔ Error (use-package): use-package: Unrecognized keyword: :pretty-hydra HOT 10
- Hydra Generator Helper Function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from major-mode-hydra.el.