-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdorg.el
More file actions
89 lines (72 loc) · 2.75 KB
/
dorg.el
File metadata and controls
89 lines (72 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
;;; dorg.el --- Manage Org-mode entries with Debbugs -*- lexical-binding: t; -*-
;; Copyright (C) 2020 Oleg Pykhalov
;; Author: Oleg Pykhalov <go.wigust@gmail.com>
;; Keywords: extensions
;; URL: https://github.com/kitnil/dorg
;; Version: 1.0.1
;; Package-Requires: ((emacs "25.1") (debbugs "0.25"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This package provides functions for Org-mode to manage entries
;; according to information received via Debbugs.
;;; Code:
(require 'debbugs)
(require 'org)
(defgroup dorg nil
"Settings for `dorg'."
:prefix "dorg-"
:group 'dorg)
(defcustom dorg-regexp-bug
(rx line-start (one-or-more anything)
"bug" "#" (group (one-or-more numeric))
(one-or-more anything) line-end)
"Regexp matching bug in Org-mode's entry."
:type 'regexp
:group 'dorg)
(defcustom dorg-regexp-guix-issue
(rx line-start (one-or-more anything)
"http" (zero-or-one "s") "://issues.guix.gnu.org/"
(zero-or-one "issue/") (group (one-or-more numeric))
(one-or-more anything) line-end)
"Regexp matching bug on Guix issue."
:type 'regexp
:group 'dorg)
(defun dorg-bug-number ()
"Get bug number from Org-mode entry at point."
(let ((org-entry (buffer-substring (org-entry-beginning-position)
(org-entry-end-position))))
(if (or (string-match dorg-regexp-bug org-entry)
(string-match dorg-regexp-guix-issue org-entry))
(substring-no-properties (match-string 1 org-entry))
nil)))
(defun dorg-bug-status (bug-number)
"Get BUG-NUMBER status."
(alist-get 'pending
(car (debbugs-get-status (string-to-number bug-number)))))
;;;###autoload
(defun dorg-bug-update ()
"Update Org-entry at point."
(interactive)
(let ((bug-number (dorg-bug-number)))
(if (or (not bug-number)
(equal (dorg-bug-status bug-number) "pending"))
(message (format "%s is still open." bug-number))
(org-todo 'done))))
;;;###autoload
(defun dorg-bugs-update ()
"Update all Org-entries in current buffer."
(interactive)
(dorg-bug-update)
(while (org-get-next-sibling)
(dorg-bug-update)))
(provide 'dorg)
;;; dorg.el ends here