emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat 041ac359ae 1/2: compat-27: Add minibuffer-histor


From: ELPA Syncer
Subject: [elpa] externals/compat 041ac359ae 1/2: compat-27: Add minibuffer-history-value
Date: Fri, 20 Jan 2023 10:57:27 -0500 (EST)

branch: externals/compat
commit 041ac359aea6083d3aa236d759ed41292ee10079
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    compat-27: Add minibuffer-history-value
---
 NEWS.org        |  1 +
 compat-27.el    | 10 +++++++++-
 compat-tests.el | 15 +++++++++++++++
 compat.texi     |  8 ++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/NEWS.org b/NEWS.org
index 5b9b3efad3..aff8a96c8c 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -7,6 +7,7 @@
 - compat-27: Add ~date-ordinal-to-time~.
 - compat-27: Add ~make-decoded-time~.
 - compat-27: Add ~ring-resize~.
+- compat-27: Add ~minibuffer-history-value~.
 - compat-28: Add ~color-dark-p~.
 - compat-28: Add ~with-window-non-dedicated~.
 - compat-28: Add ~directory-files-and-attributes~ with COUNT argument.
diff --git a/compat-27.el b/compat-27.el
index 16a6b124cd..672a1d0f8e 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -307,6 +307,14 @@ Also see `decoded-time-dst'.")
 This is an integer indicating the UTC offset in seconds, i.e.,
 the number of seconds east of Greenwich.")))
 
+(compat-defun minibuffer-history-value () ;; 
<compat-tests:minibuffer-history-value>
+  "Return the value of the minibuffer input history list.
+If `minibuffer-history-variable' points to a buffer-local variable and
+the minibuffer is active, return the buffer-local value for the buffer
+that was current when the minibuffer was activated."
+  (buffer-local-value minibuffer-history-variable
+                      (window-buffer (minibuffer-selected-window))))
+
 ;;;; Defined in minibuffer.el
 
 (compat-defmacro with-minibuffer-selected-window (&rest body) ;; 
<compat-tests:with-minibuffer-selected-window>
@@ -716,7 +724,7 @@ and if a matching region is found, place point at the start 
of the region."
 
 ;;;; Defined in ring.el
 
-(compat-defun ring-resize (ring size)
+(compat-defun ring-resize (ring size) ;; <compat-tests:ring-resize>
   "Set the size of RING to SIZE.
 If the new size is smaller, then the oldest items in the ring are
 discarded."
diff --git a/compat-tests.el b/compat-tests.el
index add4f32a79..8a2e9802da 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -153,6 +153,21 @@
        (push x y))
      '(3 2 1))))
 
+(ert-deftest minibuffer-history-value ()
+  (let ((minibuffer-history-variable 'file-name-history)
+        (file-name-history '("a" "b" "c")))
+    (should-equal (minibuffer-history-value) '("a" "b" "c")))
+  (let ((file-name-history '("x" "y" "z")))
+    (should-equal
+     (catch 'compat-tests--exit
+       (minibuffer-with-setup-hook
+           (lambda ()
+             (message "%S" minibuffer-history-variable)
+             (throw 'compat-tests--exit (minibuffer-history-value)))
+         (let ((executing-kbd-macro t))
+           (completing-read "Prompt: " #'completion-file-name-table nil nil 
nil 'file-name-history))))
+     '("x" "y" "z"))))
+
 (ert-deftest with-minibuffer-selected-window ()
   (let (ran)
     (should-not (minibuffer-selected-window))
diff --git a/compat.texi b/compat.texi
index 9668e04ec6..4f6a6060cf 100644
--- a/compat.texi
+++ b/compat.texi
@@ -899,6 +899,14 @@ Set the size of @var{ring} to @var{size}.  If the new size 
is smaller,
 then the oldest items in the ring are discarded.
 @end defun
 
+@c based on lisp/simple.el
+@defun minibuffer-history-value
+Return the value of the minibuffer input history list.  If
+@var{minibuffer-history-variable} points to a buffer-local variable
+and the minibuffer is active, return the buffer-local value for the
+buffer that was current when the minibuffer was activated."
+@end defun
+
 @c based on lisp/minibuffer.el
 @defmac with-minibuffer-selected-window &rest body
 Execute the forms in @var{body} from the minibuffer in its original



reply via email to

[Prev in Thread] Current Thread [Next in Thread]