Skip to content

Instantly share code, notes, and snippets.

@lispandfound
Last active April 11, 2023 22:32
Show Gist options
  • Save lispandfound/c8832debaece40f197867a67c57a8cd0 to your computer and use it in GitHub Desktop.
Save lispandfound/c8832debaece40f197867a67c57a8cd0 to your computer and use it in GitHub Desktop.
;; Invoke via M-x doc-view-transient
(transient-define-prefix doc-view-transient ()
"Transient for doc-view mode."
[:class transient-columns ;; the class sets how the transient is displayed; we have each category as a column.
["Zoom"
("+" "Enlarge" doc-view-enlarge :transient t) ;; :transient commands keep the transient prompt open
("-" "Shrink" doc-view-shrink :transient t)
("w" "Fit window to page" doc-view-fit-window-to-page :transient t)
("W" "Fit width to window" doc-view-fit-width-to-window :transient t)]
["Navigation"
("g" "Go to page" doc-view-goto-page) ;; Without :transient, invoking the keybinding closes the prompt
(">" "Last page" doc-view-last-page)
("<" "First page" doc-view-first-page)]
["Scale"
("R" "Scale reset" doc-view-scale-reset)
("a" "Scale adjust" doc-view-scale-adjust)]
["Miscellaneous"
("o" "Open text" doc-view-open-text)
("s" "Set slice" doc-view-set-slice)
("x" "Kill proc" doc-view-kill-proc)
("c" "Clear cache" doc-view-clear-cache)
("d" "Dired cache" doc-view-dired-cache)
("r" "Reset slice" doc-view-reset-slice)
("p" "Presentation" doc-view-presentation)]])
(transient-define-prefix rectangle-commands ()
"Transient state for rectangle mark mode."
[:class transient-columns
["Cut/Kill/Delete"
("<backspace>" "Delete rectangle" delete-rectangle)
("k" "Kill rectangle" kill-rectangle)
]
["Replace"
("c" "Replace with whitespace" clear-rectangle)
("s" "Replace rectangle with string" string-rectangle)]
["Insert"
("<tab>" "Shift text to the right" open-rectangle)
("i" "Insert string at the start of rectangle" string-insert-rectangle)
("n" "Insert numbers at the start of the rectangle" rectangle-number-lines)
]
["Copy/Yank"
("w" "Copy rectangle" copy-rectangle-as-kill)
("r" "Copy rectangle to register" copy-rectangle-to-register)
("y" "Yank rectangle" yank-rectangle)]
["Calc"
("M" "Send rectangle as matrix to calc" calc-grab-rectangle)
("D" "Sum a rectangle down" calc-grab-sum-down)
("A" "Sum a rectangle across" calc-grab-sum-across)]
["Cycle"
("x" "Cycle point around the rectangle's corners" rectangle-exchange-point-and-mark :transient t)]
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment