unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Eli Zaretskii <eliz@gnu.org>
Cc: rfflrccrd@gmail.com, 21072@debbugs.gnu.org
Subject: bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp
Date: Thu, 09 Jun 2016 13:56:25 +0200	[thread overview]
Message-ID: <8737omh8yk.fsf@amu.edu.pl> (raw)
In-Reply-To: <87y46kb11o.fsf@mbork.pl>

Hi everyone,

it's me again.

I looked at the tests of `mark-defun' for Python, and they did shed some
light on the weird implementation.  In short, `mark-defun' first jumps
to the beginning and the to the end of the current defun, checks whether
the point is now before or after the initial position, and if before,
back up and jump to the end first and to the beginning next.  This might
actually happen, since e.g. in Python, when point is on a "def"
beginning a function definition, `beginning-of-defun' goes to the start
of the _preceding_ defun.  In fact, I think this is a bug in
beginning-of-defun (or more precisely, its Python version), and
consequently I think the weird code in `mark-defun' is a workaround for
a deeper bug.

I can now do one of a few things.  (Not ATM, I'll have to take my time.)

1. Fix the docs so that #21072 is no longer a bug (i.e., change the docs
so that there's no discrepancy between them and code).

2a. Just fix the problem reported in #21072, hoping that it doesn't break
anything else.

2b. Write a few tests for `mark-defun',_then_ fix the problem, and check
whether these tests pass.  Of course, all these tests would be for Elisp
(and maybe for C and/or JavaScript).

3. Try to come up with a better `mark-defun', still given the
limitations of `beginning-of-defun', e.g., make `mark-defun' use the
numeric prefix argument in a reasonable way (i.e., what Drew proposed).

4. Report a bug in `beginning-of-defun', and hope someone (probably not
me, I do not know enough about ppss now and do not have time to learn
that now), and then write a simpler `mark-defun' from scratch.

WDYT?

Best,
Marcin



On 2016-06-05, at 08:30, Marcin Borkowski <mbork@mbork.pl> wrote:

> On 2016-05-07, at 08:47, Eli Zaretskii <eliz@gnu.org> wrote:
>
>>> From: Marcin Borkowski <mbork@mbork.pl>
>>> Cc: rfflrccrd@gmail.com, 21072@debbugs.gnu.org
>>> Date: Sat, 07 May 2016 05:47:18 +0200
>>> 
>>> I'm not sure what to do next with this bug.  I tried with the
>>> abovementioned short Elisp file and failed.  Since no-one said that the
>>> current behavior is wrong, maybe I'll try to study the code of
>>> `mark-defun' and modify the docstring/manual accordingly.
>>
>> I'd suggest to change the doc string according to what I recommended a
>> few messages ago.  I think that would be good enough.
>
> Hi Eli, hi all,
>
> and sorry for replying after such a long time (again) - I'm afraid
> I cannot help this, my time has become extremely limited recently.
>
> I studied the code of mark-defun, and it seems that the reason for
> #21072 is quite simple.  I enclose a patch where the two (seemingly)
> offending lines are commented; if this is acceptable, of course I'll
> prepare a proper patch.  (And while at that, I'll propose replacing
> `(and transient-mark-mode mark-active)' with `(use-region-p)'.)
>
> The problem is, I'm not sure whether this change won't break anything.
> The only tests I found that deal with `mark-defun' are in
> python-tests.el, and my version passes all three of them.
>
>> Thanks.
>
> Best,


-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University





  parent reply	other threads:[~2016-06-09 11:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16  6:12 bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp Raffaele Ricciardi
2016-04-25 11:11 ` Marcin Borkowski
2016-05-01 17:17   ` Eli Zaretskii
2016-05-01 17:49     ` Marcin Borkowski
2016-05-01 18:09       ` Eli Zaretskii
2016-05-01 19:45         ` Marcin Borkowski
2016-05-01 19:56           ` Eli Zaretskii
2016-05-03 18:58             ` Marcin Borkowski
2016-05-04 14:45               ` Eli Zaretskii
2016-05-06 12:27                 ` Marcin Borkowski
2016-05-06 12:59                   ` Eli Zaretskii
2016-05-07  3:47                     ` Marcin Borkowski
2016-05-07  5:07                       ` Drew Adams
2016-10-11 12:31                         ` Marcin Borkowski
2016-10-11 15:30                           ` Drew Adams
2016-10-11 17:07                             ` Marcin Borkowski
2016-10-11 17:52                               ` Clément Pit--Claudel
2016-10-11 20:26                               ` Drew Adams
2016-10-11 21:15                               ` Drew Adams
2016-10-28  5:35                                 ` Marcin Borkowski
2016-10-28 14:32                                   ` Drew Adams
2016-11-02  7:28                                 ` Marcin Borkowski
2016-11-02 18:25                                   ` Drew Adams
2016-11-04  7:48                                     ` Marcin Borkowski
2016-11-27  7:40                                       ` Marcin Borkowski
2016-11-27 18:51                                         ` Drew Adams
2017-02-07  6:22                                           ` Marcin Borkowski
2017-02-07 16:14                                             ` Drew Adams
2016-05-07  6:47                       ` Eli Zaretskii
2016-06-05  6:30                         ` Marcin Borkowski
2016-06-05  7:01                           ` bug#21072: Forgotten attachment (was: bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp) Marcin Borkowski
2016-06-09 11:56                           ` Marcin Borkowski [this message]
2016-06-21  7:58                             ` bug#21072: 24.5; inconsistent behaviour of `C-M-h (mark-defun)' in Emacs Lisp Marcin Borkowski
2016-06-21  9:05                               ` Andreas Röhler
2016-06-21 10:07                                 ` Marcin Borkowski

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=8737omh8yk.fsf@amu.edu.pl \
    --to=mbork@mbork.pl \
    --cc=21072@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rfflrccrd@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).