summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/custom-case.el5
-rw-r--r--modules/local-repository.el4
-rw-r--r--modules/mousetrap-mode.el8
-rw-r--r--modules/org-capture-config.el34
4 files changed, 31 insertions, 20 deletions
diff --git a/modules/custom-case.el b/modules/custom-case.el
index 59250ddb..a4e0c0e0 100644
--- a/modules/custom-case.el
+++ b/modules/custom-case.el
@@ -79,12 +79,15 @@ short prepositions, and all articles are considered minor words."
(while (< (point) end)
(setq prev-word-end (point))
(skip-chars-forward (concat "^" word-chars) end)
+ (when (>= (point) end) ;; no word chars remaining
+ (goto-char end))
(let ((word-end
(save-excursion
(skip-chars-forward word-chars end)
(point))))
- (unless (memq (char-before (point)) chars-separator)
+ (unless (or (>= (point) end)
+ (memq (char-before (point)) chars-separator))
(let* ((c-orig (char-to-string (char-after (point))))
(c-up (capitalize c-orig)))
(unless (string-equal c-orig c-up)
diff --git a/modules/local-repository.el b/modules/local-repository.el
index c390ffbb..ab4daac9 100644
--- a/modules/local-repository.el
+++ b/modules/local-repository.el
@@ -43,11 +43,11 @@ keep them in source control.")
"Add the repository to the package archives, then gives it a high priority."
(unless (car-member localrepo-repository-id package-archives)
(add-to-list 'package-archives
- (localrepo-repository-id . localrepo-repository-location)))
+ (cons localrepo-repository-id localrepo-repository-location)))
(unless (car-member localrepo-repository-id package-archive-priorities)
(add-to-list 'package-archive-priorities
- (localrepo-repository-id . localrepo-repository-priority))))
+ (cons localrepo-repository-id localrepo-repository-priority))))
(provide 'local-repository)
;;; local-repository.el ends here.
diff --git a/modules/mousetrap-mode.el b/modules/mousetrap-mode.el
index 7ee91d3b..0df08d7c 100644
--- a/modules/mousetrap-mode.el
+++ b/modules/mousetrap-mode.el
@@ -178,10 +178,16 @@ See `mouse-trap-profiles' for available profiles and
(if mouse-trap-mode
(progn
(setq mouse-trap-mode-map (mouse-trap--build-keymap))
+ ;; Register keymap so Emacs actually uses it for key dispatch
+ (let ((entry (assq 'mouse-trap-mode minor-mode-map-alist)))
+ (if entry
+ (setcdr entry mouse-trap-mode-map)
+ (push (cons 'mouse-trap-mode mouse-trap-mode-map) minor-mode-map-alist)))
;; Add dynamic lighter to mode-line-misc-info (always visible)
(unless (member '(:eval (mouse-trap--lighter-string)) mode-line-misc-info)
(push '(:eval (mouse-trap--lighter-string)) mode-line-misc-info)))
- ;; When disabling, clear the keymap
+ ;; When disabling, remove keymap from minor-mode-map-alist
+ (setq minor-mode-map-alist (assq-delete-all 'mouse-trap-mode minor-mode-map-alist))
(setq mouse-trap-mode-map nil)
;; Note: We keep the lighter in mode-line-misc-info so it shows 🐭 when disabled
))
diff --git a/modules/org-capture-config.el b/modules/org-capture-config.el
index 5d569002..755eecaf 100644
--- a/modules/org-capture-config.el
+++ b/modules/org-capture-config.el
@@ -24,6 +24,17 @@
;; -------------------------- Event Capture Formatting -------------------------
+ (defun cj/org-capture--date-prefix (timestamp)
+ "Return \"YY-MM-DD: \" prefix from org TIMESTAMP string, or nil if unparseable."
+ (when-let ((parsed (ignore-errors (org-parse-time-string timestamp))))
+ (let ((year (nth 5 parsed))
+ (month (nth 4 parsed))
+ (day (nth 3 parsed)))
+ (when (and year month day
+ (> year 0) (> month 0) (> day 0))
+ (format "%02d-%02d-%02d: "
+ (mod year 100) month day)))))
+
(defun cj/org-capture-format-event-headline ()
"Format the event headline with YY-MM-DD prefix from the WHEN timestamp.
This function is called during `org-capture' finalization to prepend the date
@@ -31,22 +42,12 @@ to the event title for better organization in the schedule file."
(when (string= (plist-get org-capture-plist :key) "e")
(save-excursion
(goto-char (point-min))
- ;; Find the WHEN: line with timestamp
(when (re-search-forward "^WHEN: \\(<[^>]+>\\)" nil t)
- (let* ((timestamp (match-string 1))
- ;; Parse the timestamp to extract date components
- (parsed (org-parse-time-string timestamp))
- (year (nth 5 parsed))
- (month (nth 4 parsed))
- (day (nth 3 parsed))
- ;; Format as YY-MM-DD
- (date-prefix (format "%02d-%02d-%02d: "
- (mod year 100) month day)))
- ;; Go back to the headline
- (goto-char (point-min))
- ;; Insert date prefix after the asterisks
- (when (looking-at "^\\(\\*+ \\)\\(.*\\)$")
- (replace-match (concat "\\1" date-prefix "\\2"))))))))
+ (let ((date-prefix (cj/org-capture--date-prefix (match-string 1))))
+ (when date-prefix
+ (goto-char (point-min))
+ (when (looking-at "^\\(\\*+ \\)\\(.*\\)$")
+ (replace-match (concat "\\1" date-prefix "\\2")))))))))
(defun cj/org-capture-event-content ()
"Get the appropriate content for event capture based on context.
@@ -56,7 +57,8 @@ formatted appropriately for insertion into the capture template."
;; If called from org-protocol (browser), get the initial from org-store-link-plist
((and (boundp 'org-store-link-plist)
org-store-link-plist
- (plist-get org-store-link-plist :initial))
+ (let ((val (plist-get org-store-link-plist :initial)))
+ (and (stringp val) (not (string-empty-p val)))))
(concat "\n" (plist-get org-store-link-plist :initial)))
;; If there's a selected region in Emacs, use it from capture plist
((and (stringp (plist-get org-capture-plist :initial))