org-agenda: skip all todo keywords; disable mouse in GUI

1. my/org-agenda-goto-task-name: replace face-based detection with
   regexp-opt over org-todo-keywords. Works for all keywords
   (TODO, NEXT, WAIT, DONE, CANCELLED, ...), not just TODO/DONE.
   Added helper my/org-agenda-all-keywords.

2. Disable mouse clicks in GUI Emacs (Fix C in macOS GUI section):
   global-set-key [mouse-*] to #'ignore, mouse-highlight nil.
   Prevents accidental cursor movement when touching trackpad.
This commit is contained in:
2026-02-23 13:17:40 +01:00
parent 6aa50c9b59
commit acb38759b9

View File

@@ -109,6 +109,16 @@
mac-option-modifier 'meta
mac-right-option-modifier 'none))
;; Fix C: Disable mouse clicks in GUI Emacs (prevent accidental cursor movement)
(when (display-graphic-p)
(dolist (key '([mouse-1] [mouse-2] [mouse-3]
[double-mouse-1] [double-mouse-2] [double-mouse-3]
[triple-mouse-1] [triple-mouse-2] [triple-mouse-3]
[drag-mouse-1] [drag-mouse-2] [drag-mouse-3]
[down-mouse-1] [down-mouse-2] [down-mouse-3]))
(global-set-key key #'ignore))
(setq mouse-highlight nil))
;;; ============================================================
@@ -286,31 +296,26 @@
;;; ORG MODE — CUSTOM BEHAVIOR
;;; ============================================================
;; Org agenda: position cursor at task name (after TODO keyword and priority)
;; Works with n/p (or j/k in evil mode) — skips TODO keyword and [#A] priority.
;; Org agenda: position cursor at task name (after any todo keyword and priority)
;; Works with n/p (or j/k in evil mode) — skips any keyword from org-todo-keywords
;; (TODO, NEXT, WAIT, DONE, CANCELLED, …) and optional [#A] priority.
(defun my/org-agenda-all-keywords ()
"Return list of all org todo keyword strings (without shortcut suffixes)."
(let (result)
(dolist (seq org-todo-keywords result)
(dolist (kw (cdr seq))
(unless (equal kw "|")
(push (replace-regexp-in-string "(.*" "" kw) result))))))
(defun my/org-agenda-goto-task-name (&rest _)
"Move cursor to the task name on the current org-agenda line.
Skips past the TODO keyword and optional priority indicator [#A]."
Skips past any org todo keyword (TODO, NEXT, WAIT, DONE, CANCELLED, etc.)
and optional priority indicator [#A]."
(when (get-text-property (line-beginning-position) 'org-hd-marker)
(beginning-of-line)
(let* ((bol (point))
(eol (line-end-position))
(todo-end nil)
(pos bol))
;; Find end of TODO keyword by face (org-todo or org-agenda-done)
(while (< pos eol)
(let* ((face (get-text-property pos 'face))
(next (or (next-single-property-change pos 'face nil eol) eol)))
(when (and face
(or (and (symbolp face)
(memq face '(org-todo org-agenda-done)))
(and (listp face)
(cl-intersection face '(org-todo org-agenda-done)))))
(setq todo-end next))
(setq pos next)))
;; Move past TODO keyword and optional priority [#X]
(when todo-end
(goto-char todo-end)
(let* ((eol (line-end-position))
(kw-re (regexp-opt (my/org-agenda-all-keywords) 'words)))
(when (re-search-forward kw-re eol t)
(skip-chars-forward " \t")
(when (looking-at "\\[#.\\][ \t]+")
(goto-char (match-end 0)))))))