[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#28713: Inconvenient usage of defconst in python-mode
From: |
Noam Postavsky |
Subject: |
bug#28713: Inconvenient usage of defconst in python-mode |
Date: |
Thu, 05 Oct 2017 19:42:52 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) |
severity 28713 minor
tags 28713 + patch
quit
Lele Gaifax <lele@metapensiero.it> writes:
> have to do something like the following in one of my python-mode-hooks:
>
> ;; Prettify only lambda keyword
> (setq prettify-symbols-alist '(("lambda" . ?λ)))
>
> ;; Force a refresh
> (prettify-symbols-mode -1)
> (prettify-symbols-mode))
Actually you could probably get away with
(with-eval-after-load 'python
(setq python--prettify-symbols-alist '(("lambda" . ?λ))))
since defconst doesn't actually make anything const.
> This is of course a minor hassle, but I wonder if the major mode could/should
> use a normal variable (if not a defcustom) instead.
prettify-symbols-alist is not a defcustom, due to some uncertainty over
how to produce a reasonable interface for customizing it, if I recall
correctly. So I think the python-mode version should not be a defcustom
either, but I see no reason against making it a normal variable:
>From c430329a2138674c8d67ccb3f4ce92c6b75972b7 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Thu, 5 Oct 2017 19:16:46 -0400
Subject: [PATCH v1] Make python prettify symbols into a defvar (Bug#28713)
* lisp/progmodes/python.el (python-prettify-symbols-alist): New
variable.
(python--prettify-symbols-alist): Make into obsolete alias for
`python-prettify-symbols-alist'.
---
lisp/progmodes/python.el | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 9aa5134ca0..f79d9a47d3 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -640,10 +640,14 @@ python-syntax-propertize-function
((python-rx string-delimiter)
(0 (ignore (python-syntax-stringify))))))
-(defconst python--prettify-symbols-alist
+(defvar python-prettify-symbols-alist
'(("lambda" . ?λ)
("and" . ?∧)
- ("or" . ?∨)))
+ ("or" . ?∨))
+ "Value for `prettify-symbols-alist' in `python-mode'.")
+
+(define-obsolete-variable-alias 'python--prettify-symbols-alist
+ 'python-prettify-symbols-alist "26.1")
(defsubst python-syntax-count-quotes (quote-char &optional point limit)
"Count number of quotes around point (max is 3).
--
2.11.0