aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-08-21 16:42:27 +1000
committerYuchen Pei <id@ypei.org>2023-08-21 16:42:27 +1000
commitffea78e98b6a9c494c0a52f59e6ad1678a6dc445 (patch)
tree8e09859b1e23e71391e83b45c97bc8b5dfbf2da6
parent0c844c3e9a8e72bd83e370c12eda5cb315ac5d41 (diff)
Fixing a few things in emacs, adding xdgdef
Emacs: updating the org clock refile so that it refiles all text in the logbook
-rw-r--r--emacs/.emacs.d/init/ycp-org.el6
-rw-r--r--emacs/.emacs.d/init/ycp-package.el2
-rw-r--r--emacs/.emacs.d/init/ycp-prog.el1
-rw-r--r--emacs/.emacs.d/init/ycp-web.el2
-rw-r--r--emacs/.emacs.d/lisp/my/my-org.el58
-rwxr-xr-xmisc/bin/xdgdef5
6 files changed, 64 insertions, 10 deletions
diff --git a/emacs/.emacs.d/init/ycp-org.el b/emacs/.emacs.d/init/ycp-org.el
index 9c9191a..d18b9f6 100644
--- a/emacs/.emacs.d/init/ycp-org.el
+++ b/emacs/.emacs.d/init/ycp-org.el
@@ -70,8 +70,8 @@
(setq org-modules '(ol-bbdb ol-gnus ol-info))
(setq org-use-sub-superscripts '{})
(setq org-todo-keywords
- '((sequence "TODO(t!)" "DOIN(i!)" "WAIT(w!)" "|"
- "DONE(d!)" "OBSO(o!)" "DUPL(u!)")))
+ '((sequence "TODO(t)" "DOIN(i)" "WAIT(w)" "|"
+ "DONE(d)" "OBSO(o)" "DUPL(u)")))
(setq org-enforce-todo-dependencies t
org-enforce-todo-checkbox-dependencies t)
(setq org-use-fast-todo-selection 'expert)
@@ -297,7 +297,7 @@
(setq org-speed-commands
'(("User commands")
("g" . org-delete-property)
- ("W" . my-org-clock-refile-clocking)
+ ("W" . my-org-refile-logbook)
("+" . my-org-vote-up)
("-" . my-org-vote-down)
("m" . my-magit-clone-org-source)
diff --git a/emacs/.emacs.d/init/ycp-package.el b/emacs/.emacs.d/init/ycp-package.el
index ff0d498..3662b53 100644
--- a/emacs/.emacs.d/init/ycp-package.el
+++ b/emacs/.emacs.d/init/ycp-package.el
@@ -41,7 +41,7 @@
(t
(setq my-omit-packages
'(typescript-mode tide web-mode flycheck ggtags crystal-mode
- proof-general sml-mode emms my-emms erc mastodon))))
+ sml-mode emms my-emms erc mastodon))))
(my-read-local-config)
;; only start server on default profile
diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el
index 7dc2f92..84ac0d2 100644
--- a/emacs/.emacs.d/init/ycp-prog.el
+++ b/emacs/.emacs.d/init/ycp-prog.el
@@ -435,6 +435,7 @@
(my-package proof-general
(:install t)
(:delay 60)
+ (setq proof-splash-enable nil)
(setq coq-prog-name "/usr/bin/coqtop")
(setq coq-compiler "~/.opam/default/bin/coqc")
(setq coq-prog-env '("PATH=/usr/bin/:$HOME/.opam/default/bin/"))
diff --git a/emacs/.emacs.d/init/ycp-web.el b/emacs/.emacs.d/init/ycp-web.el
index 5834971..5c96e43 100644
--- a/emacs/.emacs.d/init/ycp-web.el
+++ b/emacs/.emacs.d/init/ycp-web.el
@@ -97,7 +97,7 @@
(advice-add 'eww-browse-url :filter-args #'my-rewrite-url-advice)
(advice-add 'eww :filter-args #'my-rewrite-url-advice)
(setq eww-restore-desktop t)
- (require 'my-util)
+ (require 'my-utils)
(setq eww-download-directory my-incoming-dir)
(setq eww-bookmarks-directory (locate-user-emacs-file "eww-bookmarks"))
(setq eww-history-limit 150)
diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el
index f02784d..ae21b37 100644
--- a/emacs/.emacs.d/lisp/my/my-org.el
+++ b/emacs/.emacs.d/lisp/my/my-org.el
@@ -507,14 +507,37 @@ Assuming they are in the logbook drawer"
(append-next-kill)
(kill-line))))))
-(defun my-org-clock-yank ()
+(defun my-org-element-at-drawer-p ()
+ "Returns t if point is at a drawer beginning or end."
+ (not (not
+ (member (org-element-type (org-element-at-point))
+ '(drawer property-drawer)))))
+
+(defun my-org-kill-logbook-entries ()
+ "Kill all logbook entries of the org node at point."
+ (interactive)
+ (let ((beg))
+ (save-excursion
+ (save-restriction
+ (org-narrow-to-subtree)
+ (goto-char (point-min))
+ (when (and (re-search-forward "^\\ *:LOGBOOK:\\ *$" nil t)
+ (my-org-element-at-drawer-p))
+ (beginning-of-line 2)
+ (setq beg (point))
+ (when (re-search-forward "^\\ *:END:\\ *$" nil t)
+ (beginning-of-line)
+ (kill-region beg (point))))))))
+
+(defun my-org-logbook-yank ()
"Yank whatever is in the kill ring into the logbook drawer."
(interactive)
(let ((end))
(save-restriction
(org-narrow-to-subtree)
(goto-char (point-min))
- (if (re-search-forward "^\\ *:LOGBOOK:\\ *$" nil t)
+ (if (and (re-search-forward "^\\ *:LOGBOOK:\\ *$" nil t)
+ (my-org-element-at-drawer-p))
;; If there's already a logbook, move to where the clock
;; entries should be inserted
(progn
@@ -531,12 +554,12 @@ Assuming they are in the logbook drawer"
(delete-char 1))
(yank))))
-(defun my-org-clock-refile-clocking ()
+(defun my-org-refile-logbook ()
(interactive)
- (my-org-clock-kill-entries)
+ (my-org-kill-logbook-entries)
(save-excursion
(call-interactively 'org-goto)
- (my-org-clock-yank)))
+ (my-org-logbook-yank)))
;;; to remove
(defun my-org-clock-collect-entries (drawer &optional remove)
@@ -1223,5 +1246,30 @@ When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
((member type '(nil entry)) (setq txt "* %?"))))
(org-capture-put :template txt :type type)))
+(defun my-org-entry-sizes ()
+ "Size analysis of all entries in the current org buffer.
+
+A new org buffer appears, with the whole org tree of the original
+buffer preserved, annotated with the size"
+ (with-current-buffer (get-buffer-create "*org-sizes*")
+ (erase-buffer)
+ (org-mode))
+ (save-excursion
+ (save-restriction
+ (org-content)
+ (beginning-of-buffer)
+ (unless (org-at-heading-p)
+ (org-next-visible-heading 1))
+ (let ((beg) (line))
+ (while (org-at-heading-p)
+ (setq beg (point)
+ line (buffer-substring-no-properties
+ beg (save-excursion (org-end-of-line) (point))))
+ (org-next-visible-heading 1)
+ (setq line (format "%s (%d)" line (- (point) beg)))
+ (with-current-buffer "*org-sizes*"
+ (insert line "\n"))))))
+ (switch-to-buffer-other-window "*org-sizes*"))
+
(provide 'my-org)
;;; my-org.el ends here
diff --git a/misc/bin/xdgdef b/misc/bin/xdgdef
new file mode 100755
index 0000000..3d8791f
--- /dev/null
+++ b/misc/bin/xdgdef
@@ -0,0 +1,5 @@
+#!/bin/bash
+# Print xdg file type and the default opener for a file
+
+filetype=$(xdg-mime query filetype "$1")
+echo $filetype=`xdg-mime query default "$filetype"`