unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27646: Bug: Emacs Lisp Indentation
@ 2017-07-10 20:05 Alexander Shukaev
  2017-07-11  1:05 ` npostavs
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Shukaev @ 2017-07-10 20:05 UTC (permalink / raw)
  To: 27646; +Cc: npostavs

Hi,

With latest Emacs, I see the following indentation quirk with the Emacs 
Lisp list:

(defconst init-font-lock-keywords
   `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
             (keywords         nil))
         (dolist (symbol '(init-a
                            init-b
                            init-c
                            init-d
                            init-e
                            init-f))
           (push `(,(format "(%s\\_>" symbol)
                   (,constant-pattern
                    (save-excursion
                      (search-forward-regexp ,constant-pattern))
                    nil
                    (0 font-lock-constant-face nil t)))
                 keywords))
         keywords)))

instead of the expected:

(defconst init-font-lock-keywords
   `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
             (keywords         nil))
         (dolist (symbol '(init-a
                           init-b
                           init-c
                           init-d
                           init-e
                           init-f))
           (push `(,(format "(%s\\_>" symbol)
                   (,constant-pattern
                    (save-excursion
                      (search-forward-regexp ,constant-pattern))
                    nil
                    (0 font-lock-constant-face nil t)))
                 keywords))
         keywords)))

Please, have a look as time permits.  Thank you in advance!

Kind regards,
Alexander





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

* bug#27646: Bug: Emacs Lisp Indentation
  2017-07-10 20:05 bug#27646: Bug: Emacs Lisp Indentation Alexander Shukaev
@ 2017-07-11  1:05 ` npostavs
  2017-11-29  2:26   ` Noam Postavsky
  0 siblings, 1 reply; 7+ messages in thread
From: npostavs @ 2017-07-11  1:05 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: 27646

tags 27646 + unreproducible
quit

Alexander Shukaev <emacs@Alexander.Shukaev.name> writes:

> Hi,
>
> With latest Emacs, I see the following indentation quirk with the
> Emacs Lisp list:
>
> (defconst init-font-lock-keywords
>   `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
>             (keywords         nil))
>         (dolist (symbol '(init-a
>                            init-b

That would certainly be a bug, but I can't reproduce this, when I run
indent-region or indent-sexp on that code I get the correct indentation:

(defconst init-font-lock-keywords
  `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
            (keywords         nil))
        (dolist (symbol '(init-a
                          init-b

In GNU Emacs 26.0.50 (build 60, x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars)
 of 2017-07-10 built on zony
Repository revision: 689c5c20d1174e95be50e674d05632545eb4b9c5
Windowing system distributor 'The X.Org Foundation', version 11.0.11901000
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
You can run the command ‘emacs-lisp-mode’ with M-x e-li-mo RET
Mark set
Indenting region...done
Mark activated

Configured using:
 'configure --cache-file=../debug-config.cache 'CFLAGS=-O0 -g3
 -march=native' --enable-checking=yes,glyphs
 --enable-check-lisp-object-type MAKEINFO=makeinfo-4.13a
 --with-x-toolkit=lucid --with-toolkit-scroll-bars --with-gif=no
 --with-jpeg=no 'CFLAGS=-O2 -g3 -march=native'
 --cache-file=../opt-config.cache'

Configured features:
XPM TIFF PNG RSVG SOUND GPM DBUS GSETTINGS NOTIFY ACL GNUTLS LIBXML2
FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 LIBSYSTEMD







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

* bug#27646: Bug: Emacs Lisp Indentation
  2017-07-11  1:05 ` npostavs
@ 2017-11-29  2:26   ` Noam Postavsky
  2019-12-19  1:27     ` Alexander Shukaev
  0 siblings, 1 reply; 7+ messages in thread
From: Noam Postavsky @ 2017-11-29  2:26 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: 27646

close 27646
quit

npostavs@users.sourceforge.net writes:

> That would certainly be a bug, but I can't reproduce this, when I run
> indent-region or indent-sexp on that code I get the correct indentation:
>
> (defconst init-font-lock-keywords
>   `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
>             (keywords         nil))
>         (dolist (symbol '(init-a
>                           init-b

Closing, since there's been no followup.





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

* bug#27646: Bug: Emacs Lisp Indentation
  2017-11-29  2:26   ` Noam Postavsky
@ 2019-12-19  1:27     ` Alexander Shukaev
  2020-01-17 17:58       ` Noam Postavsky
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Shukaev @ 2019-12-19  1:27 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 27646

On 11/29/17 3:26 AM, Noam Postavsky wrote:
> close 27646
> quit
> 
> npostavs@users.sourceforge.net writes:
> 
>> That would certainly be a bug, but I can't reproduce this, when I run
>> indent-region or indent-sexp on that code I get the correct indentation:
>>
>> (defconst init-font-lock-keywords
>>    `(,@(let ((constant-pattern "\\(?:\\sw\\|\\s_\\)+")
>>              (keywords         nil))
>>          (dolist (symbol '(init-a
>>                            init-b
> 
> Closing, since there's been no followup.
> 

This time I realized what's happening.  Put

(dolist (symbol '(ignore-errors
                   xxx
                   yyy)))

to the "*scratch*" buffer and indent to observe the following result

(dolist (symbol '(ignore-errors
                    xxx
                    yyy)))

The reason why this happens is because `ignore-errors' is a macro that has

(declare (indent defun))

Any other macro with the same declaration whose innocent symbol is used 
as the first element in a list would reproduce the above indentation 
bug.  Backquote is also affected.





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

* bug#27646: Bug: Emacs Lisp Indentation
  2019-12-19  1:27     ` Alexander Shukaev
@ 2020-01-17 17:58       ` Noam Postavsky
  2020-01-17 20:26         ` bug#21922: " Alexander Shukaev
  0 siblings, 1 reply; 7+ messages in thread
From: Noam Postavsky @ 2020-01-17 17:58 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: 27646

tags 27646 - moreinfo unreproducible
forcemerge 21922 27646
quit

Alexander Shukaev <emacs@Alexander.Shukaev.name> writes:

> to the "*scratch*" buffer and indent to observe the following result
>
> (dolist (symbol '(ignore-errors
>                    xxx
>                    yyy)))
>
> The reason why this happens is because `ignore-errors' is a macro that has
>
> (declare (indent defun))
>
> Any other macro with the same declaration whose innocent symbol is
> used as the first element in a list would reproduce the above
> indentation bug.  Backquote is also affected.

That's Bug#21922, although the backquoted case is intentional (e.g., for
writing code in macros).






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

* bug#21922: bug#27646: Bug: Emacs Lisp Indentation
  2020-01-17 17:58       ` Noam Postavsky
@ 2020-01-17 20:26         ` Alexander Shukaev
  2022-01-30 22:46           ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Shukaev @ 2020-01-17 20:26 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 27646, 21922

On 17/01/2020 18:58, Noam Postavsky wrote:
> tags 27646 - moreinfo unreproducible
> forcemerge 21922 27646
> quit
> 
> Alexander Shukaev <emacs@Alexander.Shukaev.name> writes:
> 
>> to the "*scratch*" buffer and indent to observe the following result
>>
>> (dolist (symbol '(ignore-errors
>>                     xxx
>>                     yyy)))
>>
>> The reason why this happens is because `ignore-errors' is a macro that has
>>
>> (declare (indent defun))
>>
>> Any other macro with the same declaration whose innocent symbol is
>> used as the first element in a list would reproduce the above
>> indentation bug.  Backquote is also affected.
> 
> That's Bug#21922, although the backquoted case is intentional (e.g., for
> writing code in macros).
> 

I use the following trick right now:

(dolist (symbol '(;
                   ignore-errors
                   xxx
                   yyy)))

Since it's impossible to resolve that issue reliably and for all cases 
including backquote, I propose to introduce some special comment (aka 
;###list) format to indicate that this is a list rather than code to be 
evaluated.  In different contexts the same code could be desired to be 
treated differently namely either as data or as to be evaluated.





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

* bug#27646: Bug: Emacs Lisp Indentation
  2020-01-17 20:26         ` bug#21922: " Alexander Shukaev
@ 2022-01-30 22:46           ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-30 22:46 UTC (permalink / raw)
  To: Alexander Shukaev; +Cc: 27646, Noam Postavsky, 21922

Alexander Shukaev <emacs@Alexander.Shukaev.name> writes:

> I use the following trick right now:
>
> (dolist (symbol '(;
>                   ignore-errors
>                   xxx
>                   yyy)))
>
> Since it's impossible to resolve that issue reliably and for all cases
> including backquote, I propose to introduce some special comment (aka
> ;###list) format to indicate that this is a list rather than code to
> be evaluated.  In different contexts the same code could be desired to
> be treated differently namely either as data or as to be evaluated.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

This is bee fixed in recent Emacs version by introducing the following
convention:

(dolist (symbol '( ignore-errors
                   xxx
                   yyy)))

That is, a space after the opening parenthesis to signal that it's a
list and not code.

I'm therefore closing this bug report.

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





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

end of thread, other threads:[~2022-01-30 22:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 20:05 bug#27646: Bug: Emacs Lisp Indentation Alexander Shukaev
2017-07-11  1:05 ` npostavs
2017-11-29  2:26   ` Noam Postavsky
2019-12-19  1:27     ` Alexander Shukaev
2020-01-17 17:58       ` Noam Postavsky
2020-01-17 20:26         ` bug#21922: " Alexander Shukaev
2022-01-30 22:46           ` Lars Ingebrigtsen

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