From 43777d560b1f1cbf7fadadc2459d9e34cb1acee2 Mon Sep 17 00:00:00 2001 From: Thierry Volpiatto Date: Sat, 21 May 2016 08:20:42 +0200 Subject: 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. --- helm-dabbrev.el | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'helm-dabbrev.el') 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) -- cgit v1.2.3