From 25f0fe5d68ebec67f3a1ca2f24c4a0bc8e49381f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 5 Apr 2024 09:12:32 +1100 Subject: [emacs][urxvt] bunch of small changes - add org clock string to frame title - add ansi color to compilation buffer - look for project source dir from build dir - fix my-kill-sexp-or-comment - more lines in urxvt --- emacs/.emacs.d/init/ycp-editing.el | 4 +++- emacs/.emacs.d/init/ycp-org.el | 5 +++++ emacs/.emacs.d/init/ycp-prog.el | 5 +++++ emacs/.emacs.d/init/ycp-project.el | 2 +- emacs/.emacs.d/init/ycp-web.el | 5 +++-- emacs/.emacs.d/lisp/my/my-editing.el | 9 ++++++--- emacs/.emacs.d/lisp/my/my-gnus.el | 2 +- emacs/.emacs.d/lisp/my/my-mariadb.el | 14 +++++++++----- emacs/.emacs.d/lisp/my/my-project.el | 10 ++++++++++ 9 files changed, 43 insertions(+), 13 deletions(-) (limited to 'emacs/.emacs.d') diff --git a/emacs/.emacs.d/init/ycp-editing.el b/emacs/.emacs.d/init/ycp-editing.el index 8d260ee..203b185 100644 --- a/emacs/.emacs.d/init/ycp-editing.el +++ b/emacs/.emacs.d/init/ycp-editing.el @@ -125,7 +125,9 @@ (setq avy-keys '(97 115 100 102 103 104 106 107 108))) (my-package flyspell - (my-keybind flyspell-mode-map "C-." nil)) + (my-keybind flyspell-mode-map + "C-." nil + )) (my-package pyim (:delay 30) diff --git a/emacs/.emacs.d/init/ycp-org.el b/emacs/.emacs.d/init/ycp-org.el index 8364810..4ae1ed3 100644 --- a/emacs/.emacs.d/init/ycp-org.el +++ b/emacs/.emacs.d/init/ycp-org.el @@ -108,6 +108,11 @@ (plist-put org-format-latex-options :scale 1.5) (setq org-reverse-note-order t) (add-hook 'before-save-hook #'my-org-update-updated) + ;; Add org mode line string, including `org-clock-get-clock-string' + (setq frame-title-format + '(multiple-frames "%b" + ("" "%b - GNU Emacs at " system-name + " " org-mode-line-string))) ) (my-package org-duration diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el index 054b035..e2d7451 100644 --- a/emacs/.emacs.d/init/ycp-prog.el +++ b/emacs/.emacs.d/init/ycp-prog.el @@ -289,6 +289,9 @@ compilation-context-lines 10 compilation-scroll-output 'first-error compilation-skip-threshold 2) + (require 'ansi-color) + ;; ansi color in compilation buffer + (add-hook 'compilation-filter-hook 'ansi-color-compilation-filter) ) ;;; flymake @@ -499,6 +502,8 @@ "C-c d s" 'my-gdb-maria-spider ) (define-key gud-mode-map (kbd "C-c C-z") 'my-gdb-mysql-parse-frame) + (define-key gud-mode-map (kbd "C-c C-p") 'comint-previous-prompt) + (define-key gud-mode-map (kbd "C-c C-n") 'comint-next-prompt) (add-to-list 'grep-files-aliases '("mtr" . "*.inc *.test *.cnf *.result *.rdiff")) (add-to-list 'grep-files-aliases diff --git a/emacs/.emacs.d/init/ycp-project.el b/emacs/.emacs.d/init/ycp-project.el index d4c7dd9..99c022c 100644 --- a/emacs/.emacs.d/init/ycp-project.el +++ b/emacs/.emacs.d/init/ycp-project.el @@ -45,7 +45,7 @@ (add-to-list 'project-switch-commands '(project-shell "Shell")) (define-key project-prefix-map "m" #'magit-project-status) (add-to-list 'project-switch-commands '(magit-project-status "Magit") t) - ) + (add-to-list 'project-find-functions #'my-project-try-find-from-build-dir t)) (provide 'ycp-project) ;;; ycp-project.el ends here diff --git a/emacs/.emacs.d/init/ycp-web.el b/emacs/.emacs.d/init/ycp-web.el index 2a56f95..865236b 100644 --- a/emacs/.emacs.d/init/ycp-web.el +++ b/emacs/.emacs.d/init/ycp-web.el @@ -23,7 +23,7 @@ ;;; Commentary: ;; My config for web related. Covers cookies, web browsing, clients to -;; web services like osm and openlibrary +;; web services like osm and openlibrary ;;; Code: @@ -212,7 +212,8 @@ ;; it pulls. (add-hook 'org-jira-mode-hook (lambda () (setq show-trailing-whitespace nil))) - ) + (add-hook 'org-jira-mode-hook + 'turn-off-auto-fill) ) (my-package eww (:delay 60) diff --git a/emacs/.emacs.d/lisp/my/my-editing.el b/emacs/.emacs.d/lisp/my/my-editing.el index 2c1abfb..aa65ba1 100644 --- a/emacs/.emacs.d/lisp/my/my-editing.el +++ b/emacs/.emacs.d/lisp/my/my-editing.el @@ -493,9 +493,12 @@ With an prefix-arg, copy the file name relative to project root." (defun my-kill-sexp-or-comment (&optional n) "Kill the next n sexp. On failure, call `comment-kill' instead." (interactive) - (condition-case _ - (kill-sexp n) - (scan-error (comment-kill (or n 1))))) + (let ((old-max (point-max)) + (old-point (point))) + (comment-kill (or n 1)) + (when (= old-max (point-max)) + (goto-char old-point) + (kill-sexp n)))) (defun my-mark-sexp-or-comment () "Mark the next sexp or comment." diff --git a/emacs/.emacs.d/lisp/my/my-gnus.el b/emacs/.emacs.d/lisp/my/my-gnus.el index 599a19c..e44e9c8 100644 --- a/emacs/.emacs.d/lisp/my/my-gnus.el +++ b/emacs/.emacs.d/lisp/my/my-gnus.el @@ -167,7 +167,7 @@ The archiving target comes from `my-gnus-group-alist'." (defun my-gnus-start () (interactive) (let ((buffer (get-buffer "*Group*"))) - (if buffer + (if buffer (switch-to-buffer "*Group*") (gnus)))) diff --git a/emacs/.emacs.d/lisp/my/my-mariadb.el b/emacs/.emacs.d/lisp/my/my-mariadb.el index 984cc29..52ca8bc 100644 --- a/emacs/.emacs.d/lisp/my/my-mariadb.el +++ b/emacs/.emacs.d/lisp/my/my-mariadb.el @@ -63,6 +63,7 @@ (replace-regexp-in-string "/src" "/build/mysql-test/var/log/mysqld.1.1.rr/latest-trace" + ;; "/build/mysql-test/var/log/mysqld.3.1.rr/latest-trace" (project-root (project-current t)))) (expand-file-name "~/bin/gdb-mi.sh")))) @@ -185,12 +186,15 @@ (goto-char (point-min)) (while (re-search-forward (concat - "\\(spider_alloc_calc_mem_init\\|init_calc_mem\\|spider_malloc\\|" - "spider_bulk_alloc_mem\\|spider_bulk_malloc\\)" - "\\(([^0-9)_]*\\)\\([0-9]+\\)") + "\\(spider_alloc_calc_mem_init(.*?, \\|init_calc_mem(\\|" + "spider_malloc(.*?, \\|" + "spider_bulk_alloc_mem(.*?, \\|spider_bulk_malloc.*?, \\)" + "\\([0-9]+\\)" + ;; "\\(([^0-9)]*\\)\\([0-9]+\\)" + ) nil t) - (let ((beg (match-beginning 3)) - (end (match-end 3))) + (let ((beg (match-beginning 2)) + (end (match-end 2))) (replace-region-contents beg end #'my-mdev-32524-make-id))) (save-buffer))))) diff --git a/emacs/.emacs.d/lisp/my/my-project.el b/emacs/.emacs.d/lisp/my/my-project.el index 1cf23ee..70f86dc 100644 --- a/emacs/.emacs.d/lisp/my/my-project.el +++ b/emacs/.emacs.d/lisp/my/my-project.el @@ -45,6 +45,16 @@ (file-name-nondirectory (directory-file-name (project-root (project-current))))) +(defun my-project-try-find-from-build-dir (dir) + "Try to find project from the build dir. + +To use as an item in `project-find-functions'. + +TODO: check whether we could use +`project-vc-external-roots-function' instead." + (when (string-match-p "/build\\>.*" dir) + (project-current nil (replace-regexp-in-string "/build\\>.*" "/src" dir)))) + (defvar my-licenses nil "List of licenses in the form of (licence-id . license-text-file)") -- cgit v1.2.3