diff --git a/config.el b/config.el index 564322b..d0fc605 100644 --- a/config.el +++ b/config.el @@ -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)))))))