GNU bug report logs - #28713
Inconvenient usage of defconst in python-mode

Previous Next

Package: emacs;

Reported by: Lele Gaifax <lele <at> metapensiero.it>

Date: Thu, 5 Oct 2017 15:36:01 UTC

Severity: minor

Tags: fixed, patch

Fixed in version 26.1

Done: Noam Postavsky <npostavs <at> users.sourceforge.net>

Bug is archived. No further changes may be made.

Full log


Message #10 received at control <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Lele Gaifax <lele <at> metapensiero.it>
Cc: 28713 <at> debbugs.gnu.org
Subject: Re: bug#28713: Inconvenient usage of defconst in python-mode
Date: Thu, 05 Oct 2017 19:42:52 -0400
[Message part 1 (text/plain, inline)]
severity 28713 minor
tags 28713 + patch
quit

Lele Gaifax <lele <at> 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:

[v1-0001-Make-python-prettify-symbols-into-a-defvar-Bug-28.patch (text/x-diff, inline)]
From c430329a2138674c8d67ccb3f4ce92c6b75972b7 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> 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


This bug report was last modified 7 years and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.