Open cyruseuros opened 5 years ago
Could you provide an example usage that isn't working (including the state in org mode you are in)? That seems to be fine for me.
As a side note, you don't have to use lists for :keymaps
and :major-modes
if there is only one map/mode.
just in case there is something weird about my config, here's the whole :general
bock of my
org-mode
use-package call:
(my:org:general-def
"C" '(:ignore t :wk "clock")
"Cc" #'org-clock-cancel
"Cd" #'org-clock-display
"Ce" #'org-evaluate-time-range
"Cg" #'org-clock-goto
"Ci" #'org-clock-in
"CI" #'org-clock-in-last
"Cj" #'spacemacs/org-clock-jump-to-current-clock
"Co" #'org-clock-out
"CR" #'org-clock-report
"Cr" #'org-resolve-clocks
"d" '(:ignore t :wk "date")
"dd" #'org-deadline
"ds" #'org-schedule
"dt" #'org-time-stamp
"dT" #'org-time-stamp-inactive
"ee" #'org-export-dispatch
"fi" #'org-feed-goto-inbox
"fu" #'org-feed-update-all
"a" #'org-agenda
"p" #'org-priority
"T" '(:ignore t :wk "toggle")
"Tc" #'org-toggle-checkbox
"Te" #'org-toggle-pretty-entities
"Ti" #'org-toggle-inline-images
"Tl" #'org-toggle-link-display
"Tt" #'org-show-todo-tree
"TT" #'org-todo
"TV" #'space-doc-mode
"Tx" #'org-toggle-latex-fragment
"L" #'org-shiftright
"H" #'org-shiftleft
"J" #'org-shiftdown
"K" #'org-shiftup
"C-S-l" #'org-shiftcontrolright
"C-S-h" #'org-shiftcontrolleft
"C-S-j" #'org-shiftcontroldown
"C-S-k" #'org-shiftcontrolup
"s" '(:ignore t :wk "subtree")
"sa" #'org-toggle-archive-tag
"sA" #'org-archive-subtree
"sb" #'org-tree-to-indirect-buffer
"sd" #'org-cut-subtree
"sh" #'org-promote-subtree
"sj" #'org-move-subtree-down
"sk" #'org-move-subtree-up
"sl" #'org-demote-subtree
"sn" #'org-narrow-to-subtree
"sN" #'widen
"sr" #'org-refile
"ss" #'org-sparse-tree
"sS" #'org-sort
"t" '(:ignore t :wk "table")
"ta" #'org-table-align
"tb" #'org-table-blank-field
"tc" #'org-table-convert
"td" '(:ignore t :wk "delete")
"tdc" #'org-table-delete-column
"tdr" #'org-table-kill-row
"te" #'org-table-eval-formula
"tE" #'org-table-export
"th" #'org-table-previous-field
"tH" #'org-table-move-column-left
"ti" '(:ignore t :wk "insert")
"tic" #'org-table-insert-column
"tih" #'org-table-insert-hline
"tiH" #'org-table-hline-and-move
"tir" #'org-table-insert-row
"tI" #'org-table-import
"tj" #'org-table-next-row
"tJ" #'org-table-move-row-down
"tK" #'org-table-move-row-up
"tl" #'org-table-next-field
"tL" #'org-table-move-column-right
"tn" #'org-table-create
"tN" #'org-table-create-with-table.el
"tr" #'org-table-recalculate
"ts" #'org-table-sort-lines
"tt" '(:ignore t :wk "toggle")
"ttf" #'org-table-toggle-formula-debugger
"tto" #'org-table-toggle-coordinate-overlays
"tw" #'org-table-wrap-region
"b" '(:ignore t :wk "babel")
"bp" #'org-babel-previous-src-block
"bn" #'org-babel-next-src-block
"be" #'org-babel-execute-maybe
"bo" #'org-babel-open-src-block-result
"bv" #'org-babel-expand-src-block
"bu" #'org-babel-goto-src-block-head
"bg" #'org-babel-goto-named-src-block
"br" #'org-babel-goto-named-result
"bb" #'org-babel-execute-buffer
"bs" #'org-babel-execute-subtree
"bd" #'org-babel-demarcate-block
"bt" #'org-babel-tangle
"bf" #'org-babel-tangle-file
"bc" #'org-babel-check-src-block
"bj" #'org-babel-insert-header-arg
"bl" #'org-babel-load-in-session
"bi" #'org-babel-lob-ingest
"bI" #'org-babel-view-src-block-info
"bz" #'org-babel-switch-to-session
"bZ" #'org-babel-switch-to-session-with-code
"ba" #'org-babel-sha1-hash
"bx" #'org-babel-do-key-sequence-in-edit-buffer
;; "b." #'spacemacs/org-babel-transient-state/body
"," #'org-ctrl-c-ctrl-c
"*" #'org-ctrl-c-star
"-" #'org-ctrl-c-minus
"#" #'org-update-statistics-cookies
"RET" #'org-ctrl-c-ret
"M-RET" #'org-meta-return
"A" #'org-attach
"i" '(:ignore t :wk "insert")
"ib" #'org-insert-structure-template
"id" #'org-insert-drawer
"ie" #'org-set-effort
"if" #'org-footnote-new
"ih" #'org-insert-heading
"iH" #'org-insert-heading-after-current
"ii" #'org-insert-item
"il" #'org-insert-link
"in" #'org-add-note
"ip" #'org-set-property
"is" #'org-insert-subheading
"it" #'org-set-tags-command)
When I hit ,
in normal, visual, lisp or any other state I listed above, it simply gives me "no previous search". I also tried listing override
as one of the keymaps, though I'd rather not be so brutish. That did not work either.
my:org:command
is also not defined as a function, while my:elisp:command
is.
Update:
When I manually evaluate the general-create-definer
block form above (which
is inside my org :init
where everything else, including setq
s are getting
executed properly) everything works.
Screw it, here's the whole thing, in case my explanation sucks:
(use-package org
:straight org-plus-contrib
:after (general)
:init (progn
(load-file (straight--repos-file
"spacemacs" "layers" "+emacs"
"org" "funcs.el"))
(setq org-agenda-files "~/Sync/org/agendarc"
org-todo-keywords
'((sequence "TODO" "|"
"DONE" "CANCELED" "NODO")))
(my:core:general-def
"o" '(:ignore t :wk "org")
"o#" #'org-agenda-list-stuck-projects
"o/" #'org-occur-in-agenda-files
"oa" #'org-agenda-list
"oc" #'org-capture
"oe" #'org-store-agenda-views
"ol" #'org-store-link
"om" #'org-tags-view
"oo" #'org-agenda
"op" #'org-projectile-capture-for-current-project
"os" #'org-search-view
"ot" #'org-todo-list
"oC" '(nil :wk "clock")
"oCc" #'org-clock-cancel
"oCg" #'org-clock-goto
"oCI" #'org-clock-in-last
"oCi" #'org-clock-in
"oCj" #'org-clock-jump-to-current-clock
"oCo" #'org-clock-out
"oCO" #'org-clock-out-if-current
"oCr" #'org-resolve-clocks
"of" '(:ignore t :wk "feeds")
"ofi" #'org-feed-goto-inbox
"ofu" #'org-feed-update-all)
(general-create-definer my:org:general-def
:wrapping my:core:mmode-general-def
:prefix-command 'my:org:command
:prefix-map 'my:org:map))
:hook (after-init . (lambda () (when (daemonp) org-agenda-list)))
:general (my:org:general-def
"C" '(:ignore t :wk "clock")
"Cc" #'org-clock-cancel
"Cd" #'org-clock-display
"Ce" #'org-evaluate-time-range
"Cg" #'org-clock-goto
"Ci" #'org-clock-in
"CI" #'org-clock-in-last
"Cj" #'spacemacs/org-clock-jump-to-current-clock
"Co" #'org-clock-out
"CR" #'org-clock-report
"Cr" #'org-resolve-clocks
"d" '(:ignore t :wk "date")
"dd" #'org-deadline
"ds" #'org-schedule
"dt" #'org-time-stamp
"dT" #'org-time-stamp-inactive
"ee" #'org-export-dispatch
"fi" #'org-feed-goto-inbox
"fu" #'org-feed-update-all
"a" #'org-agenda
"p" #'org-priority
"T" '(:ignore t :wk "toggle")
"Tc" #'org-toggle-checkbox
"Te" #'org-toggle-pretty-entities
"Ti" #'org-toggle-inline-images
"Tl" #'org-toggle-link-display
"Tt" #'org-show-todo-tree
"TT" #'org-todo
"TV" #'space-doc-mode
"Tx" #'org-toggle-latex-fragment
"L" #'org-shiftright
"H" #'org-shiftleft
"J" #'org-shiftdown
"K" #'org-shiftup
"C-S-l" #'org-shiftcontrolright
"C-S-h" #'org-shiftcontrolleft
"C-S-j" #'org-shiftcontroldown
"C-S-k" #'org-shiftcontrolup
"s" '(:ignore t :wk "subtree")
"sa" #'org-toggle-archive-tag
"sA" #'org-archive-subtree
"sb" #'org-tree-to-indirect-buffer
"sd" #'org-cut-subtree
"sh" #'org-promote-subtree
"sj" #'org-move-subtree-down
"sk" #'org-move-subtree-up
"sl" #'org-demote-subtree
"sn" #'org-narrow-to-subtree
"sN" #'widen
"sr" #'org-refile
"ss" #'org-sparse-tree
"sS" #'org-sort
"t" '(:ignore t :wk "table")
"ta" #'org-table-align
"tb" #'org-table-blank-field
"tc" #'org-table-convert
"td" '(:ignore t :wk "delete")
"tdc" #'org-table-delete-column
"tdr" #'org-table-kill-row
"te" #'org-table-eval-formula
"tE" #'org-table-export
"th" #'org-table-previous-field
"tH" #'org-table-move-column-left
"ti" '(:ignore t :wk "insert")
"tic" #'org-table-insert-column
"tih" #'org-table-insert-hline
"tiH" #'org-table-hline-and-move
"tir" #'org-table-insert-row
"tI" #'org-table-import
"tj" #'org-table-next-row
"tJ" #'org-table-move-row-down
"tK" #'org-table-move-row-up
"tl" #'org-table-next-field
"tL" #'org-table-move-column-right
"tn" #'org-table-create
"tN" #'org-table-create-with-table.el
"tr" #'org-table-recalculate
"ts" #'org-table-sort-lines
"tt" '(:ignore t :wk "toggle")
"ttf" #'org-table-toggle-formula-debugger
"tto" #'org-table-toggle-coordinate-overlays
"tw" #'org-table-wrap-region
"b" '(:ignore t :wk "babel")
"bp" #'org-babel-previous-src-block
"bn" #'org-babel-next-src-block
"be" #'org-babel-execute-maybe
"bo" #'org-babel-open-src-block-result
"bv" #'org-babel-expand-src-block
"bu" #'org-babel-goto-src-block-head
"bg" #'org-babel-goto-named-src-block
"br" #'org-babel-goto-named-result
"bb" #'org-babel-execute-buffer
"bs" #'org-babel-execute-subtree
"bd" #'org-babel-demarcate-block
"bt" #'org-babel-tangle
"bf" #'org-babel-tangle-file
"bc" #'org-babel-check-src-block
"bj" #'org-babel-insert-header-arg
"bl" #'org-babel-load-in-session
"bi" #'org-babel-lob-ingest
"bI" #'org-babel-view-src-block-info
"bz" #'org-babel-switch-to-session
"bZ" #'org-babel-switch-to-session-with-code
"ba" #'org-babel-sha1-hash
"bx" #'org-babel-do-key-sequence-in-edit-buffer
;; "b." #'spacemacs/org-babel-transient-state/body
"," #'org-ctrl-c-ctrl-c
"*" #'org-ctrl-c-star
"-" #'org-ctrl-c-minus
"#" #'org-update-statistics-cookies
"RET" #'org-ctrl-c-ret
"M-RET" #'org-meta-return
"A" #'org-attach
"i" '(:ignore t :wk "insert")
"ib" #'org-insert-structure-template
"id" #'org-insert-drawer
"ie" #'org-set-effort
"if" #'org-footnote-new
"ih" #'org-insert-heading
"iH" #'org-insert-heading-after-current
"ii" #'org-insert-item
"il" #'org-insert-link
"in" #'org-add-note
"ip" #'org-set-property
"is" #'org-insert-subheading
"it" #'org-set-tags-command))
could it be that general still doesn't know the definition of my definer so can't use it in the keyword?
Yep! That's the ticket. Now we're getting into deep macro territory, but is there any way aroudn this save for sticking my bindings in the config block?
The only way :general can know that my:org:general-def
is not a keymap or state name is if it is a function or macro. I could add a distinct keyword for using custom functions, but otherwise, you'll have to create the definer before the use-package
statement.
Honestly, I don't mind doing that, but here's my 2 cents:
Since general automatically waits for keymaps to be defined, it basically solves the use-package load order problem, i.e. :after
only applying to :init
not :config
(which causes a lot of problems with keymaps if you choose not to nest). If it were possible to specify these functions within a use-package call too, it would essentially also be possible to specify your config in completely arbitrary order. You could send someone your use-package call and it would either not load or work out of the box.
But again, this is a really small thing, and I'm guessing there are more important things to work on.
Thank you again for writing this. You're a legend.
You could send someone your use-package call and it would either not load or work out of the box.
They'd still have to general installed. There's also not much of a difference between just including the definer before the use-package call in the snippet. That said I'd be fine with adding another keyword like :general-custom
if you want it. Your example is not possible otherwise.
Personally I only use :general for keybindings meant to load the package.
Holly shit man, you made a beautiful beast. Left Spacemacs in a second.
That being said, I am still struggling with this little lady: My major mode bindings are only working for
emacs-lisp-mode
. Any clues as to why?I tried with and without the
:states
keyword, among other things, but only my elisp stuff gets bound. Org-mode (and python) get nothing. I feel like I'm missing something super simple, but I've been staring at it for a day now with no luck.