-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpel-custom.el
94 lines (80 loc) · 3.37 KB
/
pel-custom.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
87
88
89
90
91
92
93
94
;;; pel-custom.el --- PEL custization utilities. -*- lexical-binding: t; -*-
;; Created : Wednesday, October 21 2020.
;; Author : Pierre Rouleau <[email protected]>
;; Time-stamp: <2021-08-19 10:36:06, updated by Pierre Rouleau>
;; This file is part of the PEL package.
;; This file is not part of GNU Emacs.
;; Copyright (C) 2020, 2021 Pierre Rouleau
;;
;; 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 adds a set of commands that helps customization of Emacs and PEL.
;; Emacs customization browser is very useful and easy to use. It provides a
;; quick overview of the data organization and it ought to become better
;; known. The `pel-browse-pel' and `pel-browse-group' commands provide quick
;; access to the PEL customization group and any group respectively. This
;; last command complements the Emacs `customize-browse' command that
;; unfortunately does not accept any argument.
;;
;; The `pel-customize-save' function is used by PEL to store new values of
;; user-options to the custom-file currently used or explicitly specified.
;;; --------------------------------------------------------------------------
;;; Dependencies:
;;
;;
(require 'pel--base)
(require 'cus-edit) ; use: customize-save-variable
;;; --------------------------------------------------------------------------
;;; Code:
;;
;;-pel-autoload
(defun pel-browse-pel ()
"Browse the PEL customization group."
(interactive)
(pel-require 'cus-edit)
(customize-browse 'pel))
(defun pel--read-group ()
"Read and return a group name.
Lazily load file `cus-edit' if needed."
(pel-require 'cus-edit)
(if (fboundp 'customize-read-group)
(customize-read-group)
(user-error "Cannot load cus-edit!")))
;;-pel-autoload
(defun pel-browse-group (group)
"Browse the customization tree from a specific GROUP node."
(interactive (list (pel--read-group)))
(pel-require 'cus-edit)
(when (stringp group)
(if (string-equal "" group)
(setq group 'emacs)
(setq group (intern group)))
(customize-browse group)))
;;-pel-autoload
(defun pel-customize-pel-base-emacs-group (&optional other-window)
"Open `pel-base-emacs' customization group."
(interactive "P")
(customize-group 'pel-base-emacs other-window))
;; --
(defun pel-customize-save (user-option-symbol value &optional file)
"Save the VALUE of USER-OPTION-SYMBOL in customize file.
If FILE is specified force saving to specified customization FILE
otherwise save to the current custom-file."
(let ((custom-file (or file custom-file)))
(customize-save-variable user-option-symbol value)))
;;; --------------------------------------------------------------------------
(provide 'pel-custom)
;;; pel-custom.el ends here