unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#26642: 25.1; Lisp Mode: open paren at start of line in doc string messes up top level form detection
@ 2017-04-24 18:06 Philipp Matthias Schäfer
  2017-04-25 17:08 ` Glenn Morris
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Matthias Schäfer @ 2017-04-24 18:06 UTC (permalink / raw)
  To: 26642


[-- Attachment #1.1: Type: text/plain, Size: 1734 bytes --]

An open parenthesis in the first column of a line that is fully part of
a string within a top level form, causes the top level form detection to
fail.

As an example, consider

(defun foo ()
  "
(bar)"
)

Invoking EVAL-DEFUN on any point between the first and the last
parenthesis of that example, informs me that BAR has a void function
definition. The example also shows the result of automatic indentation
for new lines, which started the last line in column 0 (instead of
column 2).

There is the simple workaround of escaping the open parenthesis in the
string. `git grep -P "^\\\\\("` shows that this workaround is used all
over the place in the Emacs sources.

I would prefer if I would not need to do that.

Digging into the code, one of the culprits for the EVAL-DEFUN problem
seems to be BEGINNING-OF-DEFUN-RAW, which searches backward from point
for the regexp "^\\s(". So, if I am anywhere after the open parenthesis
before bar, the regexp search finds that parenthesis and stops there.

A test whether the resulting point is within a string or not is missing.
A naive solution for this is to count the unescaped double quotes from
the start of the file, while taking comments into account. This would
also be necessary if no other information is available.

However, I have almost no knowledge of how Emacs works internally, hence
there might be information kept somewhere (for syntax highlighting, for
example), that would make this easier.

Apart from reporting this bug, my question is: Is this something that is
worth pursuing further? Or are there very clear reasons against solving
this problem that are obvious to someone with sufficient experience?

Cheers,

Philipp


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* bug#26642: 25.1; Lisp Mode: open paren at start of line in doc string messes up top level form detection
  2017-04-24 18:06 bug#26642: 25.1; Lisp Mode: open paren at start of line in doc string messes up top level form detection Philipp Matthias Schäfer
@ 2017-04-25 17:08 ` Glenn Morris
  2017-04-25 17:30   ` John Mastro
  0 siblings, 1 reply; 3+ messages in thread
From: Glenn Morris @ 2017-04-25 17:08 UTC (permalink / raw)
  To: Philipp Matthias Schäfer; +Cc: 26642


The is the long-standing "open paren in column zero" issue.
Searching should find several previous discussions.





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

* bug#26642: 25.1; Lisp Mode: open paren at start of line in doc string messes up top level form detection
  2017-04-25 17:08 ` Glenn Morris
@ 2017-04-25 17:30   ` John Mastro
  0 siblings, 0 replies; 3+ messages in thread
From: John Mastro @ 2017-04-25 17:30 UTC (permalink / raw)
  To: Philipp Matthias Schäfer; +Cc: 26642

Glenn Morris <rgm@gnu.org> wrote:
> The is the long-standing "open paren in column zero" issue.
> Searching should find several previous discussions.

You can get the behavior you want by setting the variable
`open-paren-in-column-0-is-defun-start' to nil.

        John





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

end of thread, other threads:[~2017-04-25 17:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-24 18:06 bug#26642: 25.1; Lisp Mode: open paren at start of line in doc string messes up top level form detection Philipp Matthias Schäfer
2017-04-25 17:08 ` Glenn Morris
2017-04-25 17:30   ` John Mastro

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