[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/m-buffer 3702262fbc 092/115: m-buffer was not stateless
From: |
ELPA Syncer |
Subject: |
[elpa] externals/m-buffer 3702262fbc 092/115: m-buffer was not stateless at all! |
Date: |
Tue, 19 Jul 2022 15:58:51 -0400 (EDT) |
branch: externals/m-buffer
commit 3702262fbc7b4eaa625f99162eba8c46fb612c74
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
m-buffer was not stateless at all!
A bug in m-buffer-match meant that the m-buffer-match-* functions was
not at all stateless. The bug was caused because m-buffer-match saved
all the various states before setting the current buffer.
---
m-buffer.el | 12 ++++++------
test/m-buffer-test.el | 26 ++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/m-buffer.el b/m-buffer.el
index dadd538c23..769e4e30b3 100644
--- a/m-buffer.el
+++ b/m-buffer.el
@@ -11,7 +11,7 @@
;; The contents of this file are subject to the GPL License, Version 3.0.
-;; Copyright (C) 2014, Phillip Lord, Newcastle University
+;; Copyright (C) 2014, 2015, Phillip Lord, Newcastle University
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -139,11 +139,11 @@ NUMERIC -- Non-nil if we should return integers not
markers."
;; this is all the global state that exists and that we are changing.
;; #+begin_src emacs-lisp
- (save-match-data
- (save-excursion
- (save-restriction
- (with-current-buffer
- buffer
+ (with-current-buffer
+ buffer
+ (save-match-data
+ (save-excursion
+ (save-restriction
(when widen (widen))
;; #+end_src
diff --git a/test/m-buffer-test.el b/test/m-buffer-test.el
index afe828374b..029f5a1c51 100644
--- a/test/m-buffer-test.el
+++ b/test/m-buffer-test.el
@@ -421,4 +421,30 @@ should not have moved."
))))
+(ert-deftest point-stationionary-with-current ()
+ "This test addresses a bug where m-buffer did not correctly
+protect global state when the buffer being operated on was not
+current -- in this case, a match could move point.
+
+The two clauses are identical, one changing the current buffer
+and one changing a buffer which is not current."
+ (should
+ (let ((out) (out-point))
+ (with-temp-buffer
+ (insert "one\ntwo\nthree\n")
+ (setq out (current-buffer))
+ (setq out-point (point))
+ (m-buffer-match-first-line out)
+ (= (point) out-point))))
+
+ (should
+ (let ((out) (out-point))
+ (with-temp-buffer
+ (insert "one\ntwo\nthree\n")
+ (setq out (current-buffer))
+ (setq out-point (point))
+ (with-temp-buffer
+ (m-buffer-match-first-line out))
+ (= (point) out-point)))))
+
;;; m-buffer-test.el ends here
- [elpa] externals/m-buffer 3df675024f 064/115: New functions added., (continued)
- [elpa] externals/m-buffer 3df675024f 064/115: New functions added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 69cf1fb326 066/115: Documentation updates., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer e80fd6cdaa 068/115: Documentation updates., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer e9f9b0819f 072/115: Prepare for next iteration!, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 8c7f63ee16 073/115: Removed pointless call to m-buffer-buffer-for-match., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 77067c0ff5 076/115: Version 0.9 Released., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3136ab48a8 082/115: Docstring typo., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer c0946dbe6c 085/115: Documentations updates., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer ea281db21a 089/115: New function: m-buffer-partition-by-marker., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3fd8848e40 091/115: m-buffer-at-narrowed-p added., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3702262fbc 092/115: m-buffer was not stateless at all!,
ELPA Syncer <=
- [elpa] externals/m-buffer 1f9cb91594 095/115: Generic language., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3325bfcf6e 098/115: Prepare for next release., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 62751a56db 099/115: Fix hyperlink in travis-ci build., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 1ff021c5f6 100/115: v0.13 release., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 2a056e6248 104/115: seq replaces the dependency on dash., ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 61d1ed99e5 103/115: Update email, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 1da2438bfb 105/115: Lentic doc update and generation, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 9c45387989 107/115: Update Cask file for lentic-doc changes, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer 3bff1078c6 109/115: Add package task to Makefile, ELPA Syncer, 2022/07/19
- [elpa] externals/m-buffer a2b935896f 111/115: Support Emacs-24 series, ELPA Syncer, 2022/07/19