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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28713 in the body.
You can then email your comments to 28713 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28713; Package emacs. (Thu, 05 Oct 2017 15:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lele Gaifax <lele <at> metapensiero.it>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 05 Oct 2017 15:36:02 GMT) Full text and rfc822 format available.

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

From: Lele Gaifax <lele <at> metapensiero.it>
To: bug-gnu-emacs <at> gnu.org
Subject: Inconvenient usage of defconst in python-mode
Date: Thu, 05 Oct 2017 17:35:04 +0200
In Emacs 25+, to be exact after commit
dadcf33984391a285ef0b161c1122864264e4386, python-mode uses a defconst to
define the value of `python--prettify-symbols-alist':

  (defconst python--prettify-symbols-alist
    '(("lambda"  . ?\u03bb)
      ("and" . ?\u2227)
      ("or" . ?\u2228)))

that is used just once in the major mode initializer:

  (set (make-local-variable 'prettify-symbols-alist)
       python--prettify-symbols-alist)

While the replacement for "lambda" is pretty, I find the other two quite
unreadable. To get rid of those I cannot simply customize the alist, but I
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))

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.

Thanks&bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele <at> metapensiero.it  |                 -- Fortunato Depero, 1929.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28713; Package emacs. (Thu, 05 Oct 2017 23:44:02 GMT) Full text and rfc822 format available.

Message #8 received at 28713 <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


Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Thu, 05 Oct 2017 23:44:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Thu, 05 Oct 2017 23:44:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28713; Package emacs. (Fri, 06 Oct 2017 06:51:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: lele <at> metapensiero.it, 28713 <at> debbugs.gnu.org
Subject: Re: bug#28713: Inconvenient usage of defconst in python-mode
Date: Fri, 06 Oct 2017 09:49:58 +0300
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Thu, 05 Oct 2017 19:42:52 -0400
> Cc: 28713 <at> debbugs.gnu.org
> 
> > 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:

Thanks, LGTM.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28713; Package emacs. (Sun, 08 Oct 2017 00:12:01 GMT) Full text and rfc822 format available.

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

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: lele <at> metapensiero.it, 28713 <at> debbugs.gnu.org
Subject: Re: bug#28713: Inconvenient usage of defconst in python-mode
Date: Sat, 07 Oct 2017 20:11:12 -0400
tags 28713 fixed
close 28713 26.1
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
>> Date: Thu, 05 Oct 2017 19:42:52 -0400
>> Cc: 28713 <at> debbugs.gnu.org
>> 
>> > 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:
>
> Thanks, LGTM.

Pushed to emacs-26.

[1: c194fb61c6]: 2017-10-07 19:19:05 -0400
  Make python prettify symbols into a defvar (Bug#28713)
  http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=c194fb61c638490e3510864fe2750814af8c3719




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sun, 08 Oct 2017 00:12:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.1, send any further explanations to 28713 <at> debbugs.gnu.org and Lele Gaifax <lele <at> metapensiero.it> Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Sun, 08 Oct 2017 00:12:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 Nov 2017 12:24:03 GMT) Full text and rfc822 format available.

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

Previous Next


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