unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#28713: Inconvenient usage of defconst in python-mode
@ 2017-10-05 15:35 Lele Gaifax
  2017-10-05 23:42 ` Noam Postavsky
  0 siblings, 1 reply; 4+ messages in thread
From: Lele Gaifax @ 2017-10-05 15:35 UTC (permalink / raw)
  To: 28713

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@metapensiero.it  |                 -- Fortunato Depero, 1929.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#28713: Inconvenient usage of defconst in python-mode
  2017-10-05 15:35 bug#28713: Inconvenient usage of defconst in python-mode Lele Gaifax
@ 2017-10-05 23:42 ` Noam Postavsky
  2017-10-06  6:49   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Noam Postavsky @ 2017-10-05 23:42 UTC (permalink / raw)
  To: Lele Gaifax; +Cc: 28713

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

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:


[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1300 bytes --]

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#28713: Inconvenient usage of defconst in python-mode
  2017-10-05 23:42 ` Noam Postavsky
@ 2017-10-06  6:49   ` Eli Zaretskii
  2017-10-08  0:11     ` Noam Postavsky
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-10-06  6:49 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: lele, 28713

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#28713: Inconvenient usage of defconst in python-mode
  2017-10-06  6:49   ` Eli Zaretskii
@ 2017-10-08  0:11     ` Noam Postavsky
  0 siblings, 0 replies; 4+ messages in thread
From: Noam Postavsky @ 2017-10-08  0:11 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: lele, 28713

tags 28713 fixed
close 28713 26.1
quit

Eli Zaretskii <eliz@gnu.org> writes:

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-08  0:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 15:35 bug#28713: Inconvenient usage of defconst in python-mode Lele Gaifax
2017-10-05 23:42 ` Noam Postavsky
2017-10-06  6:49   ` Eli Zaretskii
2017-10-08  0:11     ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).