unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Harald Jörg" <haj@posteo.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 66050@debbugs.gnu.org,
	Jens Schmidt <jschmidt4gnu@vodafonemail.de>,
	Stefan Kangas <stefankangas@gmail.com>
Subject: bug#66050: Making perl-mode.el obsolete
Date: Sun, 24 Sep 2023 21:29:08 +0000	[thread overview]
Message-ID: <87ttrjw997.fsf@oook.m.uunet.de> (raw)
In-Reply-To: <jwvo7hrbmnv.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 24 Sep 2023 11:58:48 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> It would need more work.  An important step is to identify the features
>> we should be able to switch off per customization.  I am somewhat
>> reluctant to add more options to cperl-mode if they can't be bundled
>> (like `cperl-hairy' does):  The possible combinations of options are a
>> nightmare to document, to test, and also to learn for new users.
>
> BTW, "bundling" is what Custom themes are for.
> At least to solve the "learn for new users" side of the problem.
> Not to say we should add more options (or more fine-grained options),
> but it can be helpful to simplify the code (a.g. avoid having to test both
> `cperl-dont-be-hairy` and `cperl-highlight-variables-indiscriminately`).

Agreed.

cperl-mode has many customization options I've never tried (nor fully
understood).  These days, "Perl Best Practices" (the book, almost 20
years old by now) and perltidy (the tool) could be taken as guidelines
for new users.  Unfortunately, Perl has lots of very knowledgeable old
users, some of which are rather religious in their opinions - and
perltidy lets all of them have it their way.

I *guess* that for new users a manual or tutorial would be helpful, but
don't know whether I can spend the time to write it (nor whether I'm the
right person to do it).

>> Yes, that should be covered.  The option name is somewhat ... weird, but
>> I didn't find enough motivation to change it (or to fiddle with
>> font-lock-level 3, which would be more in line with other modes).
>
> That's a downvote for font-lock levels from me.

Oh - I guessed that ignoring font-lock-levels was one of the things you
meant when you wrote that cperl-mode is different than other major modes...

>> This seems doable.  The easy way is to make cperl-hash-face and
>> cperl-array-face customizable so that they can be "downgraded" to
>> font-lock-variable-name-face.
>
> They're faces, so they are already customizable, e.g. via Custom themes.

Sure.  I think that creating custom themes might be a bit beyond what
*users* of c?perl-mode might want to do (I myself never did that).
Emacs comes with themes which look better than anything I could create -
and adding four extra faces which fit these palettes needs experience I
don't have.

>>> 3. Variable sigils ("$", "%", "@") should not be highlighted at all.
>> I doubt that this is worth the effort in cperl-mode... and guess it
>> should be tolerable.  The sigil *is* part of the variable, after all.
>
> FWIW, I agree.  We don't have to satisfy all the wishlist items of
> previous `perl-mode` users.

>>> 4. Builtins ("shift", "ref", "defined") should not be highlighted at
>>>    all.
>> This is an area where cperl-mode is a bit untidy.  It has two different
>> faces for builtins, depending on whether they can be overridden by user
>> functions with the same name.  Many occur in two lists for
>> fontification, only the first one ever applies.  This has *some*
>> justification because builtins allow sloppy syntax (omitting
>> parentheses).
>
> What part of this is "untidy" or "a mess"?  I can see why you'd say it
> w.r.t Perl having those fine distinctions, but the corresponding
> features in `cperl-mode` seem to just reflect Perl's syntax&semantics.
> Or is it the implementation part to distinguish those two kinds of
> builtins messy?

It is the implementation.

There's some overlap in the "regex-opt" lists of keywords
(e.g. "require", "for").  Some of the "builtin functions" are actually binary
operands ("eq" and friends).  "use" is fontified as a keyword, but "no"
(which is sort of "do not use") is fontified as a non-overridable
function.  The builtins use font-lock-type-face, which isn't
appropriate.  "shift" is fontified as non-overridable, but it can be
overridden in recent Perl versions.

An overhaul of all of this would take some time, and probably a thick
skin to weather the storm caused by cperl-mode users who are accustomed
to the current colors.

>> When we clean up this mess, adding a way to not
>> highlighting them at all should not be too difficult.
>
> AFAIK that can also be solved by changing the faces' appearance, hence
> without changing the code.

Agreed.

>>> 5. Package names should be highlighted as font-lock-constant-face rather
>>>    than font-lock-function-face.
>>
>> perl-mode uses font-lock-function-name-face in the package declaration
>> but font-lock-constant-face in 'use' statements.  I can't say whether
>> that is intentional.
>>
>> Someone once suggested to use font-lock-type-face (because packages
>> usually are classes, and classes are sort-of types).  This is one of the
>> cases where I doubt that adding more options will actually improve
>> things.
>
> I think it's more important here to choose a "meaningful/consistent"
> behavior than to reproduce what was done historically in `perl-mode` or
> `cperl-mode`.

Agreed!

>>> 7. Regexps should be highlighted as font-lock-string-face.
>> This can be added as an option with some effort.  Regexps aren't
>> strings, but alas, almost no syntax highlighter takes the same effort as
>> cperl-mode to display them.
>
> Here again, I believe it's a small matter of changing faces.

It is a bit more than _changing_ faces.  In the match part, cperl-mode
highlights metacharacters (|) as keywords, [] as functions, and
character classes (\d \D \s and friends) as types.  The substitution
part can be actual Perl code, and cperl-mode will fontify it as Perl
code.

For example, the following substitution is rather colorful in cperl-mode
but (sorry) dull in perl-mode:

   s/\d+|[IVXLCDM]+(\D)/sqrt(2) . "_$1_"/eri;

Making these highlightings optional would, as far as I know, require to
define an extra set of faces, which could then be mapped either to their
cperl-mode values (cperl-mode style) or all to font-lock-string-face
(perl-mode style).

-- 
Cheers,
haj





  reply	other threads:[~2023-09-24 21:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-17 12:47 bug#66050: Making perl-mode.el obsolete Stefan Kangas
2023-09-17 16:34 ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-17 18:20   ` Stefan Kangas
2023-09-17 20:59     ` Jens Schmidt via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-22  7:39       ` Stefan Kangas
2023-09-24  0:02       ` Harald Jörg
2023-09-24 15:58         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-24 21:29           ` Harald Jörg [this message]
2023-09-24 22:12             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25  9:18               ` Harald Jörg
2023-09-25 10:09                 ` Mauro Aranda
2023-09-25 10:34                   ` Harald Jörg
2023-09-18 14:11 ` Corwin Brust
2023-09-20 18:34   ` Richard Stallman
2023-09-20 23:26     ` Stefan Kangas
2023-09-21  0:08       ` Corwin Brust
2023-09-21  0:16         ` Stefan Kangas
2023-09-21  0:37           ` Corwin Brust
2023-09-21  0:49             ` Stefan Kangas
2023-09-21 14:13           ` Mauro Aranda
2023-09-21 14:20             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-21 20:14               ` Mauro Aranda
2023-09-24  5:30                 ` Stefan Kangas
2023-09-24 22:21             ` Harald Jörg
2023-09-24 22:40               ` Mauro Aranda
2023-09-25  8:33                 ` Harald Jörg
2023-09-25 13:04                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-24 22:54               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-25  8:40                 ` Harald Jörg
2023-09-18 16:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-24  0:44   ` Harald Jörg
2023-09-24  7:31     ` Stefan Kangas
2023-09-24 16:01       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-26  9:02       ` Richard Stallman
2023-09-23 22:13 ` Harald Jörg
2023-09-24 10:41   ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttrjw997.fsf@oook.m.uunet.de \
    --to=haj@posteo.de \
    --cc=66050@debbugs.gnu.org \
    --cc=jschmidt4gnu@vodafonemail.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).