aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-23 09:42:22 +1000
committerYuchen Pei <id@ypei.org>2023-06-23 09:42:22 +1000
commit56bf9566d2d1ff6814ec32e38550c84962d7f15b (patch)
tree7952cb84eadc752d96d8cdd6b13557f2b84ff27f /emacs/.emacs.d
parentbdc3969b723efdf9baad34e22f3f90702352a0a5 (diff)
adding votes to org entries
Diffstat (limited to 'emacs/.emacs.d')
-rw-r--r--emacs/.emacs.d/init/ycp-org.el2
-rw-r--r--emacs/.emacs.d/lisp/my/my-org.el14
2 files changed, 16 insertions, 0 deletions
diff --git a/emacs/.emacs.d/init/ycp-org.el b/emacs/.emacs.d/init/ycp-org.el
index 93d192f..6dbc26e 100644
--- a/emacs/.emacs.d/init/ycp-org.el
+++ b/emacs/.emacs.d/init/ycp-org.el
@@ -250,6 +250,8 @@
(setq org-use-speed-commands t)
(setq org-speed-commands
'(("User commands")
+ ("+" . my-org-vote-up)
+ ("-" . my-org-vote-down)
("m" . my-magit-clone-org-source)
("c" . my-org-copy-property-value)
("x" . my-org-osm-goto)
diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el
index cb72677..28c5354 100644
--- a/emacs/.emacs.d/lisp/my/my-org.el
+++ b/emacs/.emacs.d/lisp/my/my-org.el
@@ -999,5 +999,19 @@ When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
((org-footnote-at-reference-p) nil)
(t (apply orig-fun args)))))
+(defun my-org-vote-up (&optional points)
+ (interactive "p")
+ (org-entry-put
+ (point)
+ "Vote"
+ (number-to-string
+ (+ (or points 1)
+ (string-to-number
+ (or (org-entry-get (point) "Vote") "0"))))))
+
+(defun my-org-vote-down (&optional points)
+ (interactive "p")
+ (my-org-vote-up (- points)))
+
(provide 'my-org)
;;; my-org.el ends here