all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#50482: Unhelpful error message whilst byte-compiling a function.
@ 2021-09-08 20:37 Alan Mackenzie
  2021-09-09 14:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Mackenzie @ 2021-09-08 20:37 UTC (permalink / raw)
  To: 50482

Hello, Emacs

I'm working on Emacs 28.  Not emacs -Q, but it shouldn't matter.

I'm working on a function which begins thus:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun jit-lock--run-functions-new (beg end &optional last-fun)
  (let ((tight-beg nil) (tight-end nil) ; The region we have fully fontified.
        (loose-beg beg) (loose-end end)) ; The maximum region we have fontified
                                        ; with at least some of
                                        ; `jit-lock-functions'.
    (run-hook-wrapped
     'jit-lock-functions
......
......
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

On doing M-x compile-defun on this function, I get as sum total of the
output in *Compile-Log* this:

Buffer jit-lock.el:416:1: Error: Wrong number of arguments: #<subr
macroexp--warn-wrap>, 3

..  I don't know what this means.  Line 416 is the line where the defun
starts.  I don't have `macroexp--warn-wrap' anywhere in my source code,
it's not clear to what form 3 arguments are being wrongly passed, or
where.

Emacs compilation messages should not be so obscure.  This message
should be so formulated that I can see immediately what needs fixing.

#########################################################################

Second curiosity.  I can evaluate that defun form, and when I do C-h C-f
on it, I get:

jit-lock--run-functions-new is a Lisp closure in `jit-lock.el'.

A "closure" for crying out loud.  It's a FUNCTION, created by defun.
Calling a function a "closure" seems very pretentious and somewhat
patronising.  Not all users will know what it means.

Was there some discussion on emacs-devel which I somehow missed, where
this was agreed to?  If not, can we restore this word to "function",
please?

-- 
Alan Mackenzie (Nuremberg, Germany).





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

* bug#50482: Unhelpful error message whilst byte-compiling a function.
  2021-09-08 20:37 bug#50482: Unhelpful error message whilst byte-compiling a function Alan Mackenzie
@ 2021-09-09 14:42 ` Lars Ingebrigtsen
  2021-09-09 17:13   ` Alan Mackenzie
  2021-09-09 18:12   ` Alan Mackenzie
  0 siblings, 2 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-09 14:42 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 50482

Alan Mackenzie <acm@muc.de> writes:

> I'm working on a function which begins thus:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (defun jit-lock--run-functions-new (beg end &optional last-fun)
>   (let ((tight-beg nil) (tight-end nil) ; The region we have fully fontified.
>         (loose-beg beg) (loose-end end)) ; The maximum region we have fontified
>                                         ; with at least some of
>                                         ; `jit-lock-functions'.
>     (run-hook-wrapped
>      'jit-lock-functions
> ......
> ......
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> On doing M-x compile-defun on this function, I get as sum total of the
> output in *Compile-Log* this:
>
> Buffer jit-lock.el:416:1: Error: Wrong number of arguments: #<subr
> macroexp--warn-wrap>, 3

If I just put that in a buffer (and add some closing parentheses), I
don't get that warning.  Is there something else needed?

> ..  I don't know what this means.  Line 416 is the line where the defun
> starts.  I don't have `macroexp--warn-wrap' anywhere in my source code,
> it's not clear to what form 3 arguments are being wrongly passed, or
> where.

The warn-wrap stuff comes from `with-suppressed-warnings', I think.

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





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

* bug#50482: Unhelpful error message whilst byte-compiling a function.
  2021-09-09 14:42 ` Lars Ingebrigtsen
@ 2021-09-09 17:13   ` Alan Mackenzie
  2021-09-09 18:12   ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2021-09-09 17:13 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 50482

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

Hello, Lars.

On Thu, Sep 09, 2021 at 16:42:29 +0200, Lars Ingebrigtsen wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > I'm working on a function which begins thus:

> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > (defun jit-lock--run-functions-new (beg end &optional last-fun)
> >   (let ((tight-beg nil) (tight-end nil) ; The region we have fully fontified.
> >         (loose-beg beg) (loose-end end)) ; The maximum region we have fontified
> >                                         ; with at least some of
> >                                         ; `jit-lock-functions'.
> >     (run-hook-wrapped
> >      'jit-lock-functions
> > ......
> > ......
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

> > On doing M-x compile-defun on this function, I get as sum total of the
> > output in *Compile-Log* this:

> > Buffer jit-lock.el:416:1: Error: Wrong number of arguments: #<subr
> > macroexp--warn-wrap>, 3

> If I just put that in a buffer (and add some closing parentheses), I
> don't get that warning.  Is there something else needed?

It would appear so.  On putting the entire function into *scratch*,
compile-defun gives the same error in scratch, so I'm attaching the file.
Note that lexical-binding was t in my *scratch*.

> > ..  I don't know what this means.  Line 416 is the line where the defun
> > starts.  I don't have `macroexp--warn-wrap' anywhere in my source code,
> > it's not clear to what form 3 arguments are being wrongly passed, or
> > where.

> The warn-wrap stuff comes from `with-suppressed-warnings', I think.

Just to be entirely clear, I'm not asking for help in debugging this
error message (although that wouldn't go amiss) - I'm asking that Emacs
be amended such that this unhelpful message cannot appear any more.

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

-- 
Alan Mackenzie (Nuremberg, Germany).


[-- Attachment #2: jit-lock--run-functions-new.el --]
[-- Type: text/plain, Size: 2705 bytes --]

(defun jit-lock--run-functions-new (beg end &optional last-fun)
  (let ((tight-beg nil) (tight-end nil) ; The region we have fully fontified.
        (loose-beg beg) (loose-end end)) ; The maximum region we have fontified
                                        ; with at least some of
                                        ; `jit-lock-functions'.
    (run-hook-wrapped
     'jit-lock-functions
     (lambda (fun)
       (if (eq fun last-fun)
           ;; If an earlier function in a recursive call has enlarged
           ;; the region being fontified, we need to re-run `last-fun'.
           (progn
             (when (< loose-beg beg)
               (pcase-let*
                   ((res (funcall fun loose-beg beg))
                    (`(,this-beg . ,this-end)
                     (if (eq (car-safe res) 'jit-lock-bounds)
                         (cdr res) (cons loose-beg beg))))
                 (setq loose-beg this-beg)))
             (when (> loose-end end)
               (pcase-let*
                   ((res (funcall fun end loose-end))
                    (`(,this-beg . ,this-end)
                     (if (eq (car-safe res) 'jit-lock-bounds)
                         (cdr res) (cons end loose-end))))
                 (setq loose-end this-end)))
             t)                         ; quit `run-hook-wrapped'.
         (pcase-let*
             ;; The first function in `jit-lock-functions' can expand
             ;; the region into `tight-beg' and `tight-end'.  These
             ;; arguments are passed to the next function (if any).
             ;; Subsequently, the expanded region from any function is
             ;; stored in `loose-beg' and `loose-end', and is likewise
             ;; passed to the next function.
             ((res (funcall fun loose-beg loose-end))
              (`(,this-beg . ,this-end)
               (if (eq (car-safe res) 'jit-lock-bounds)
                   (cdr res) (cons beg end))))
;;;; NEW STOUGH, 2021-09-07
           (when (< this-beg loose-beg)
             (let ((sub-beg (car (jit-lock--run-functions
                                  this-beg loose-beg fun))))
               (setq loose-beg this-beg)))
           (when (> this-end loose-end)
             (jit-lock--run-functions loose-end this-end)
             (setq loose-end this-end))
;;;; END OF NEW STOUGH
           (or tight-beg (setq tight-beg (min this-beg beg)))
           (or tight-end (setq tight-end (max this-end end)))
           (setq loose-beg (min loose-beg this-beg))
           (setq loose-end (max loose-end this-end))
           nil))))                      ; Carry on executing the hook.
    `(,(or tight-beg beg) ,(or tight-end end) ,loose-beg ,loose-end)))

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

* bug#50482: Unhelpful error message whilst byte-compiling a function.
  2021-09-09 14:42 ` Lars Ingebrigtsen
  2021-09-09 17:13   ` Alan Mackenzie
@ 2021-09-09 18:12   ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2021-09-09 18:12 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 50482-done

Hello again, Lars.

On Thu, Sep 09, 2021 at 16:42:29 +0200, Lars Ingebrigtsen wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > I'm working on a function which begins thus:
> >
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > (defun jit-lock--run-functions-new (beg end &optional last-fun)
> >   (let ((tight-beg nil) (tight-end nil) ; The region we have fully fontified.
> >         (loose-beg beg) (loose-end end)) ; The maximum region we have fontified
> >                                         ; with at least some of
> >                                         ; `jit-lock-functions'.
> >     (run-hook-wrapped
> >      'jit-lock-functions
> > ......
> > ......
> > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> >
> > On doing M-x compile-defun on this function, I get as sum total of the
> > output in *Compile-Log* this:
> >
> > Buffer jit-lock.el:416:1: Error: Wrong number of arguments: #<subr
> > macroexp--warn-wrap>, 3

> If I just put that in a buffer (and add some closing parentheses), I
> don't get that warning.  Is there something else needed?

> > ..  I don't know what this means.  Line 416 is the line where the defun
> > starts.  I don't have `macroexp--warn-wrap' anywhere in my source code,
> > it's not clear to what form 3 arguments are being wrongly passed, or
> > where.

> The warn-wrap stuff comes from `with-suppressed-warnings', I think.

The problem was I hadn't compiled macroexp.el for a long time, and in
the meantime macroexp--warn-wrap had indeed acquired an extra parameter.
The version I have is expecting 2 arguments, but is being supplied with
3.

Apologies for sending you on a wild goose chase.  I will close the bug
as not a bug.

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

-- 
Alan Mackenzie (Nuremberg, Germany).





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

end of thread, other threads:[~2021-09-09 18:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-08 20:37 bug#50482: Unhelpful error message whilst byte-compiling a function Alan Mackenzie
2021-09-09 14:42 ` Lars Ingebrigtsen
2021-09-09 17:13   ` Alan Mackenzie
2021-09-09 18:12   ` Alan Mackenzie

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.