[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 41ec1d79602 2/4: Merge branch 'master' of git.sv.gnu.org:/srv/git
From: |
Michael Albinus |
Subject: |
master 41ec1d79602 2/4: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs |
Date: |
Mon, 13 May 2024 03:24:20 -0400 (EDT) |
branch: master
commit 41ec1d79602f9d1cadc543ccc4aff2f907d9cde3
Merge: e53e8b4cf44 f560e759338
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
build-aux/makecounter.sh | 1 +
etc/NEWS | 5 ++++
lisp/progmodes/project.el | 8 +++---
lisp/progmodes/ruby-mode.el | 26 ++++++++++++++++----
lisp/progmodes/xref.el | 47 +++++++++++++++++++++++-------------
src/android.c | 2 +-
src/androidfont.c | 10 ++++----
src/androidterm.c | 2 --
src/androidterm.h | 1 +
src/epaths.in | 3 ++-
test/lisp/progmodes/project-tests.el | 29 ++++++++++++++++++++++
11 files changed, 100 insertions(+), 34 deletions(-)
diff --git a/build-aux/makecounter.sh b/build-aux/makecounter.sh
index a63fcbb7c61..4d572d5ab80 100755
--- a/build-aux/makecounter.sh
+++ b/build-aux/makecounter.sh
@@ -36,6 +36,7 @@ cat > $1 <<EOF
#define EXPORT __attribute__ ((visibility ("default")))
#endif /* HAVE_ANDROID */
+extern int emacs_shortlisp_counter;
#ifdef EXPORT
EXPORT
#endif /* EXPORT */
diff --git a/etc/NEWS b/etc/NEWS
index cb7c62a7876..4f2c59a1300 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1708,6 +1708,11 @@ options of GNU 'ls'.
If non-nil, moving point forward or backward between widgets by typing
'TAB' or 'S-TAB' skips over inactive widgets. The default value is nil.
+** Ruby mode
+New user option 'ruby-rubocop-use-bundler'. By default it retains the
+previous behavior: read the contens of Gemfile and act accordingly. But
+you can also set it to t or nil to skip the check.
+
** Miscellaneous
---
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 52fe4df9080..a95d1267dd2 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -347,7 +347,8 @@ to find the list of ignores for each directory."
(defun project--files-in-directory (dir ignores &optional files)
(require 'find-dired)
(require 'xref)
- (let* ((default-directory dir)
+ (let* ((dir (file-name-as-directory dir))
+ (default-directory dir)
;; Make sure ~/ etc. in local directory name is
;; expanded and not left for the shell command
;; to interpret.
@@ -989,8 +990,9 @@ requires quoting, e.g. `\\[quoted-insert]<space>'."
(files
(if (not current-prefix-arg)
(project-files pr)
- (let ((dir (read-directory-name "Base directory: "
- caller-dir nil t)))
+ (let* ((dir (read-directory-name "Base directory: "
+ caller-dir nil t)))
+ (setq default-directory dir)
(project--files-in-directory dir
nil
(grep-read-files regexp))))))
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 999fbebfb08..f6ef175e11e 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -2553,6 +2553,16 @@ If there is no Rubocop config file, Rubocop will be
passed a flag
:type 'string
:safe 'stringp)
+(defcustom ruby-rubocop-use-bundler 'check
+ "Non-nil with allow `ruby-flymake-rubocop' to use `bundle exec'.
+When the value is `check', it will first see whether Gemfile exists in
+the same directory as the configuration file, and whether it mentions
+the gem \"rubocop\". When t, it's used unconditionally. "
+ :type '(choice (const :tag "Always" t)
+ (const :tag "No" nil)
+ (const :tag "If rubocop is in Gemfile" check))
+ :safe 'booleanp)
+
(defun ruby-flymake-rubocop (report-fn &rest _args)
"RuboCop backend for Flymake."
(unless (executable-find "rubocop")
@@ -2614,11 +2624,17 @@ If there is no Rubocop config file, Rubocop will be
passed a flag
finally (funcall report-fn diags)))))))
(defun ruby-flymake-rubocop--use-bundler-p (dir)
- (let ((file (expand-file-name "Gemfile" dir)))
- (and (file-exists-p file)
- (with-temp-buffer
- (insert-file-contents file)
- (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t)))))
+ (cond
+ ((eq t ruby-rubocop-use-bundler)
+ t)
+ ((null ruby-rubocop-use-bundler)
+ nil)
+ (t
+ (let ((file (expand-file-name "Gemfile" dir)))
+ (and (file-exists-p file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t)))))))
(defun ruby-flymake-auto (report-fn &rest args)
(apply
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 90ed8eb20e9..f9faec1b474 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1048,11 +1048,15 @@ beginning of the line."
(defun xref--add-log-current-defun ()
"Return the string used to group a set of locations.
This function is used as a value for `add-log-current-defun-function'."
- (xref--group-name-for-display
- (if-let (item (xref--item-at-point))
- (xref-location-group (xref-match-item-location item))
- (xref--imenu-extract-index-name))
- (xref--project-root (project-current))))
+ (let ((project-root (xref--project-root (project-current))))
+ (xref--group-name-for-display
+ (if-let (item (xref--item-at-point))
+ (xref-location-group (xref-match-item-location item))
+ (xref--imenu-extract-index-name))
+ project-root
+ (and
+ (string-prefix-p project-root default-directory)
+ (substring default-directory (length project-root))))))
(defun xref--next-error-function (n reset?)
(when reset?
@@ -1184,12 +1188,15 @@ GROUP is a string for decoration purposes and XREF is an
(xref--apply-truncation)))
(run-hooks 'xref-after-update-hook))
-(defun xref--group-name-for-display (group project-root)
+(defun xref--group-name-for-display (group project-root dd-suffix)
"Return GROUP formatted in the preferred style.
The style is determined by the value of `xref-file-name-display'.
If GROUP looks like a file name, its value is formatted according
-to that style. Otherwise it is returned unchanged."
+to that style. Otherwise it is returned unchanged.
+
+PROJECT-ROOT is the root of the current project, if any. DD-SUFFIX is
+the relative name of `default-directory' relative to the project root."
;; XXX: The way we verify that it's indeed a file name and not some
;; other kind of string, e.g. Java package name or TITLE from
;; `tags-apropos-additional-actions', is pretty lax. But we don't
@@ -1199,16 +1206,19 @@ to that style. Otherwise it is returned unchanged."
;; values themselves (e.g. by piping through some public function),
;; or adding a new accessor to locations, like GROUP-TYPE.
(cl-ecase xref-file-name-display
- (abs group)
+ (abs (if (file-name-absolute-p group) group (expand-file-name group)))
(nondirectory
- (if (file-name-absolute-p group)
- (file-name-nondirectory group)
- group))
+ (file-name-nondirectory group))
(project-relative
- (if (and project-root
- (string-prefix-p project-root group))
- (substring group (length project-root))
- group))))
+ (cond
+ ((not (file-name-absolute-p group))
+ (concat dd-suffix group))
+ ((and project-root
+ (string-prefix-p project-root group))
+ (substring group (length project-root)))
+ ;; Default to absolute when there's not project around.
+ (t
+ (expand-file-name group))))))
(defun xref--analyze (xrefs)
"Find common groups in XREFS and format group names.
@@ -1221,10 +1231,13 @@ Return an alist of the form ((GROUP . (XREF ...)) ...)."
(eq xref-file-name-display 'project-relative)
(project-current)))
(project-root (and project
- (expand-file-name (xref--project-root project)))))
+ (expand-file-name (xref--project-root project))))
+ (dd-suffix (and project-root
+ (string-prefix-p project-root default-directory)
+ (substring default-directory (length project-root)))))
(mapcar
(lambda (pair)
- (cons (xref--group-name-for-display (car pair) project-root)
+ (cons (xref--group-name-for-display (car pair) project-root dd-suffix)
(cdr pair)))
alist)))
diff --git a/src/android.c b/src/android.c
index c25ecd88a5a..72ef9e689ef 100644
--- a/src/android.c
+++ b/src/android.c
@@ -153,7 +153,7 @@ char *android_cache_dir;
/* The list of archive files within which the Java virtual macine
looks for class files. */
-char *android_class_path;
+static char *android_class_path;
/* The display's pixel densities. */
double android_pixel_density_x, android_pixel_density_y;
diff --git a/src/androidfont.c b/src/androidfont.c
index 20a18327ff8..5cd23a006e8 100644
--- a/src/androidfont.c
+++ b/src/androidfont.c
@@ -136,26 +136,26 @@ struct androidfont_entity
/* Method and class identifiers associated with the EmacsFontDriver
class. */
-struct android_emacs_font_driver font_driver_class;
+static struct android_emacs_font_driver font_driver_class;
/* Field and class identifiers associated with the
EmacsFontDriver$FontSpec class. */
-struct android_emacs_font_spec font_spec_class;
+static struct android_emacs_font_spec font_spec_class;
/* Method and class identifiers associated with the Integer class. */
-struct android_integer integer_class;
+static struct android_integer integer_class;
/* Field and class identifiers associated with the
EmacsFontDriver$FontMetrics class. */
-struct android_emacs_font_metrics font_metrics_class;
+static struct android_emacs_font_metrics font_metrics_class;
/* Field and class identifiers associated with the
EmacsFontDriver$FontObject class. */
-struct android_emacs_font_object font_object_class;
+static struct android_emacs_font_object font_object_class;
/* The font cache. */
diff --git a/src/androidterm.c b/src/androidterm.c
index e1cd96c9176..67c20ec5245 100644
--- a/src/androidterm.c
+++ b/src/androidterm.c
@@ -6479,8 +6479,6 @@ static struct textconv_interface
text_conversion_interface =
-extern frame_parm_handler android_frame_parm_handlers[];
-
#endif /* !ANDROID_STUBIFY */
static struct redisplay_interface android_redisplay_interface =
diff --git a/src/androidterm.h b/src/androidterm.h
index 24eb2c30f12..f4459c45dc9 100644
--- a/src/androidterm.h
+++ b/src/androidterm.h
@@ -392,6 +392,7 @@ extern struct android_display_info *x_display_list;
/* From androidfns.c. */
+extern frame_parm_handler android_frame_parm_handlers[];
extern void android_free_gcs (struct frame *);
extern void android_default_font_parameter (struct frame *, Lisp_Object);
extern void android_set_preeditarea (struct window *, int, int);
diff --git a/src/epaths.in b/src/epaths.in
index 8415ce51586..a928830dba2 100644
--- a/src/epaths.in
+++ b/src/epaths.in
@@ -94,10 +94,11 @@ along with GNU Emacs. If not, see
<https://www.gnu.org/licenses/>. */
# define PATH_DATA "/assets/etc/"
# define PATH_DOC "/assets/etc/"
# define PATH_INFO "/assets/info/"
- # define PATH_GAME ""
+ # define PATH_GAME (android_game_path)
# define PATH_BITMAPS "/assets/bitmaps/"
extern char *android_site_load_path;
extern char *android_lib_dir;
+extern char *android_game_path;
#endif
diff --git a/test/lisp/progmodes/project-tests.el
b/test/lisp/progmodes/project-tests.el
index 21703cbdad6..93943cef43b 100644
--- a/test/lisp/progmodes/project-tests.el
+++ b/test/lisp/progmodes/project-tests.el
@@ -188,4 +188,33 @@ When `project-ignores' includes a name matching project
dir."
(should (equal (sort (mapcar #'xref-item-summary matches) #'string<)
'("((nil . ((project-vc-ignores . (\"etc\")))))"
"etc"))))))
+(ert-deftest project-find-regexp-with-prefix ()
+ "Check the happy path."
+ (skip-unless (executable-find find-program))
+ (skip-unless (executable-find "xargs"))
+ (skip-unless (executable-find "grep"))
+ (let* ((directory (ert-resource-directory))
+ (project-find-functions nil)
+ (project-list-file (expand-file-name "emacs-projects"
temporary-file-directory))
+ (project (cons 'transient (expand-file-name
"../elisp-mode-resources/" directory))))
+ (add-hook 'project-find-functions (lambda (_dir) project))
+ (should (eq (project-current) project))
+ (let* ((matches nil)
+ (xref-search-program 'grep)
+ (xref-show-xrefs-function
+ (lambda (fetcher _display)
+ (setq matches (funcall fetcher))))
+ (current-prefix-arg t))
+ (cl-letf (((symbol-function 'read-directory-name)
+ (lambda (_prompt _default _dirname _mm) directory))
+ ((symbol-function 'grep-read-files) (lambda (_re) "*")))
+ (project-find-regexp "etc"))
+ (should (equal (mapcar (lambda (item)
+ (file-name-base
+ (xref-location-group (xref-item-location
item))))
+ matches)
+ '(".dir-locals" "etc")))
+ (should (equal (sort (mapcar #'xref-item-summary matches) #'string<)
+ '("((nil . ((project-vc-ignores . (\"etc\")))))"
"etc"))))))
+
;;; project-tests.el ends here