* Re: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed [not found] <E1U7sgy-00020G-Up@vcs.savannah.gnu.org> @ 2013-02-19 21:37 ` Stefan Monnier 2013-02-20 5:24 ` Fabián Ezequiel Gallina 0 siblings, 1 reply; 4+ messages in thread From: Stefan Monnier @ 2013-02-19 21:37 UTC (permalink / raw To: Fabián Ezequiel Gallina; +Cc: emacs-devel > - (python-nav-end-of-defun) > + (save-match-data > + ;; FIXME: avoid cluttering match-data > + ;; where's not wanted. > + (python-nav-end-of-defun)) > (+ (point) > (if (>= (current-indentation) min-indent) > (1+ (current-indentation)) I suspect this is not The Right Place for the save-match-data, since we should not assume that current-indentation won't also mess up the match-data. Stefan ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed 2013-02-19 21:37 ` [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed Stefan Monnier @ 2013-02-20 5:24 ` Fabián Ezequiel Gallina 2013-02-20 14:01 ` Stefan Monnier 0 siblings, 1 reply; 4+ messages in thread From: Fabián Ezequiel Gallina @ 2013-02-20 5:24 UTC (permalink / raw To: Stefan Monnier; +Cc: emacs-devel On 02/19/2013 06:37 PM, Stefan Monnier wrote: >> - (python-nav-end-of-defun) >> + (save-match-data >> + ;; FIXME: avoid cluttering match-data >> + ;; where's not wanted. >> + (python-nav-end-of-defun)) >> (+ (point) >> (if (>= (current-indentation) min-indent) >> (1+ (current-indentation)) > I suspect this is not The Right Place for the save-match-data, since we > should not assume that current-indentation won't also mess up the > match-data. > > > Stefan FWIW this very small change corrected the python-info-current-defun behavior and was able to pass the test suite I've been working on. So far my local test/automated/python-tests.el is covering indentation, movement and python-info-* functions completely. Would it be OK to introduce these tests into the emacs-24 branch? Now, I certainly wasn't expecting current-indentation could change match-data (could it?). If so, I feel that functions not expected[0] to mess with match-data should at least document it. In this regard, I have a change in the works that will cause python.el to stop messing with match-data so much (use of looking-at-p instead of looking-at and such), and document those functions that are intended to. If everyone agrees I could get this to the emacs-24 branch. [0] By "functions not expected[0] to mess with match-data" I mean functions that are not receiving a regexp as argument. Regards, Fabián ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed 2013-02-20 5:24 ` Fabián Ezequiel Gallina @ 2013-02-20 14:01 ` Stefan Monnier 2013-02-20 20:54 ` Fabián Ezequiel Gallina 0 siblings, 1 reply; 4+ messages in thread From: Stefan Monnier @ 2013-02-20 14:01 UTC (permalink / raw To: Fabián Ezequiel Gallina; +Cc: emacs-devel >> I suspect this is not The Right Place for the save-match-data, since we >> should not assume that current-indentation won't also mess up the >> match-data. > FWIW this very small change corrected the python-info-current-defun behavior > and was able to pass the test suite I've been working on. I don't doubt it works, I'm just pointing out that it would be better to place the save-match-data elsewhere. The general rule is: put the save-match-data between the "match" and the corresponding "get match-data" rather than around some code that might modify the match-data. > So far my local test/automated/python-tests.el is covering > indentation, movement and python-info-* functions completely. Would it > be OK to introduce these tests into the emacs-24 branch? Yes, it's OK to add files to emacs-24/test/... > Now, I certainly wasn't expecting current-indentation could change > match-data (could it?). All functions can do it, except for those where it's blatantly obvious they can't (e.g. `car', `cdr', `match-beginning'). And yes, current-indentation probably can in sufficiently weird cases. > If so, I feel that functions not expected[0] to mess > with match-data should at least document it. We should indeed document the small set of functions which are guaranteed not to mess the match-data. > In this regard, I have a change in the works that will cause python.el to > stop messing with match-data so much (use of looking-at-p instead of > looking-at and such), and document those functions that are intended to. > If everyone agrees I could get this to the emacs-24 branch. I generally recommend not to go down that route. Instead, just make sure all the match-{beginning/end/string} calls come right after the corresponding search, and if not, place a save-match-data around the intermediate code. Stefan ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed 2013-02-20 14:01 ` Stefan Monnier @ 2013-02-20 20:54 ` Fabián Ezequiel Gallina 0 siblings, 0 replies; 4+ messages in thread From: Fabián Ezequiel Gallina @ 2013-02-20 20:54 UTC (permalink / raw To: Stefan Monnier; +Cc: emacs-devel On 02/20/2013 11:01 AM, Stefan Monnier wrote: >> FWIW this very small change corrected the python-info-current-defun behavior >> and was able to pass the test suite I've been working on. > I don't doubt it works, I'm just pointing out that it would be better to > place the save-match-data elsewhere. The general rule is: put the > save-match-data between the "match" and the corresponding "get > match-data" rather than around some code that might modify the match-data. Thanks for the clarification, I pushed a change for this in revno 111284. >> So far my local test/automated/python-tests.el is covering >> indentation, movement and python-info-* functions completely. Would it >> be OK to introduce these tests into the emacs-24 branch? > Yes, it's OK to add files to emacs-24/test/... Pushed in revno 111283. >> In this regard, I have a change in the works that will cause python.el to >> stop messing with match-data so much (use of looking-at-p instead of >> looking-at and such), and document those functions that are intended to. >> If everyone agrees I could get this to the emacs-24 branch. > I generally recommend not to go down that route. Instead, just make sure > all the match-{beginning/end/string} calls come right after the > corresponding search, and if not, place a save-match-data around the > intermediate code. That's good, I will not get picky about match-data modification. In any case these replacements of looking-at and string-match are part of a set of good and fairly cheap refactors (partially based on https://github.com/fgallina/python.el/pull/121). Thanks, Fabián ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-02-20 20:54 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <E1U7sgy-00020G-Up@vcs.savannah.gnu.org> 2013-02-19 21:37 ` [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111281: * progmodes/python.el (python-info-current-defun): Fix failed Stefan Monnier 2013-02-20 5:24 ` Fabián Ezequiel Gallina 2013-02-20 14:01 ` Stefan Monnier 2013-02-20 20:54 ` Fabián Ezequiel Gallina
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.