[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 28a1e8e377 36/77: compat-30: Add find-buffer and
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 28a1e8e377 36/77: compat-30: Add find-buffer and get-truename-buffer |
Date: |
Mon, 24 Jun 2024 12:58:55 -0400 (EDT) |
branch: externals/compat
commit 28a1e8e377fb2884c7dbc564f6fed1e65a33f8ba
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
compat-30: Add find-buffer and get-truename-buffer
---
NEWS.org | 1 +
compat-30.el | 15 +++++++++++++++
compat-tests.el | 27 +++++++++++++++++++++++++++
compat.texi | 11 +++++++++++
4 files changed, 54 insertions(+)
diff --git a/NEWS.org b/NEWS.org
index 043d45ac15..b081c4c3e6 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -11,6 +11,7 @@
- compat-30: New variables =completion-lazy-hilit= and
=completion-lazy-hilit-fn=
and new function =completion-lazy-hilit=.
- compat-30: New function =require-with-check=.
+- compat-30: New functions =find-buffer= and =get-truename-buffer=.
* Release of "Compat" Version 29.1.4.4
diff --git a/compat-30.el b/compat-30.el
index 36e6a19d02..b68cc407e2 100644
--- a/compat-30.el
+++ b/compat-30.el
@@ -27,6 +27,21 @@
;; TODO Update to 30.1 as soon as the Emacs emacs-30 branch version bumped
(compat-version "30.0.50")
+;;;; Defined in buffer.c
+
+(compat-defun find-buffer (variable value) ;; <compat-tests:find-buffer>
+ "Return the buffer with buffer-local VARIABLE equal to VALUE.
+If there is no such live buffer, return nil."
+ (cl-loop for buffer the buffers
+ if (equal (buffer-local-value variable buffer) value)
+ return buffer))
+
+(compat-defun get-truename-buffer (filename) ;;
<compat-tests:get-truename-buffer>
+ "Return the buffer with `file-truename' equal to FILENAME (a string).
+If there is no such live buffer, return nil.
+See also `find-buffer-visiting'."
+ (find-buffer 'buffer-file-truename filename))
+
;;;; Defined in files.el
(compat-defun require-with-check (feature &optional filename noerror) ;;
<compat-tests:require-with-check>
diff --git a/compat-tests.el b/compat-tests.el
index 12e52ea370..88992f690a 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -3084,5 +3084,32 @@
(should-equal 'compat-reload (require-with-check 'compat-reload nil
'noerror))
(should-equal 'compat-reload (require-with-check 'compat-reload nil
'reload)))))))
+(defvar compat-tests-find-buffer nil)
+(ert-deftest compat-find-buffer ()
+ ;; TODO enable test on Emacs 30 as soon as the CI supports it.
+ (static-if (< emacs-major-version 30)
+ (let ((buf1 (get-buffer-create "*compat-tests-buf1*"))
+ (buf2 (get-buffer-create "*compat-tests-buf2*")))
+ (with-current-buffer buf1
+ (setq-local compat-tests-find-buffer 1))
+ (with-current-buffer buf2
+ (setq-local compat-tests-find-buffer 2))
+ (should-equal buf1 (find-buffer 'compat-tests-find-buffer 1))
+ (should-equal buf2 (find-buffer 'compat-tests-find-buffer 2))
+ (should-not (find-buffer 'compat-tests-find-buffer 3)))))
+
+(ert-deftest compat-get-truename-buffer ()
+ ;; TODO enable test on Emacs 30 as soon as the CI supports it.
+ (static-if (< emacs-major-version 30)
+ (let ((buf1 (get-buffer-create "*compat-tests-buf1*"))
+ (buf2 (get-buffer-create "*compat-tests-buf2*")))
+ (with-current-buffer buf1
+ (setq-local buffer-file-truename "compat-tests-file1"))
+ (with-current-buffer buf2
+ (setq-local buffer-file-truename "compat-tests-file2"))
+ (should-equal buf1 (get-truename-buffer "compat-tests-file1"))
+ (should-equal buf2 (get-truename-buffer "compat-tests-file2"))
+ (should-not (get-truename-buffer "compat-tests-file3")))))
+
(provide 'compat-tests)
;;; compat-tests.el ends here
diff --git a/compat.texi b/compat.texi
index 95c9257b79..696418b08a 100644
--- a/compat.texi
+++ b/compat.texi
@@ -3348,6 +3348,17 @@ older than 30.1. Note that due to upstream changes, it
might happen
that there will be the need for changes, so use these functions with
care.
+@defun get-truename-buffer filename
+Return the buffer with @code{file-truename} equal to @var{filename} (a string).
+If there is no such live buffer, return nil.
+See also @code{find-buffer-visiting}.
+@end defun
+
+@defun find-buffer variable value
+Return the buffer with buffer-local @var{variable} equal to @var{value}.
+If there is no such live buffer, return nil.
+@end defun
+
@c copied from lispref/loading.texi
@defun require-with-check feature &optional filename noerror
This function works like @code{require}, except if @var{feature} is
- [elpa] externals/compat 2cf02d0f89 03/77: compat-30.el: Fix compat-require, since Emacs 29.1 is not yet released, (continued)
- [elpa] externals/compat 2cf02d0f89 03/77: compat-30.el: Fix compat-require, since Emacs 29.1 is not yet released, ELPA Syncer, 2024/06/24
- [elpa] externals/compat e2d66a8816 09/77: compat-defun: Add :min-version argument, ELPA Syncer, 2024/06/24
- [elpa] externals/compat abe97399f8 12/77: compat-30: Add static-if, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 8f1c84745f 14/77: compat-tests: Use static-if, ELPA Syncer, 2024/06/24
- [elpa] externals/compat bc22c48cf9 18/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 1bcce2dfd4 19/77: compat.texi: Fix typos, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 2a140e3563 22/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 4884caa838 21/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 9824972bfd 26/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat d4231e73e0 29/77: compat-tests: Enable merge-ordered-lists test on Emacs 30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 28a1e8e377 36/77: compat-30: Add find-buffer and get-truename-buffer,
ELPA Syncer <=
- [elpa] externals/compat ab3fbaf31f 38/77: compat-30: Add extended completion-metadata-get, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 3e718596ac 50/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 89d77c8fe4 53/77: compat-tests.el: Enable sort-on test, ELPA Syncer, 2024/06/24
- [elpa] externals/compat f8a73191c6 52/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 8190769d9e 61/77: compat-30: Add value< and sort with keyword arguments, ELPA Syncer, 2024/06/24
- [elpa] externals/compat ea96659971 75/77: compat-28: Fix links to tests, ELPA Syncer, 2024/06/24
- [elpa] externals/compat ab39edfb3b 08/77: compat.texi: Add missing compat-call, ELPA Syncer, 2024/06/24
- [elpa] externals/compat bf4b9aaa2e 11/77: Merge branch 'master' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat 2cc2454fae 17/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24
- [elpa] externals/compat bd35d89543 16/77: Merge branch 'main' into emacs-30, ELPA Syncer, 2024/06/24