Skip to content

Instantly share code, notes, and snippets.

@mmarshall540
mmarshall540 / cua-problem-keys.org
Last active June 22, 2025 18:12
List of default keybindings under C-x and C-c (org-mode) that can use an active region

List of default keybindings that use region under C-x and C-c

(Note: this is easier to read if you click the “Raw” button, or even better, download and view it in Emacs.)

This is for helping to locate bindings that might be corrected for CUA-mode.

Global-map (only C-x)

  • Editing
    C-x TAB
    indent-rigidly
    C-x C-l
    downcase-region
    • Bind downcase-dwim to M-l.
@mmarshall540
mmarshall540 / set-window-4-scrolling.el
Created June 28, 2025 20:46
Set the window to use with `scroll-other-window`
(defun my/set-window-4-scrolling (arg)
"Set current window as target window for `scroll-other-window'.
This ensures that `scroll-other-window' scrolls the desired window, even
if Emacs doesn't consider it the \"next-window\" and regardless of which
window is selected when `scroll-other-window' is called.
Compared to setting the `other-window-scroll-buffer' variable, the
method this command uses works even when the window is on another frame
and won't cause a duplicate window to pop up on the current frame.
@mmarshall540
mmarshall540 / org-mode-add-modified-property.el
Created October 19, 2025 15:03
Add "MODIFIED" (and "HASH") properties to Org-mode entries on save
;; Org-mode: Custom property: MODIFIED
;; Adapted from: https://emacs.stackexchange.com/a/39376/31079
(defun yant/getentryhash ()
"Get the hash sum of the text in current entry.
Except :HASH: and :MODIFIED: property texts."
(save-excursion
(let* ((beg (progn (org-back-to-heading :invisible-ok) (point)))
(end (progn
(forward-char)
@mmarshall540
mmarshall540 / backlinks.el
Last active November 18, 2025 13:25
Backlinking facilities for Org-mode entries
@mmarshall540
mmarshall540 / tmm-menubar-enhancements.el
Created January 18, 2026 21:40
Using the tmm-menubar
(setopt completions-format 'one-column
tmm-completion-prompt nil
tmm-mid-prompt " → "
tmm-shortcut-style '(downcase)
tmm-shortcut-words nil)
(define-keymap
:keymap global-map
;; Improve the #tmm Options menu shortcuts by removing some entries:
"<menu-bar> <options> <cua-mode>" nil ; let "Customize Emacs" use "c"
@mmarshall540
mmarshall540 / insert-quotes-or-break-string.el
Created January 29, 2026 02:04
DWIM command for inserting pairs of quotes or escaped quotes inside of a string
(defun my/insert-quotes-or-break-string (&optional arg)
"This enhances the behavior of `insert-pair' for double-quotes.
It acts differently from `insert-pair', because when splitting an
existing string, the strings will be outside of the new pair, not
inside. So in that case, we want to add spaces inside of the new pair,
not outside. If the mark is active, escaped double-quotes are added
around the region. This command makes it easier to edit tempo templates
and skeletons. To add escaped double-quotes within a template string,
just activate the mark before calling this command. This works even if
the region is empty."