aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/custom.el
diff options
context:
space:
mode:
authorArtur Malabarba2015-10-25 01:37:17 +0100
committerArtur Malabarba2015-10-25 01:53:46 +0100
commit79fac080d277fed07b3c192890ad59d36d9f83b6 (patch)
tree856c29de61b6bb7c77680b0dd05d4c980513846f /lisp/custom.el
parentb6c6629ebe570baac53ed2a737f54711f29f79ca (diff)
downloademacs-79fac080d277fed07b3c192890ad59d36d9f83b6.tar.gz
emacs-79fac080d277fed07b3c192890ad59d36d9f83b6.zip
* lisp/custom.el (custom-declare-variable): Shorten code a bit
Diffstat (limited to 'lisp/custom.el')
-rw-r--r--lisp/custom.el57
1 files changed, 23 insertions, 34 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index c5d0e65f42b..cc284ef51ce 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -155,40 +155,29 @@ set to nil, as the value is no longer rogue."
155 (unless (memq :group args) 155 (unless (memq :group args)
156 (custom-add-to-group (custom-current-group) symbol 'custom-variable)) 156 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
157 (while args 157 (while args
158 (let ((arg (car args))) 158 (let ((keyword (pop args)))
159 (setq args (cdr args)) 159 (unless (symbolp keyword)
160 (unless (symbolp arg) 160 (error "Junk in args %S" (cons keyword args)))
161 (error "Junk in args %S" args)) 161 (unless args
162 (let ((keyword arg) 162 (error "Keyword %s is missing an argument" keyword))
163 (value (car args))) 163 (let ((value (pop args)))
164 (unless args 164 (pcase keyword
165 (error "Keyword %s is missing an argument" keyword)) 165 (`:initialize (setq initialize value))
166 (setq args (cdr args)) 166 (`:set (put symbol 'custom-set value))
167 (cond ((eq keyword :initialize) 167 (`:get (put symbol 'custom-get value))
168 (setq initialize value)) 168 (`:require (push value requests))
169 ((eq keyword :set) 169 (`:risky (put symbol 'risky-local-variable value))
170 (put symbol 'custom-set value)) 170 (`:safe (put symbol 'safe-local-variable value))
171 ((eq keyword :get) 171 (`:type (put symbol 'custom-type (purecopy value)))
172 (put symbol 'custom-get value)) 172 (`:options (if (get symbol 'custom-options)
173 ((eq keyword :require) 173 ;; Slow safe code to avoid duplicates.
174 (push value requests)) 174 (mapc (lambda (option)
175 ((eq keyword :risky) 175 (custom-add-option symbol option))
176 (put symbol 'risky-local-variable value)) 176 value)
177 ((eq keyword :safe) 177 ;; Fast code for the common case.
178 (put symbol 'safe-local-variable value)) 178 (put symbol 'custom-options (copy-sequence value))))
179 ((eq keyword :type) 179 (_ (custom-handle-keyword symbol keyword value
180 (put symbol 'custom-type (purecopy value))) 180 'custom-variable))))))
181 ((eq keyword :options)
182 (if (get symbol 'custom-options)
183 ;; Slow safe code to avoid duplicates.
184 (mapc (lambda (option)
185 (custom-add-option symbol option))
186 value)
187 ;; Fast code for the common case.
188 (put symbol 'custom-options (copy-sequence value))))
189 (t
190 (custom-handle-keyword symbol keyword value
191 'custom-variable))))))
192 (put symbol 'custom-requests requests) 181 (put symbol 'custom-requests requests)
193 ;; Do the actual initialization. 182 ;; Do the actual initialization.
194 (unless custom-dont-initialize 183 (unless custom-dont-initialize