unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / Atom feed
* bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables
@ 2021-01-13 13:46 Protesilaos Stavrou
  2021-01-19  6:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Protesilaos Stavrou @ 2021-01-13 13:46 UTC (permalink / raw)
  To: 45840

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

Dear maintainers,

I have noticed that perl-mode modifies in a non-standard way the
font-lock-variable-name-face.  This makes it impossible to get perl
buffers to look like other programming modes, in accordance with user or
theme configurations.

The attached patch merely assigns font-lock-variable-name-face while
removing the hardcoded underline property.

If you think that the underline should remain in place, then I can
provide another patch that would add a new face which would inherit from
font-lock-variable-name-face and add an underline accordingly.

All the best,
Protesilaos

-- 
Protesilaos Stavrou
protesilaos.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-hardcoded-underline-for-perl-mode-variables.patch --]
[-- Type: text/x-patch, Size: 1187 bytes --]

From 69c6c946f24520edf34ea474290054c3ceb0cc0a Mon Sep 17 00:00:00 2001
From: Protesilaos Stavrou <info@protesilaos.com>
Date: Wed, 13 Jan 2021 14:53:18 +0200
Subject: [PATCH] Remove hardcoded underline for perl-mode variables

* lisp/progmodes/perl-mode.el (perl-font-lock-keywords-2): Just assign
'font-lock-variable-name-face' without editing it further.

This respects user or theme configurations with regard to font-lock
faces.
---
 lisp/progmodes/perl-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index fd8a51b5a5..15b6cb0c7e 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -191,7 +191,7 @@ perl-font-lock-keywords-2
      ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
      ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
      ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
-      (2 (cons font-lock-variable-name-face '(underline))))
+      (2 font-lock-variable-name-face))
      ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
      ;;
      ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
-- 
2.30.0


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

* bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables
  2021-01-13 13:46 bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables Protesilaos Stavrou
@ 2021-01-19  6:32 ` Lars Ingebrigtsen
  2021-01-19  7:07   ` Protesilaos Stavrou
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-19  6:32 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: 45840

Protesilaos Stavrou <info@protesilaos.com> writes:

> The attached patch merely assigns font-lock-variable-name-face while
> removing the hardcoded underline property.
>
> If you think that the underline should remain in place, then I can
> provide another patch that would add a new face which would inherit from
> font-lock-variable-name-face and add an underline accordingly.

The comment here mentions this:

     ;; Additionally underline non-scalar variables.  Maybe this is a bad idea.
     ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
     ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
     ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
      (2 (cons font-lock-variable-name-face '(underline))))

And it is a bad idea to hard-code this, but having different faces here
makes sense, I think.  So could you whip up another patch to add the new
face, as you suggested?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables
  2021-01-19  6:32 ` Lars Ingebrigtsen
@ 2021-01-19  7:07   ` Protesilaos Stavrou
  2021-01-19  7:11     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Protesilaos Stavrou @ 2021-01-19  7:07 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 45840

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

On 2021-01-19, 07:32 +0100, Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Protesilaos Stavrou <info@protesilaos.com> writes:
>
>> The attached patch merely assigns font-lock-variable-name-face while
>> removing the hardcoded underline property.
>>
>> If you think that the underline should remain in place, then I can
>> provide another patch that would add a new face which would inherit from
>> font-lock-variable-name-face and add an underline accordingly.
>
> The comment here mentions this:
>
>      ;; Additionally underline non-scalar variables.  Maybe this is a bad idea.
>      ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
>      ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
>      ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
>       (2 (cons font-lock-variable-name-face '(underline))))
>
> And it is a bad idea to hard-code this, but having different faces here
> makes sense, I think.  So could you whip up another patch to add the new
> face, as you suggested?

Thank you, Lars!  Please find attached the new patch.  I also added a
NEWS entry.  Feel free to edit it as you will.

-- 
Protesilaos Stavrou
protesilaos.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-perl-non-scalar-variable-face-to-perl-mode.patch --]
[-- Type: text/x-patch, Size: 2443 bytes --]

From 161ba7a2a406122c95ab0bb41d1b1bc9bde2d565 Mon Sep 17 00:00:00 2001
From: Protesilaos Stavrou <info@protesilaos.com>
Date: Tue, 19 Jan 2021 09:04:17 +0200
Subject: [PATCH] Add 'perl-non-scalar-variable' face to perl-mode

* lisp/progmodes/perl-mode.el (perl-non-scalar-variable): Define new
face.
(perl-font-lock-keywords-2): Apply 'perl-non-scalar-variable' face.

* etc/NEWS: Document the new face.
---
 etc/NEWS                    |  6 ++++++
 lisp/progmodes/perl-mode.el | 11 +++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index d632283e7f..8fc5f3e046 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -352,6 +352,12 @@ When emacsclient connects, Emacs will (by default) output a message
 about how to exit the client frame.  If 'server-client-instructions'
 is set to nil, this message is inhibited.
 
+** Perl mode
+
+---
+*** New face 'perl-non-scalar-variable'.
+This is used to fontify non-scalar variables.
+
 ** Python mode
 
 *** 'python-shell-interpreter' now defaults to python3 on systems with python3.
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index 2a2a4978c6..d047dd543c 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -95,6 +95,12 @@ perl
   :prefix "perl-"
   :group 'languages)
 
+(defface perl-non-scalar-variable
+  '((t :inherit font-lock-variable-name-face :underline t))
+  "Face used for non-scalar variables."
+  :version "28.1"
+  :group 'perl)
+
 (defvar perl-mode-abbrev-table nil
   "Abbrev table in use in perl-mode buffers.")
 (define-abbrev-table 'perl-mode-abbrev-table ())
@@ -187,11 +193,12 @@ perl-font-lock-keywords-2
      ;;
      ;; Fontify function, variable and file name references.
      ("&\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-function-name-face)
-     ;; Additionally underline non-scalar variables.  Maybe this is a bad idea.
+     ;; Additionally fontify non-scalar variables.  `perl-non-scalar-variable'
+     ;; will underline them by default.
      ;;'("[$@%*][#{]?\\(\\sw+\\)" 1 font-lock-variable-name-face)
      ("[$*]{?\\(\\sw+\\(::\\sw+\\)*\\)" 1 font-lock-variable-name-face)
      ("\\([@%]\\|\\$#\\)\\(\\sw+\\(::\\sw+\\)*\\)"
-      (2 (cons font-lock-variable-name-face '(underline))))
+      (2 'perl-non-scalar-variable))
      ("<\\(\\sw+\\)>" 1 font-lock-constant-face)
      ;;
      ;; Fontify keywords with/and labels as we do in `c++-font-lock-keywords'.
-- 
2.30.0


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

* bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables
  2021-01-19  7:07   ` Protesilaos Stavrou
@ 2021-01-19  7:11     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-19  7:11 UTC (permalink / raw)
  To: Protesilaos Stavrou; +Cc: 45840

Protesilaos Stavrou <info@protesilaos.com> writes:

> Thank you, Lars!  Please find attached the new patch.  I also added a
> NEWS entry.  Feel free to edit it as you will.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2021-01-19  7:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 13:46 bug#45840: 28.0.50; [PATCH] Remove hardcoded underline for perl-mode variables Protesilaos Stavrou
2021-01-19  6:32 ` Lars Ingebrigtsen
2021-01-19  7:07   ` Protesilaos Stavrou
2021-01-19  7:11     ` Lars Ingebrigtsen

unofficial mirror of bug-gnu-emacs@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/emacs-bugs/0 emacs-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 emacs-bugs emacs-bugs/ https://yhetil.org/emacs-bugs \
		bug-gnu-emacs@gnu.org
	public-inbox-index emacs-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.bugs
	nntp://news.gmane.io/gmane.emacs.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git