Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
04dcd3a
rewrite keymap system
mahmoodsh36 Jan 14, 2026
eb57d77
introduce keymap-activate and initialize transient.lisp
mahmoodsh36 Jan 14, 2026
7a213e7
add simple popup
mahmoodsh36 Jan 14, 2026
e3f6d6a
make popup more informative
mahmoodsh36 Jan 18, 2026
a3d56b3
improve docstrings a little more
mahmoodsh36 Jan 18, 2026
d8ac6fb
slight refactor
mahmoodsh36 Jan 18, 2026
fdb7bf9
make multi-choice prefix work
mahmoodsh36 Jan 20, 2026
2d7e130
fix order of keymaps (hence fix priorities)
mahmoodsh36 Jan 23, 2026
8fe748d
slight change
mahmoodsh36 Jan 23, 2026
7b9f3a6
add find-prefix-by-id
mahmoodsh36 Jan 23, 2026
42977a4
introduce :back, :cancel suffix values
mahmoodsh36 Jan 23, 2026
7e73c23
rename package to lem/transient
mahmoodsh36 Jan 25, 2026
ebce66e
rename package to lem/transient
mahmoodsh36 Jan 25, 2026
ba5694b
rename package to lem/transient and system to lem-transient
mahmoodsh36 Jan 25, 2026
33cdde7
use "intern" with explicit package name
mahmoodsh36 Jan 27, 2026
d5023be
introduce prefix-behavior, with-last-read-key-sequence, and handle ex…
mahmoodsh36 Jan 28, 2026
2397e14
use :description instead of :name for keymaps
mahmoodsh36 Jan 28, 2026
4d37d35
introduce toggle infix, use prompt for multi-choice infix
mahmoodsh36 Jan 29, 2026
8a418d8
fix vim search
mahmoodsh36 Jan 30, 2026
4b33545
fix undefine-key (actually undefine-key-internal)
mahmoodsh36 Jan 30, 2026
30d4ea5
remvoe some redundant stuff
mahmoodsh36 Jan 30, 2026
79229a8
properly parse keymap keywords in transient, change title styling
mahmoodsh36 Jan 30, 2026
3d8b2d5
small fix
mahmoodsh36 Feb 1, 2026
891b2f3
introduce "intermediate" prefixes
mahmoodsh36 Feb 3, 2026
3ea00ea
introduce *transient-always-show*
mahmoodsh36 Feb 4, 2026
1f3a109
small refactor
mahmoodsh36 Feb 4, 2026
facc26c
introduce multi-value infix to demo
mahmoodsh36 Feb 4, 2026
eb7fc25
remove outdated comment
mahmoodsh36 Feb 5, 2026
caf8743
introduce variable-syncing (sync infix with var)
mahmoodsh36 Feb 5, 2026
06b58e5
add :extend keyword to make-keymap
mahmoodsh36 Feb 7, 2026
f708a1e
add mode-transient-keymap, show extended keymap keys in transient
mahmoodsh36 Feb 7, 2026
0af3651
rename keymap-extend to keymap-base
mahmoodsh36 Feb 7, 2026
64631a3
export more symbols
mahmoodsh36 Feb 12, 2026
feafe41
remove redundant keymap-find-keybind arg and rename it to keymap-find
mahmoodsh36 Feb 13, 2026
d11647b
remove "dynamic properties" and just rely on CLOS
mahmoodsh36 Feb 13, 2026
50be8c8
small fixes
mahmoodsh36 Feb 14, 2026
42158ab
make parse-transient eval values, so that quotes are needed
mahmoodsh36 Feb 17, 2026
9ca5ad6
add bottomside-window and define transient-mode
mahmoodsh36 Feb 17, 2026
e3da420
add scrolling support
mahmoodsh36 Feb 18, 2026
ac9b675
fix horizontal scrolling
mahmoodsh36 Feb 18, 2026
c39df30
set always-show to nil
mahmoodsh36 Feb 18, 2026
a1533e3
remove "dirty" redrawing technique
mahmoodsh36 Feb 18, 2026
24badca
separate child keymaps from prefixes
mahmoodsh36 Feb 19, 2026
6e28acc
handle editor-abort in suffix prompts
mahmoodsh36 Feb 23, 2026
7ea0eda
add define-transient-key
mahmoodsh36 Feb 23, 2026
d811a8b
indentation
mahmoodsh36 Feb 24, 2026
6db325d
add define-prefix, add post-command hook to update popup
mahmoodsh36 Mar 9, 2026
46ebbbe
fix issue: self-insert was being invoked when it shouldnt have been
mahmoodsh36 Mar 9, 2026
1a42a5e
show maps that have show-p set, regardless of mode
mahmoodsh36 Mar 12, 2026
b69ae34
use defvar instead of defparameter to avoid issues on recomp
mahmoodsh36 Mar 17, 2026
5bda002
fix handling of undef-hook
mahmoodsh36 Mar 20, 2026
40ab039
set popup max-lines to 10 instead of 15 by default
mahmoodsh36 Mar 21, 2026
1610e48
fix undef-hook/function-table edge case
mahmoodsh36 Mar 26, 2026
62201d2
fix popup behavior when switching buffers
mahmoodsh36 Mar 29, 2026
9abe4ff
remove outdated comment
mahmoodsh36 Mar 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make popup more informative
  • Loading branch information
mahmoodsh36 committed Jan 18, 2026
commit e3f6d6a221fcce9188924705e269b73e091beeaa
50 changes: 50 additions & 0 deletions extensions/transient/demo.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(in-package :transient)

(define-transient *demo-keymap*
:display-style :row
(:keymap
:display-style :column
:description "file operations"
(:key "o" :suffix demo-open :description "demo open")
(:key "s" :suffix demo-save :description "demo save (disabled)" :active-p nil)
(:key "w" :suffix demo-write :description "demo write")
(:key "x"
:suffix (:keymap
(:key "p" :suffix demo-pdf :description "pdf")
(:key "h" :suffix demo-html :description "html")
(:key "m" :suffix demo-md :description "markdown"))
:description "export format"))
(:keymap
:display-style :column
:description "edit operations"
(:key "c" :suffix demo-copy)
(:key "v" :suffix demo-paste)
(:key "u" :suffix demo-undo))
(:key "f"
:suffix (:keymap
(:key "g" :suffix demo-grep :description "grep")
(:key "f" :suffix demo-find :description "find")
(:key "r" :suffix demo-replace :description "replace"))
:description "search menu")
(:key "t"
:suffix (:keymap
:display-style :row
(:keymap
:description "languages"
(:key "l"
:type :choice
:choices ("lisp" "python" "js")
:description "mode"))
(:keymap
:description "editor"
(:key "v"
:type :choice
:choices ("vim" "emacs")
:description "keys")))
:description "langs demo")
(:key "d"
:type :choice
:choices ("on" "off")
:description "debug toggle"))

(define-key *global-keymap* "C-c t" *demo-keymap*)
92 changes: 92 additions & 0 deletions extensions/transient/keymap.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
(in-package :transient)

(defmethod keymap-activate ((keymap keymap))
(log:info "keymap ~A activated" keymap)
(show-transient keymap))

(defmacro add-dynamic-property (class-name properties-accessor property-name &optional default-value)
"define <CLASS-NAME>-<PROPERTY-NAME> getter and setter methods.

the getter retrieves from PROPERTIES-ACCESSOR using :PROPERTY-NAME as key.
if the value is a function, it funcalls it. the setter stores directly.
if DEFAULT-VALUE is provided and non-nil, it is used as the default for getf."
(let* ((keyword (intern (symbol-name property-name) :keyword))
(getter-name (intern (format nil "~A-~A" class-name property-name)))
(obj-sym (gensym "OBJ")))
`(progn
(defmethod ,getter-name ((,obj-sym ,class-name))
(let ((prop ,(if default-value
`(getf (,properties-accessor ,obj-sym) ,keyword ,default-value)
`(getf (,properties-accessor ,obj-sym) ,keyword))))
(if (functionp prop)
(funcall prop)
prop)))
(defmethod (setf ,getter-name) (val (,obj-sym ,class-name))
(setf (getf (,properties-accessor ,obj-sym) ,keyword) val)))))

(add-dynamic-property keymap keymap-properties show-p t)
(add-dynamic-property prefix prefix-properties show-p t)

(defgeneric prefix-render (prefix)
(:documentation "render prefix into a layout item. returns nil to use default rendering."))

;; should return :row or :column
(defmethod keymap-display-style ((keymap keymap))
(getf (keymap-properties keymap) :display-style :row))

(defmethod (setf keymap-display-style) (val (keymap keymap))
(setf (getf (keymap-properties keymap) :display-style) val))

(defclass choice (prefix)
((choices
:accessor prefix-choices)))

(defmacro define-transient (name &body bindings)
`(defparameter ,name (parse-transient ',bindings)))

(defun parse-transient (bindings)
(let ((keymap (make-keymap)))
(loop for tail = bindings then (cdr tail)
while tail
do (let ((binding (car tail)))
(cond
;; inline property
((keywordp binding)
(let ((val (second tail)))
(setf (getf (keymap-properties keymap) binding) val))
;; advance another cell because we're already consumed it (second tail)
(setf tail (cdr tail)))
;; direct child keymap (:keymap ...)
((eq (car binding) :keymap)
(let ((sub-map (parse-transient (cdr binding))))
(keymap-add-child keymap sub-map t)))
;; key binding (:key ...)
((eq (car binding) :key)
(let* ((key (second binding))
;; prefix-class depends on the first cell in the :suffix value (if its a list at all)
(prefix-type (intern (symbol-name (getf binding :type 'prefix))))
(prefix (make-instance prefix-type)))
(setf (prefix-key prefix) (car (parse-keyspec key)))
;; sometimes the suffix will not be set (e.g. prefix-type is :choice). we
;; initialize it to nil to avoid unbound errors.
(setf (prefix-suffix prefix) nil)
(loop for (key value) on (cddr binding) by 'cddr
;; key-method is used for (setf prefix-<key-method> <value>)
for key-method = (intern (format nil "PREFIX-~A" (string key)))
do (let ((setf-expr `(setf (,key-method prefix) value))
(final-value)
(should-set t))
(cond
;; if the suffix is a keymap we need to parse recursively
((and (listp value) (eq (car value) :keymap))
(setf final-value (parse-transient value)))
((eq key :type)
(setf should-set nil))
(t
(setf final-value value)))
(when should-set
(funcall (fdefinition (list 'setf key-method))
final-value
prefix))))
(keymap-add-prefix keymap prefix t))))))
keymap))
Loading
Loading