bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#14591: New keyword :local for defcustom


From: Juanma Barranquero
Subject: bug#14591: New keyword :local for defcustom
Date: Tue, 11 Jun 2013 19:18:54 +0200

Package: emacs
Version: 24.3.50
Severity: wishlist
Tags: patch



This patch adds a new keyword :local to defcustom, to simplify cases like

(defcustom some-var some-val
   "A very long description
filling many lines
...
...
..."
  ;; some keywords)
(make-variable-buffer-local 'some-var)

i.e., it tries to solve the same problem (non-locality) for
customization variables that the new macro defvar-local solves for
defvars.

As designed, it accepts values 'local (which means make the symbol
automatically buffer-local), 'permanent (which makes the symbol
permanent-local), and t which does both.

OK to the idea, the interface, comments...?

    Juanma




2013-06-11  Juanma Barranquero  <lekktu@gmail.com>

* custom.el (custom-declare-variable): Accept new keyword :local.
(defcustom): Document it.

=== modified file 'etc/NEWS'
--- etc/NEWS 2013-06-07 03:23:57 +0000
+++ etc/NEWS 2013-06-11 17:04:53 +0000
@@ -544,6 +544,9 @@
 and functions should be separated by two hyphens if the symbol is not
 meant to be used by other packages.

+** defcustom now has a new keyword :local to mark the variable as
+automatically buffer-local and/or permanent-local.
+

 * Changes in Emacs 24.4 on Non-Free Operating Systems


=== modified file 'lisp/custom.el'
--- lisp/custom.el 2013-01-02 16:13:04 +0000
+++ lisp/custom.el 2013-06-11 16:44:11 +0000
@@ -173,6 +173,11 @@
  (put symbol 'risky-local-variable value))
  ((eq keyword :safe)
  (put symbol 'safe-local-variable value))
+                ((eq keyword :local)
+                 (when (memq value '(t local))
+                   (make-variable-buffer-local symbol))
+                 (when (memq value '(t permanent))
+                   (put symbol 'permanent-local t)))
  ((eq keyword :type)
  (put symbol 'custom-type (purecopy value)))
  ((eq keyword :options)
@@ -246,6 +251,9 @@
 :risky Set SYMBOL's `risky-local-variable' property to VALUE.
 :safe Set SYMBOL's `safe-local-variable' property to VALUE.
         See Info node `(elisp) File Local Variables'.
+:local  VALUE should be t, `local' or `permanent'.
+        If t or `local', mark SYMBOL as automatically buffer-local.
+        If t or `permanent', set SYMBOL's `permanent-local' property to t.

 The following common keywords are also meaningful.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]