summaryrefslogtreecommitdiff
path: root/helm-dabbrev.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-05-21 08:20:42 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-05-21 08:20:42 +0200
commit43777d560b1f1cbf7fadadc2459d9e34cb1acee2 (patch)
tree0aaf471a6604ecf003ea7660b04ef5aa74903069 /helm-dabbrev.el
parent033fa11c38a52d40e80c7e7870e0b4965f164711 (diff)
Allow reusing the dabbrev assoc buffers fn in other places.
* helm-dabbrev.el (helm-dabbrev--same-major-mode-p): Now reuse helm-same-major-mode-p. * helm-lib.el (helm-same-major-mode-p): Moved here from helm-dabbrev--same-major-mode-p. Now check also if initial buffer is derived from current-buffer.
Diffstat (limited to 'helm-dabbrev.el')
-rw-r--r--helm-dabbrev.el33
1 files changed, 2 insertions, 31 deletions
diff --git a/helm-dabbrev.el b/helm-dabbrev.el
index 6f64f67f..499b9a49 100644
--- a/helm-dabbrev.el
+++ b/helm-dabbrev.el
@@ -18,6 +18,7 @@
;;; Code:
(require 'helm)
+(require 'helm-lib)
(require 'helm-help)
(require 'helm-elisp) ; For show-completion.
@@ -120,37 +121,7 @@ but the initial search for all candidates in buffer(s)."
collect buf))
(defun helm-dabbrev--same-major-mode-p (start-buffer)
- ;; START-BUFFER is the current-buffer where we start searching.
- ;; Determine the major-mode of START-BUFFER as `cur-maj-mode'.
- ;; Each time the loop go in another buffer we try to find if its
- ;; `major-mode' is:
- ;; - same as the `cur-maj-mode'
- ;; - derived from `cur-maj-mode'
- ;; - have an assoc entry (major-mode . cur-maj-mode)
- ;; - have an rassoc entry (cur-maj-mode . major-mode)
- ;; - check if one of these entries inherit from another one in
- ;; `helm-dabbrev-major-mode-assoc'.
- (let* ((cur-maj-mode (with-current-buffer start-buffer major-mode))
- (c-assoc-mode (assq cur-maj-mode helm-dabbrev-major-mode-assoc))
- (c-rassoc-mode (rassq cur-maj-mode helm-dabbrev-major-mode-assoc))
- (o-assoc-mode (assq major-mode helm-dabbrev-major-mode-assoc))
- (o-rassoc-mode (rassq major-mode helm-dabbrev-major-mode-assoc))
- (cdr-c-assoc-mode (cdr c-assoc-mode))
- (cdr-o-assoc-mode (cdr o-assoc-mode)))
- (or (eq major-mode cur-maj-mode)
- (derived-mode-p cur-maj-mode)
- (or (eq cdr-c-assoc-mode major-mode)
- (eq (car c-rassoc-mode) major-mode)
- (eq (cdr (assq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc))
- major-mode)
- (eq (car (rassq cdr-c-assoc-mode helm-dabbrev-major-mode-assoc))
- major-mode))
- (or (eq cdr-o-assoc-mode cur-maj-mode)
- (eq (car o-rassoc-mode) cur-maj-mode)
- (eq (cdr (assq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc))
- cur-maj-mode)
- (eq (car (rassq cdr-o-assoc-mode helm-dabbrev-major-mode-assoc))
- cur-maj-mode)))))
+ (helm-same-major-mode-p start-buffer helm-dabbrev-major-mode-assoc))
(defun helm-dabbrev--collect (str limit ignore-case all)
(let* ((case-fold-search ignore-case)