unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48180: ruby-mode.el: fix font lock for puts and printf
@ 2021-05-03  1:01 Steve Purcell
  2021-05-03  7:41 ` Lars Ingebrigtsen
  2021-05-03 10:17 ` Dmitry Gutov
  0 siblings, 2 replies; 6+ messages in thread
From: Steve Purcell @ 2021-05-03  1:01 UTC (permalink / raw)
  To: 48180

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

Tags: patch

Both these methods can be called without arguments, so the font
locking of "bare" calls to either is incorrect.  The fix is to
font-lock them as for other kernel methods which accepts zero or more
arguments.


In GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin20.4.0, NS appkit-2022.44 Version 10.16 (Build 20E232))
Repository revision: 30d974bf5c02a1367291fbb6fa17a182bb7974b7
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.3

Configured using:
 'configure
 --prefix=/nix/store/kvhx6vn5wvif4s9aiwp75v8pxplh19i2-emacs-gcc-20210502.0
 --disable-build-details --with-modules --with-ns
 --disable-ns-self-contained --with-native-compilation
 CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-ruby-mode.el-puts-and-printf-do-not-r.patch --]
[-- Type: text/patch, Size: 1268 bytes --]

From 6041b603c0a4cadbd1eaa92a2d9c0162bedbd939 Mon Sep 17 00:00:00 2001
From: Steve Purcell <steve@sanityinc.com>
Date: Mon, 3 May 2021 12:54:53 +1200
Subject: [PATCH] lisp/progmodes/ruby-mode.el: puts and printf do not require
 args

Both these methods can be called without arguments, so the font
locking of "bare" calls to either is incorrect.  The fix is to
font-lock them as for other kernel methods which accepts zero or more
arguments.
---
 lisp/progmodes/ruby-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 35772827ce2..0c54a1d27a6 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -2127,11 +2127,9 @@ ruby-font-lock-keywords
           "loop"
           "open"
           "p"
-          "print"
           "printf"
           "proc"
           "putc"
-          "puts"
           "require"
           "require_relative"
           "spawn"
@@ -2180,9 +2178,11 @@ ruby-font-lock-keywords
           "fork"
           "global_variables"
           "local_variables"
+          "print"
           "private"
           "protected"
           "public"
+          "puts"
           "raise"
           "rand"
           "readline"
-- 
2.31.1


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

* bug#48180: ruby-mode.el: fix font lock for puts and printf
  2021-05-03  1:01 bug#48180: ruby-mode.el: fix font lock for puts and printf Steve Purcell
@ 2021-05-03  7:41 ` Lars Ingebrigtsen
  2021-05-03 10:17 ` Dmitry Gutov
  1 sibling, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-03  7:41 UTC (permalink / raw)
  To: Steve Purcell; +Cc: 48180

Steve Purcell <steve@sanityinc.com> writes:

> Both these methods can be called without arguments, so the font
> locking of "bare" calls to either is incorrect.  The fix is to
> font-lock them as for other kernel methods which accepts zero or more
> arguments.

Thanks; applied to Emacs 28.

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





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

* bug#48180: ruby-mode.el: fix font lock for puts and printf
  2021-05-03  1:01 bug#48180: ruby-mode.el: fix font lock for puts and printf Steve Purcell
  2021-05-03  7:41 ` Lars Ingebrigtsen
@ 2021-05-03 10:17 ` Dmitry Gutov
  2021-05-03 16:42   ` Juri Linkov
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2021-05-03 10:17 UTC (permalink / raw)
  To: Steve Purcell, 48180

Hi Steve,

On 03.05.2021 04:01, Steve Purcell wrote:
> Both these methods can be called without arguments, so the font
> locking of "bare" calls to either is incorrect.  The fix is to
> font-lock them as for other kernel methods which accepts zero or more
> arguments.

Is that important? Like, is anybody likely to call either without args? 
font-lock is not a precise facility (that anything depends on), so we 
can afford to be wrong in 0.01% cases.

If we institute this principle, I suppose we'll need to do this for all 
functions that can work without args? In my testing, that's also:

p, open, loop, warn, print

Also note that your title says 'printf', but the patch said 'print'.





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

* bug#48180: ruby-mode.el: fix font lock for puts and printf
  2021-05-03 10:17 ` Dmitry Gutov
@ 2021-05-03 16:42   ` Juri Linkov
  2021-05-03 20:31     ` Steve Purcell
  0 siblings, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2021-05-03 16:42 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: Steve Purcell, 48180

>> Both these methods can be called without arguments, so the font
>> locking of "bare" calls to either is incorrect.  The fix is to
>> font-lock them as for other kernel methods which accepts zero or more
>> arguments.
>
> Is that important? Like, is anybody likely to call either without args?
> font-lock is not a precise facility (that anything depends on), so we can
> afford to be wrong in 0.01% cases.

It always bothered me that in ruby-mode highlighting was broken for printing
without arguments, but I had no time to investigate.  Now finally this is fixed.
Maybe some other printing like "p" could be fixed as well, but the
already fixed "puts" and "print" is an improvement.





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

* bug#48180: ruby-mode.el: fix font lock for puts and printf
  2021-05-03 16:42   ` Juri Linkov
@ 2021-05-03 20:31     ` Steve Purcell
  2021-05-03 20:42       ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Purcell @ 2021-05-03 20:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 48180, Dmitry Gutov

On 4 May 2021, at 04:42, Juri Linkov <juri@linkov.net> wrote:
> 
>> Is that important? Like, is anybody likely to call either without args?
>> font-lock is not a precise facility (that anything depends on), so we can
>> afford to be wrong in 0.01% cases.
> 
> It always bothered me that in ruby-mode highlighting was broken for printing
> without arguments, but I had no time to investigate.  Now finally this is fixed.
> Maybe some other printing like "p" could be fixed as well, but the
> already fixed "puts" and "print" is an improvement.


Yes, it’s actually pretty common to just use “puts” without args to print an empty line.






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

* bug#48180: ruby-mode.el: fix font lock for puts and printf
  2021-05-03 20:31     ` Steve Purcell
@ 2021-05-03 20:42       ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2021-05-03 20:42 UTC (permalink / raw)
  To: Steve Purcell, Juri Linkov; +Cc: 48180

On 03.05.2021 23:31, Steve Purcell wrote:
>> It always bothered me that in ruby-mode highlighting was broken for printing
>> without arguments, but I had no time to investigate.  Now finally this is fixed.
>> Maybe some other printing like "p" could be fixed as well, but the
>> already fixed "puts" and "print" is an improvement.
> 
> Yes, it’s actually pretty common to just use “puts” without args to print an empty line.

Very good, then.





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

end of thread, other threads:[~2021-05-03 20:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03  1:01 bug#48180: ruby-mode.el: fix font lock for puts and printf Steve Purcell
2021-05-03  7:41 ` Lars Ingebrigtsen
2021-05-03 10:17 ` Dmitry Gutov
2021-05-03 16:42   ` Juri Linkov
2021-05-03 20:31     ` Steve Purcell
2021-05-03 20:42       ` Dmitry Gutov

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).