* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior [not found] ` <E1YpLPp-0000IV-4c@vcs.savannah.gnu.org> @ 2015-05-04 22:16 ` Stefan Monnier 2015-05-04 22:37 ` Daniel Colascione 2015-05-04 23:02 ` Nicolas Petton 0 siblings, 2 replies; 9+ messages in thread From: Stefan Monnier @ 2015-05-04 22:16 UTC (permalink / raw To: emacs-devel; +Cc: Daniel Colascione > + (let ((mark (mark-marker))) > + (and mark (marker-position mark) (copy-marker mark))) Here you consider that (mark-marker) can return nil. > +(defun save-mark-and-excursion--restore (saved-mark-info) > + (let ((saved-mark (car saved-mark-info)) > + (omark (marker-position (mark-marker))) But here you assume it's always a marker. > + (setf nmark (marker-position saved-mark)) ^^^^ Old habits die hard. > + (let ((cur-mark-active mark-active)) > + (setf mark-active saved-mark-active) > + ;; If mark is active now, and either was not active or was at a > + ;; different place, run the activate hook. > + (if saved-mark-active > + (unless (eq omark nmark) > + (run-hooks 'activate-mark-hook)) IIUC activate-mark-hook should also be run when (eq omark nmark) but cur-mark-active was nil. Stefan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-04 22:16 ` [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior Stefan Monnier @ 2015-05-04 22:37 ` Daniel Colascione 2015-05-05 17:48 ` Stefan Monnier 2015-05-04 23:02 ` Nicolas Petton 1 sibling, 1 reply; 9+ messages in thread From: Daniel Colascione @ 2015-05-04 22:37 UTC (permalink / raw To: Stefan Monnier, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1635 bytes --] On 05/04/2015 03:16 PM, Stefan Monnier wrote: >> + (let ((mark (mark-marker))) >> + (and mark (marker-position mark) (copy-marker mark))) > > Here you consider that (mark-marker) can return nil. > >> +(defun save-mark-and-excursion--restore (saved-mark-info) >> + (let ((saved-mark (car saved-mark-info)) >> + (omark (marker-position (mark-marker))) > > But here you assume it's always a marker. It is always a marker, isn't it? Some other parts of simple.el assume it always returns non-nil. I'll remove the nil check. >> + (let ((cur-mark-active mark-active)) >> + (setf mark-active saved-mark-active) >> + ;; If mark is active now, and either was not active or was at a >> + ;; different place, run the activate hook. >> + (if saved-mark-active >> + (unless (eq omark nmark) >> + (run-hooks 'activate-mark-hook)) > > IIUC activate-mark-hook should also be run when (eq omark nmark) but > cur-mark-active was nil. Huh. I just mechanically translated the original save-excursion C code. Doesn't that code have the same mismatch between the comment and the behavior? /* If mark is active now, and either was not active or was at a different place, run the activate hook. */ tem = XSAVE_OBJECT (info, 3); // saved-mark-active ... if (! NILP (tem)) { if (! EQ (omark, nmark)) run_hook (intern ("activate-mark-hook")); } /* If mark has ceased to be active, run deactivate hook. */ else if (! NILP (tem1)) run_hook (intern ("deactivate-mark-hook")); I'll change the code to match the comment. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-04 22:37 ` Daniel Colascione @ 2015-05-05 17:48 ` Stefan Monnier 0 siblings, 0 replies; 9+ messages in thread From: Stefan Monnier @ 2015-05-05 17:48 UTC (permalink / raw To: Daniel Colascione; +Cc: emacs-devel > It is always a marker, isn't it? I think so, yes. > Some other parts of simple.el assume it always returns non-nil. > I'll remove the nil check. Good, thanks. >> IIUC activate-mark-hook should also be run when (eq omark nmark) but >> cur-mark-active was nil. > Huh. I just mechanically translated the original save-excursion C code. Ah, you're probably right: the save-excursion code had such kinds of problems. > I'll change the code to match the comment. Thanks, Stefan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-04 22:16 ` [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior Stefan Monnier 2015-05-04 22:37 ` Daniel Colascione @ 2015-05-04 23:02 ` Nicolas Petton 2015-05-04 23:04 ` Daniel Colascione 2015-05-05 17:50 ` Stefan Monnier 1 sibling, 2 replies; 9+ messages in thread From: Nicolas Petton @ 2015-05-04 23:02 UTC (permalink / raw To: Stefan Monnier; +Cc: Daniel Colascione, emacs-devel [-- Attachment #1: Type: text/plain, Size: 261 bytes --] Stefan Monnier writes: >> + (setf nmark (marker-position saved-mark)) > ^^^^ > Old habits die hard. Should `setf' be avoided? Is it only when `setq' would do instead? Nico, confused -- Nicolas Petton http://nicolas-petton.fr [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 512 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-04 23:02 ` Nicolas Petton @ 2015-05-04 23:04 ` Daniel Colascione 2015-05-05 17:50 ` Stefan Monnier 1 sibling, 0 replies; 9+ messages in thread From: Daniel Colascione @ 2015-05-04 23:04 UTC (permalink / raw To: Nicolas Petton, Stefan Monnier; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 392 bytes --] On 05/04/2015 04:02 PM, Nicolas Petton wrote: > > Stefan Monnier writes: > >>> + (setf nmark (marker-position saved-mark)) >> ^^^^ >> Old habits die hard. > > Should `setf' be avoided? Is it only when `setq' would do instead? I'm guessing Stefan doesn't want loading simple.el (in the case where it's not already compiled) to force the autoloading of gv.el. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-04 23:02 ` Nicolas Petton 2015-05-04 23:04 ` Daniel Colascione @ 2015-05-05 17:50 ` Stefan Monnier 2015-05-05 18:04 ` Daniel Colascione 2015-05-05 18:31 ` Nicolas Petton 1 sibling, 2 replies; 9+ messages in thread From: Stefan Monnier @ 2015-05-05 17:50 UTC (permalink / raw To: Nicolas Petton; +Cc: Daniel Colascione, emacs-devel >>> + (setf nmark (marker-position saved-mark)) >> ^^^^ >> Old habits die hard. > Should `setf' be avoided? Is it only when `setq' would do instead? Sorry, I guess `setf' work as well, here. I've just been bitten by bootstrapping problems too many times, but simple.el should be late enough that it can't be a problem. Stefan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-05 17:50 ` Stefan Monnier @ 2015-05-05 18:04 ` Daniel Colascione 2015-05-05 19:00 ` Stefan Monnier 2015-05-05 18:31 ` Nicolas Petton 1 sibling, 1 reply; 9+ messages in thread From: Daniel Colascione @ 2015-05-05 18:04 UTC (permalink / raw To: Stefan Monnier, Nicolas Petton; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 540 bytes --] On 05/05/2015 10:50 AM, Stefan Monnier wrote: >>>> + (setf nmark (marker-position saved-mark)) >>> ^^^^ >>> Old habits die hard. >> Should `setf' be avoided? Is it only when `setq' would do instead? > > Sorry, I guess `setf' work as well, here. I've just been bitten by > bootstrapping problems too many times, but simple.el should be late > enough that it can't be a problem. There ought to be a file-local variable marking early-loadup files that tells the compiler to warn about certain otherwise-safe facilities. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-05 18:04 ` Daniel Colascione @ 2015-05-05 19:00 ` Stefan Monnier 0 siblings, 0 replies; 9+ messages in thread From: Stefan Monnier @ 2015-05-05 19:00 UTC (permalink / raw To: Daniel Colascione; +Cc: Nicolas Petton, emacs-devel > There ought to be a file-local variable marking early-loadup files that > tells the compiler to warn about certain otherwise-safe facilities. IWBNI, but at the same time, it's pretty difficult to clearly characterize that which is safe and that which isn't (and our bootstrap is pretty close to the edge at various places, so the details do matter). I'm not sure it's really worth investing much effort into it. Stefan "who'd rather aim for a different bootstrap method to get rid of the prooblem" ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior 2015-05-05 17:50 ` Stefan Monnier 2015-05-05 18:04 ` Daniel Colascione @ 2015-05-05 18:31 ` Nicolas Petton 1 sibling, 0 replies; 9+ messages in thread From: Nicolas Petton @ 2015-05-05 18:31 UTC (permalink / raw To: Stefan Monnier; +Cc: Nicolas Petton, Daniel Colascione, emacs-devel [-- Attachment #1: Type: text/plain, Size: 466 bytes --] Stefan Monnier writes: >>>> + (setf nmark (marker-position saved-mark)) >>> ^^^^ >>> Old habits die hard. >> Should `setf' be avoided? Is it only when `setq' would do instead? > > Sorry, I guess `setf' work as well, here. I've just been bitten by > bootstrapping problems too many times, but simple.el should be late > enough that it can't be a problem. Ok, thanks for the clarification. Nico -- Nicolas Petton http://nicolas-petton.fr [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 512 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-05-05 19:00 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20150504184829.1108.13525@vcs.savannah.gnu.org> [not found] ` <E1YpLPp-0000IV-4c@vcs.savannah.gnu.org> 2015-05-04 22:16 ` [Emacs-diffs] master 255a011: Add `save-mark-and-excursion', which has the old `save-excursion' behavior Stefan Monnier 2015-05-04 22:37 ` Daniel Colascione 2015-05-05 17:48 ` Stefan Monnier 2015-05-04 23:02 ` Nicolas Petton 2015-05-04 23:04 ` Daniel Colascione 2015-05-05 17:50 ` Stefan Monnier 2015-05-05 18:04 ` Daniel Colascione 2015-05-05 19:00 ` Stefan Monnier 2015-05-05 18:31 ` Nicolas Petton
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.