From bd7c33b39527f3cea1c7f5270fc60a979357a318 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 30 Jul 2023 16:23:47 +1000 Subject: Some small changes. visual line mode, bbdb mua, org agenda, org capture, xref, bbdb --- emacs/.emacs.d/init/ycp-editing.el | 9 +++++++- emacs/.emacs.d/init/ycp-gnus.el | 11 +++++----- emacs/.emacs.d/init/ycp-grep.el | 11 +++------- emacs/.emacs.d/init/ycp-org.el | 24 +++++++++++++------- emacs/.emacs.d/init/ycp-prog.el | 10 +++++---- emacs/.emacs.d/lisp/my/my-bbdb.el | 2 +- emacs/.emacs.d/lisp/my/my-prog.el | 45 ++------------------------------------ 7 files changed, 42 insertions(+), 70 deletions(-) diff --git a/emacs/.emacs.d/init/ycp-editing.el b/emacs/.emacs.d/init/ycp-editing.el index b5da08a..2e87ecc 100644 --- a/emacs/.emacs.d/init/ycp-editing.el +++ b/emacs/.emacs.d/init/ycp-editing.el @@ -41,7 +41,14 @@ ;; don't interpret C-m as RET (define-key input-decode-map [?\C-m] [C-m]) (setq save-place-file (locate-user-emacs-file "saveplace")) -(setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow)) + +(my-configure + (setq visual-line-fringe-indicators + '(left-curly-arrow right-curly-arrow)) + ;; Keep the binding of C-a and C-e + (my-keybind visual-line-mode-map + "C-a" nil + "C-e" nil)) (my-package my-editing (:delay 5) diff --git a/emacs/.emacs.d/init/ycp-gnus.el b/emacs/.emacs.d/init/ycp-gnus.el index 6945de1..8485a86 100644 --- a/emacs/.emacs.d/init/ycp-gnus.el +++ b/emacs/.emacs.d/init/ycp-gnus.el @@ -30,19 +30,19 @@ (my-setq-from-local user-mail-address user-full-name) (setq auth-sources '("~/.authinfo.gpg")) -;;;; `mm-encode' +;;; `mm-encode' (my-package mm-encode (setq mm-encrypt-option nil ; use 'guided if you need more control mm-sign-option nil)) ; same -;;;; `mml-sec' +;;; `mml-sec' (my-package mml-sec (setq mml-secure-openpgp-encrypt-to-self t mml-secure-openpgp-sign-with-sender t mml-secure-smime-encrypt-to-self t mml-secure-smime-sign-with-sender t)) -;;;; `message' +;;; `message' (my-package message (setq mail-user-agent 'message-user-agent message-elide-ellipsis "\n> [... %l lines elided]\n" @@ -64,7 +64,7 @@ (setq smtpmail-smtp-service 587 smtpmail-queue-mail nil)) -;;;; `sendmail' (mail transfer agent) +;;; `sendmail' (mail transfer agent) (setq send-mail-function 'smtpmail-send-it) ;;; gnus @@ -167,7 +167,7 @@ (setq gnus-treat-display-smileys nil) (setq gnus-article-x-face-too-ugly ".*")) ; all images in headers are outright ; annoying---disabled! -;; gnus-desktop-notify +;;; gnus-desktop-notify (my-package gnus-desktop-notify (:delay 30) (gnus-desktop-notify-mode) @@ -184,6 +184,7 @@ (bbdb-mua-auto-update-init 'gnus 'message) (setq bbdb-message-all-addresses t) (setq bbdb-mua-pop-up-window-size .15) + (setq bbdb-new-mails-primary nil) (setq bbdb-mail-user-agent 'gnus-user-agent) (setq bbdb-update-records-p 'create) (setq bbdb-message-clean-mail-function 'my-bbdb-clean-mail) diff --git a/emacs/.emacs.d/init/ycp-grep.el b/emacs/.emacs.d/init/ycp-grep.el index 2e75e26..6496c78 100644 --- a/emacs/.emacs.d/init/ycp-grep.el +++ b/emacs/.emacs.d/init/ycp-grep.el @@ -27,6 +27,9 @@ ;;; Code: +;;; Some configs in `simple' are related to search +(my-package simple + (add-hook 'next-error-hook #'which-func-update)) ;;; `grep' package (my-package grep @@ -87,14 +90,6 @@ (my-keybind occur-mode-map "t" #'toggle-truncate-lines) ) - -;;; `xref' package -(my-package xref - ;; All those have been changed for Emacs 28 - (setq xref-show-definitions-function #'xref-show-definitions-completing-read) ; for M-. - (setq xref-show-xrefs-function #'xref-show-definitions-buffer) - ) - ;;; wgrep (writable grep) (my-package wgrep (:install t) diff --git a/emacs/.emacs.d/init/ycp-org.el b/emacs/.emacs.d/init/ycp-org.el index db29697..2d40c37 100644 --- a/emacs/.emacs.d/init/ycp-org.el +++ b/emacs/.emacs.d/init/ycp-org.el @@ -170,11 +170,14 @@ (setq org-agenda-skip-deadline-if-done nil) (setq org-agenda-skip-scheduled-if-done nil) (setq org-agenda-skip-timestamp-if-done t) - (setq org-agenda-start-on-weekday 6) + (setq org-agenda-start-on-weekday nil) (setq org-agenda-custom-commands `(("A" "Agenda and next" ((agenda "" - ((org-agenda-span 'week))) + ((org-agenda-span 'week) + ;; only works when `org-agenda-start-on-weekday' + ;; is nil + (org-agenda-start-day "-2d"))) (tags-todo "PRIORITY=\"A\"" nil)) nil ,(my-get-from-local my-org-agenda-and-next-export-files)) @@ -206,22 +209,27 @@ (my-package org-capture (my-override org-capture-set-plist) (setq org-capture-templates - `(("j" "Journal" entry + `(("w" "Today's work" checkitem + (file+headline org-default-notes-file "Today's work") + "- [ ] %a%?" + :prepend t) + ("j" "Journal" entry (file+olp+datetree ,(my-get-from-local my-org-journal-file)) - "* %^{Title} + "* %? :PROPERTIES: :CREATED: %U :END: - -%?") +") ("t" "Todo" entry (file+headline org-default-notes-file "Inbox") - "* TODO %a%? + "* TODO %? :PROPERTIES: :CREATED: %U +:Referral: %a :END: -%i" +%i +" :prepend t) ("ya" "Blank audio" entry (file+headline org-default-notes-file "Audios") diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el index 63cdb36..23982ea 100644 --- a/emacs/.emacs.d/init/ycp-prog.el +++ b/emacs/.emacs.d/init/ycp-prog.el @@ -293,10 +293,12 @@ ;; "Probably \"%s\" should be imperative \"%s\"" (setq checkdoc-verb-check-experimental-flag nil)) -(my-package my-prog - (:delay 10) - (require 'xref) - (my-override xref-query-replace-in-results)) +(my-package xref + (add-hook 'xref-after-jump-hook #'which-func-update) + ;; All those have been changed for Emacs 28 + (setq xref-show-definitions-function #'xref-show-definitions-completing-read) ; for M-. + (setq xref-show-xrefs-function #'xref-show-definitions-buffer) + ) (my-package js (:delay 60) diff --git a/emacs/.emacs.d/lisp/my/my-bbdb.el b/emacs/.emacs.d/lisp/my/my-bbdb.el index f5aa420..91cdcde 100644 --- a/emacs/.emacs.d/lisp/my/my-bbdb.el +++ b/emacs/.emacs.d/lisp/my/my-bbdb.el @@ -179,7 +179,7 @@ If NAME exists in bbdb, update. Otherwise insert." (defun my-bbdb-done () "Save and quit bbdb window" (interactive) - (bbdb-save) (quit-window)) + (bbdb-save) (delete-window)) (defun my-bbdb-all () "Dispaly all bbdb records" diff --git a/emacs/.emacs.d/lisp/my/my-prog.el b/emacs/.emacs.d/lisp/my/my-prog.el index 96ffac2..a38f956 100644 --- a/emacs/.emacs.d/lisp/my/my-prog.el +++ b/emacs/.emacs.d/lisp/my/my-prog.el @@ -73,7 +73,7 @@ (error "I don't know how to restart in %S" major-mode)) ) -(defun my-shell-disable-company-if-remote () +(defun my-shell-disable-company-if-remote () (when (and (fboundp 'company-mode) (file-remote-p default-directory)) (company-mode -1))) @@ -122,48 +122,7 @@ ;; second condition - the extension is "c" or "cpp" ((member ext '("c" "cpp" "cc")) (when (file-exists-p (setq new-file (concat bse ".h"))) - (find-file new-file)))))) - -;;; To override `xref-query-replace-in-results'. -(defun my-xref-query-replace-in-results (from to) - "Perform interactive replacement of FROM with TO in all displayed xrefs. - -This function interactively replaces FROM with TO in the names of the -references displayed in the current *xref* buffer. - -When called interactively, it uses '.*' as FROM, which means replace -the whole name, and prompts the user for TO. -If invoked with prefix argument, it prompts the user for both FROM and TO. - -As each match is found, the user must type a character saying -what to do with it. Type SPC or `y' to replace the match, -DEL or `n' to skip and go to the next match. For more directions, -type \\[help-command] at that time. - -Note that this function cannot be used in *xref* buffers that show -a partial list of all references, such as the *xref* buffer created -by \\[xref-find-definitions] and its variants, since those list only -some of the references to the identifiers." - (interactive - (let* ((fr - (if current-prefix-arg - (read-regexp "Query-replace (regexp)" ".*") - "\\(.*\\)")) - (prompt (if current-prefix-arg - (format "Query-replace (regexp) %s with: " fr) - "Query-replace all matches with: "))) - (list fr (read-regexp prompt)))) - (let* (item xrefs iter) - (save-excursion - (while (setq item (xref--search-property 'xref-item)) - (when (xref-match-length item) - (push item xrefs)))) - (unwind-protect - (progn - (goto-char (point-min)) - (setq iter (xref--buf-pairs-iterator (nreverse xrefs))) - (xref--query-replace-1 from to iter)) - (funcall iter :cleanup)))) + (find-file new-file)))))) (defun my-set-tab-width-to-8 () (interactive) -- cgit v1.2.3