-
Notifications
You must be signed in to change notification settings - Fork 0
/
org-glaux-menu.el
86 lines (73 loc) · 3.15 KB
/
org-glaux-menu.el
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
;;; org-glaux-menu.el --- Menu for Org-glaux -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 Firmin Martin
;; Author: Firmin Martin
;; Maintainer: Firmin Martin
;; Version: 0.3
;; Keywords: outlines, files, convenience
;; URL: https://www.github.com/firmart/org-glaux
;; Package-Requires: ((emacs "25.1") (org "9.3") (cl-lib "0.5"))
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides menu for Org-glaux. Enable it through
;; `org-glaux-menu-enable' and in case you haven't done it, activate
;; `menu-bar-mode'. The menu entries are generated automatically through
;; `org-glaux--easy-menu-entry' which takes a category name and a common prefix
;; of interactive functions.
;;; Code:
;;;###autoload
(defun org-glaux-menu-disable ()
"Disable the menu entry of org-glaux"
(interactive)
(require 'easymenu)
(easy-menu-define nil global-map nil
(list "Org-glaux" :active nil)))
;;;###autoload
(defun org-glaux-menu-enable ()
"Build and enable a menu for org-glaux."
(interactive)
(require 'easymenu)
(easy-menu-define org-glaux-menu global-map "Org-glaux"
(list "Org-glaux"
(org-glaux--easy-menu-entry "Backup" "org-glaux-backup")
(org-glaux--easy-menu-entry "Close" "org-glaux-close")
(org-glaux--easy-menu-entry "Dired" "org-glaux-dired")
(org-glaux--easy-menu-entry "Export" "org-glaux-export")
(org-glaux--easy-menu-entry "Index" "org-glaux-index")
(org-glaux--easy-menu-entry "Insert" "org-glaux-insert")
(org-glaux--easy-menu-entry "Navigation" "org-glaux-navi")
(org-glaux--easy-menu-entry "Search" "org-glaux-search")
(org-glaux--easy-menu-entry "Select" "org-glaux-select")
(org-glaux--easy-menu-entry "Server" "org-glaux-server")
(org-glaux--easy-menu-entry "Version control" "org-glaux-vc")
["---" nil]
(list "Miscellaneous"
(vector (documentation 'org-glaux-new-page) 'org-glaux-new-page)
(vector (documentation 'org-glaux-website) 'org-glaux-website)))))
;;;; Internal: Menu
(defun org-glaux--easy-menu-entry (entry-name prefix)
"Create a menu entry with ENTRY-NAME including functions prefixed by PREFIX."
;; (entry-name [doc_f1 f1] [doc_f2 f2] ...)
(cons entry-name
(mapcar
(lambda (f)
;; [<func-doc_first_line> <func>]
(vector (car (split-string (documentation (intern f)) "\n"))
(intern f)))
;; list of functions prefixed by PREFIX
(let (glaux-list)
(mapatoms (lambda (x)
(when (and (fboundp x)
(string-prefix-p prefix (symbol-name x)))
(push (symbol-name x) glaux-list ))))
glaux-list))))
;;; org-glaux-menu.el ends here
(provide 'org-glaux-menu)