[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master f942b83 26/38: Support jumping to buffers of the same majo
From: |
Dmitry Gutov |
Subject: |
[elpa] master f942b83 26/38: Support jumping to buffers of the same major mode |
Date: |
Wed, 09 Sep 2015 18:41:47 +0000 |
branch: master
commit f942b83f95394d4035e8de6e73b98551e722335a
Author: ScottyB <address@hidden>
Commit: ScottyB <address@hidden>
Support jumping to buffers of the same major mode
---
js2-mode.el | 66 ++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 41 insertions(+), 25 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index cfcc302..cf99e37 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -12299,41 +12299,57 @@ it marks the next defun after the ones already
marked."
(unless (js2-ast-root-p fn)
(narrow-to-region beg (+ beg (js2-node-len fn))))))
-(defun js2-jump-to-definition ()
+(defun js2-jump-to-definition (&optional arg)
"Jump to the definition of an object's property, variable or function."
- (interactive)
+ (interactive "P")
(ring-insert find-tag-marker-ring (point-marker))
(let* ((node (js2-node-at-point))
(parent (js2-node-parent node))
- (prop-names (if (js2-prop-get-node-p parent)(reverse
(js2-prop-names-left node))))
- (name (or (and prop-names (pop prop-names))
- (unless (and (js2-object-prop-node-p parent)
- (eq node (js2-object-prop-node-left parent)))
- (js2-name-node-name node))
- (error "Node is not a supported jump node")))
+ (names (if (js2-prop-get-node-p parent)(reverse (js2-prop-names-left
node))))
node-init)
- (ignore-errors
- (setq node-init (js2-symbol-ast-node (js2-get-symbol-declaration node
name)))
- (when prop-names
- (let ((found-node (js2-var-init-node-initializer (js2-node-parent
node-init))))
- (setq node-init nil)
- (when (js2-object-node-p found-node)
- (js2-visit-ast
- found-node
- (lambda (node endp)
- (unless endp
- (when (and (js2-object-prop-node-p node)
- (string= (car prop-names)
- (js2-name-node-name
(js2-object-prop-node-left node))))
- (pop prop-names)
- (unless prop-names (setq node-init node)))
- t)))))))
+ (push (or (and names (pop names))
+ (unless (and (js2-object-prop-node-p parent)
+ (eq node (js2-object-prop-node-left parent)))
+ (js2-name-node-name node))
+ (error "Node is not a supported jump node")) names)
+ (setq node-init (js2-search-scope node names))
+ (unless node-init
+ (switch-to-buffer (catch 'found
+ (unless arg
+ (mapc (lambda (b) (if (derived-mode-p 'js2-mode)
+ (with-current-buffer b
+ (setq node-init
(js2-search-scope js2-mode-ast names))
+ (if node-init
+ (throw 'found b)))))
+ (buffer-list)))
+ nil)))
(unless node-init
(pop-tag-mark)
(error "No jump location found"))
(goto-char (js2-node-abs-pos node-init))))
-(defun js2-prop-names-left (name-node)
+(defun js2-search-scope (scope names)
+ "Searches SCOPE for jump location in NAMES."
+ (let (node-init)
+ (ignore-errors
+ (setq node-init (js2-symbol-ast-node (js2-get-symbol-declaration scope
(pop names))))
+ (when names
+ (let ((found-node (js2-var-init-node-initializer (js2-node-parent
node-init))))
+ (setq node-init nil)
+ (when (js2-object-node-p found-node)
+ (js2-visit-ast
+ found-node
+ (lambda (node endp)
+ (unless endp
+ (when (and (js2-object-prop-node-p node)
+ (string= (car names)
+ (js2-name-node-name
(js2-object-prop-node-left node))))
+ (pop names)
+ (unless names (setq node-init node)))
+ t)))))))
+ node-init))
+
+(defun js2-names-left (name-node)
"Create a list of all of the names in the property NAME-NODE.
NAME-NODE must have a js2-prop-get-node as parent. Only adds
properties to the left of point. This is so individual jump
- [elpa] master fc56c58 16/38: js2-define-destruct-symbols-internal: Anticipate js2-getter-setter-node, (continued)
- [elpa] master fc56c58 16/38: js2-define-destruct-symbols-internal: Anticipate js2-getter-setter-node, Dmitry Gutov, 2015/09/09
- [elpa] master c8b8e11 19/38: js2-define-destruct-symbols: Speed up, theoretically, Dmitry Gutov, 2015/09/09
- [elpa] master a6f2a94 15/38: Allow plain parameters after default, Dmitry Gutov, 2015/09/09
- [elpa] master d0686a0 18/38: js2-define-destruct-symbols-internal: Remove, don't need it anymore, Dmitry Gutov, 2015/09/09
- [elpa] master f146f13 17/38: js2-define-destruct-symbols-internal: Stop growing NAME-NODES exponentially, Dmitry Gutov, 2015/09/09
- [elpa] master eba59c5 21/38: Added missing etags dependency, Dmitry Gutov, 2015/09/09
- [elpa] master 7184664 20/38: Add a jump to definition command bound to M-., Dmitry Gutov, 2015/09/09
- [elpa] master bc5cdb4 23/38: Simplified property name matching, Dmitry Gutov, 2015/09/09
- [elpa] master 1ee5c45 22/38: Return correct node when searching for the definition of a property., Dmitry Gutov, 2015/09/09
- [elpa] master 579aacb 24/38: Simplified method of searching for nodes based on scope, Dmitry Gutov, 2015/09/09
- [elpa] master f942b83 26/38: Support jumping to buffers of the same major mode,
Dmitry Gutov <=
- [elpa] master 145c5d6 25/38: Fixed jumping to object properties, Dmitry Gutov, 2015/09/09
- [elpa] master bb0476c 29/38: Clarified js2-search-scope doc string, Dmitry Gutov, 2015/09/09
- [elpa] master c4f4095 28/38: Only jump if not already at var or function definition, Dmitry Gutov, 2015/09/09
- [elpa] master af85699 30/38: Clean up todo in js2-search-scope and fix year typo, Dmitry Gutov, 2015/09/09
- [elpa] master aaf218a 27/38: Find definition by locating assignment nodes, Dmitry Gutov, 2015/09/09
- [elpa] master e236923 31/38: Removed functions: js2-build-prop-name-list and js2-names-left., Dmitry Gutov, 2015/09/09
- [elpa] master 75129c1 33/38: Use cl-assert instead of error, Dmitry Gutov, 2015/09/09
- [elpa] master bbb5086 34/38: Remove a space, Dmitry Gutov, 2015/09/09
- [elpa] master 58335d4 36/38: Add NEWS and bump the version, Dmitry Gutov, 2015/09/09
- [elpa] master 9ad7708 32/38: Add cl- prefix, improve line lengths, Dmitry Gutov, 2015/09/09