Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aki2o committed Sep 18, 2017
1 parent 5d1db7c commit 909025c
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions pophint-config--tags.el
Expand Up @@ -6,32 +6,43 @@


;;;###autoload
(defmacro pophint-config:set-tag-jump-command (command)
"Set advice to move the point selected hint-tip before COMMAND."
(defmacro* pophint-config:set-tag-jump-command (command &key point-arg-index)
"Set advice to move the point selected hint-tip before COMMAND.
If COMMAND receives point by interactive, give the argument index as POINT-ARG-INDEX."
(declare (indent 0))
`(defadvice ,command (around do-pophint activate)
(pophint--trace "start as substitute for %s" (symbol-name ',command))
(let ((pophint-config:tag-jump-current-mode major-mode)
(currpt (point))
(startpt (progn (skip-syntax-backward "w_") (point))))
(pophint:do :allwindow t
:direction 'around
:source `((activebufferp . (lambda (b)
(eq pophint-config:tag-jump-current-mode
(buffer-local-value 'major-mode b))))
,@pophint:source-symbol)
:action-name "TagJump"
:action (lambda (hint)
(with-selected-window (pophint:hint-window hint)
(goto-char (pophint:hint-startpt hint))
ad-do-it
(ignore-errors
(let (pt (point))
(with-selected-window (get-buffer-window)
(goto-char pt)))))))
(when (and (eq major-mode pophint-config:tag-jump-current-mode)
(= (point) startpt))
(goto-char currpt)))))
(let ((pophint-config:tag-jump-current-mode major-mode))
(lexical-let ((currwnd (get-buffer-window))
(currpt (point))
(startpt (progn
;; move to head of current symbol
(skip-syntax-backward "w_")
(point))))
(pophint:do :allwindow t
:direction 'around
:source `((activebufferp . (lambda (b)
(eq pophint-config:tag-jump-current-mode
(buffer-local-value 'major-mode b))))
,@pophint:source-symbol)
:action-name "TagJump"
:action (lambda (hint)
(lexical-let* ((startwnd (pophint:hint-window hint))
(beforept (window-point startwnd)))
(with-selected-window startwnd
(goto-char (pophint:hint-startpt hint))
(when ,point-arg-index
(ad-set-arg ,point-arg-index (point)))
ad-do-it)
(when (and (window-live-p startwnd)
(eq (window-point startwnd) (pophint:hint-startpt hint)))
;; if jumped into other window, move active window point to before jump
(set-window-point startwnd beforept))
(when (and (window-live-p currwnd)
(eq (window-point currwnd) startpt))
;; if jumped into other window, move active window point to before jump
(set-window-point currwnd currpt)))))))))


(provide 'pophint-config--tags)
Expand Down

0 comments on commit 909025c

Please sign in to comment.