summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-07-26 18:27:51 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-07-26 18:27:51 -0700
commit4797710f1bde16e716ece04f28325879726fa2e4 (patch)
tree52e13d0600cc02556635621d52946e9886436a15
parentc2c422ba2c1851d86a99038fde2e93805e217394 (diff)
parent4d195bb7d0beff4c5833401bd167851f8557d0ad (diff)
downloademacs-4797710f1bde16e716ece04f28325879726fa2e4.tar.gz
Merge remote-tracking branch 'origin/master' into athena/unstable
-rw-r--r--lisp/progmodes/elisp-mode.el4
-rw-r--r--lisp/progmodes/project.el139
-rw-r--r--src/emacs-module.c8
3 files changed, 124 insertions, 27 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 6df54111911..2f44118edb5 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -280,9 +280,9 @@ Blank lines separate paragraphs. Semicolons start comments.
electric-pair-text-pairs))
(add-hook 'electric-pair-mode-hook #'emacs-lisp-set-electric-text-pairs))
(add-hook 'eldoc-documentation-functions
- #'elisp-eldoc-var-docstring nil t)
- (add-hook 'eldoc-documentation-functions
#'elisp-eldoc-funcall nil t)
+ (add-hook 'eldoc-documentation-functions
+ #'elisp-eldoc-var-docstring nil t)
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
(add-hook 'completion-at-point-functions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 5cfc6a20986..da4a589c21a 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -568,6 +568,13 @@ DIRS must contain directory names."
;; Sidestep the issue of expanded/abbreviated file names here.
(cl-set-difference files dirs :test #'file-in-directory-p))
+(defun project--value-in-dir (var dir)
+ (with-temp-buffer
+ (setq default-directory dir)
+ (let ((enable-local-variables :all))
+ (hack-dir-local-variables-non-file-buffer))
+ (symbol-value var)))
+
;;; Project commands
@@ -592,12 +599,73 @@ DIRS must contain directory names."
;;;###autoload (define-key ctl-x-map "p" project-prefix-map)
-(defun project--value-in-dir (var dir)
- (with-temp-buffer
- (setq default-directory dir)
- (let ((enable-local-variables :all))
- (hack-dir-local-variables-non-file-buffer))
- (symbol-value var)))
+;; We can't have these place-specific maps inherit from
+;; project-prefix-map because project--other-place-command needs to
+;; know which map the key binding came from, as if it came from one of
+;; these maps, we don't want to set display-buffer-overriding-action
+
+(defvar project-other-window-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-o" #'project-display-buffer)
+ map)
+ "Keymap for project commands that display buffers in other windows.")
+
+(defvar project-other-frame-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\C-o" #'project-display-buffer-other-frame)
+ map)
+ "Keymap for project commands that display buffers in other frames.")
+
+(defun project--other-place-command (action &optional map)
+ (let* ((key (read-key-sequence-vector nil t))
+ (place-cmd (lookup-key map key))
+ (generic-cmd (lookup-key project-prefix-map key))
+ (switch-to-buffer-obey-display-actions t)
+ (display-buffer-overriding-action (unless place-cmd action)))
+ (if-let ((cmd (or place-cmd generic-cmd)))
+ (call-interactively cmd)
+ (user-error "%s is undefined" (key-description key)))))
+
+;;;###autoload
+(defun project-other-window-command ()
+ "Run project command, displaying resultant buffer in another window.
+
+The following commands are available:
+
+\\{project-prefix-map}
+\\{project-other-window-map}"
+ (interactive)
+ (project--other-place-command '((display-buffer-pop-up-window)
+ (inhibit-same-window . t))
+ project-other-window-map))
+
+;;;###autoload (define-key ctl-x-4-map "p" #'project-other-window-command)
+
+;;;###autoload
+(defun project-other-frame-command ()
+ "Run project command, displaying resultant buffer in another frame.
+
+The following commands are available:
+
+\\{project-prefix-map}
+\\{project-other-frame-map}"
+ (interactive)
+ (project--other-place-command '((display-buffer-pop-up-frame))
+ project-other-frame-map))
+
+;;;###autoload (define-key ctl-x-5-map "p" #'project-other-frame-command)
+
+;;;###autoload
+(defun project-other-tab-command ()
+ "Run project command, displaying resultant buffer in a new tab.
+
+The following commands are available:
+
+\\{project-prefix-map}"
+ (interactive)
+ (project--other-place-command '((display-buffer-in-new-tab))))
+
+;;;###autoload (define-key tab-prefix-map "p" #'project-other-tab-command)
(declare-function grep-read-files "grep")
(declare-function xref--show-xrefs "xref")
@@ -877,14 +945,7 @@ Arguments the same as in `compile'."
(default-directory (project-root pr)))
(compile command comint)))
-;;;###autoload
-(defun project-switch-to-buffer ()
- "Switch to another buffer belonging to the current project.
-This function prompts for another buffer, offering as candidates
-buffers that belong to the same project as the current buffer.
-Two buffers belong to the same project if their project instances,
-as reported by `project-current' in each buffer, are identical."
- (interactive)
+(defun project--read-project-buffer ()
(let* ((pr (project-current t))
(current-buffer (current-buffer))
(other-buffer (other-buffer current-buffer))
@@ -896,13 +957,49 @@ as reported by `project-current' in each buffer, are identical."
(equal pr
(with-current-buffer (cdr buffer)
(project-current)))))))
- (switch-to-buffer
- (read-buffer
- "Switch to buffer: "
- (when (funcall predicate (cons other-name other-buffer))
- other-name)
- nil
- predicate))))
+ (read-buffer
+ "Switch to buffer: "
+ (when (funcall predicate (cons other-name other-buffer))
+ other-name)
+ nil
+ predicate)))
+
+;;;###autoload
+(defun project-switch-to-buffer (buffer-or-name)
+ "Display buffer BUFFER-OR-NAME in the selected window.
+When called interactively, prompts for a buffer belonging to the
+current project. Two buffers belong to the same project if their
+project instances, as reported by `project-current' in each
+buffer, are identical."
+ (interactive (list (project--read-project-buffer)))
+ (switch-to-buffer buffer-or-name))
+
+;;;###autoload
+(defun project-display-buffer (buffer-or-name)
+ "Display BUFFER-OR-NAME in some window, without selecting it.
+When called interactively, prompts for a buffer belonging to the
+current project. Two buffers belong to the same project if their
+project instances, as reported by `project-current' in each
+buffer, are identical.
+
+This function uses `display-buffer' as a subroutine, which see
+for how it is determined where the buffer will be displayed."
+ (interactive (list (project--read-project-buffer)))
+ (display-buffer buffer-or-name))
+
+;;;###autoload
+(defun project-display-buffer-other-frame (buffer-or-name)
+ "Display BUFFER-OR-NAME preferably in another frame.
+When called interactively, prompts for a buffer belonging to the
+current project. Two buffers belong to the same project if their
+project instances, as reported by `project-current' in each
+buffer, are identical.
+
+This function uses `display-buffer-other-frame' as a subroutine,
+which see for how it is determined where the buffer will be
+displayed."
+ (interactive (list (project--read-project-buffer)))
+ (display-buffer-other-frame buffer-or-name))
(defcustom project-kill-buffers-ignores
'("\\*Help\\*")
diff --git a/src/emacs-module.c b/src/emacs-module.c
index e4e7da088d7..ac9ac824b7b 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -190,7 +190,7 @@ struct emacs_runtime_private
/* Forward declarations. */
static Lisp_Object value_to_lisp (emacs_value);
-static emacs_value allocate_emacs_value (emacs_env *, struct emacs_value_storage *, Lisp_Object);
+static emacs_value allocate_emacs_value (emacs_env *, Lisp_Object);
static emacs_value lisp_to_value (emacs_env *, Lisp_Object);
static enum emacs_funcall_exit module_non_local_exit_check (emacs_env *);
static void module_assert_thread (void);
@@ -1321,7 +1321,7 @@ lisp_to_value (emacs_env *env, Lisp_Object o)
struct emacs_env_private *p = env->private_members;
if (p->pending_non_local_exit != emacs_funcall_exit_return)
return NULL;
- return allocate_emacs_value (env, &p->storage, o);
+ return allocate_emacs_value (env, o);
}
/* Must be called for each frame before it can be used for allocation. */
@@ -1358,9 +1358,9 @@ finalize_storage (struct emacs_value_storage *storage)
/* Allocate a new value from STORAGE and stores OBJ in it. Return
NULL if allocation fails and use ENV for non local exit reporting. */
static emacs_value
-allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
- Lisp_Object obj)
+allocate_emacs_value (emacs_env *env, Lisp_Object obj)
{
+ struct emacs_value_storage *storage = &env->private_members->storage;
eassert (storage->current);
eassert (storage->current->offset < value_frame_size);
eassert (! storage->current->next);