From 079d2e41db0fafc5f5ab30ccd7afc02e346b48b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 1 Nov 2014 23:10:45 +0100 Subject: [PATCH] FUEL: when browsing vocab documentation, use the fuel-help--buffer-link variable to determine what vocabulary we are "in" --- misc/fuel/fuel-help.el | 6 ++++++ misc/fuel/fuel-tests.el | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/misc/fuel/fuel-help.el b/misc/fuel/fuel-help.el index ab843c99ba..5be9b8c5d4 100644 --- a/misc/fuel/fuel-help.el +++ b/misc/fuel/fuel-help.el @@ -343,9 +343,15 @@ With prefix, the current page is deleted from history." ;;; IN: support +(defun fuel-help--find-in-buffer-link () + (when (and fuel-help--buffer-link + (equal (nth 2 fuel-help--buffer-link) 'vocab)) + (car fuel-help--buffer-link))) + (defun fuel-help--find-in () (save-excursion (or (factor-find-in) + (fuel-help--find-in-buffer-link) (and (goto-char (point-min)) (re-search-forward "Vocabulary: \\(.+\\)$" nil t) (match-string-no-properties 1))))) diff --git a/misc/fuel/fuel-tests.el b/misc/fuel/fuel-tests.el index 9d60a5e041..80fe17be37 100644 --- a/misc/fuel/fuel-tests.el +++ b/misc/fuel/fuel-tests.el @@ -20,6 +20,7 @@ (add-to-list 'load-path (file-name-directory load-file-name)) (require 'ert) +(require 'fuel-help) (require 'fuel-markup) ;; fuel-markup @@ -33,3 +34,19 @@ (fuel-markup--quotation quot) (buffer-string)) "a quotation with stack effect ( args kw -- ret )")))) + +;; fuel-help +(ert-deftest find-in-w/vocabulary () + (should (equal + (with-temp-buffer + (insert "Vocabulary: imap") + (fuel-help--find-in)) + "imap"))) + +(ert-deftest find-in-w/buffer-link () + (should (equal + (with-temp-buffer + (setq fuel-help--buffer-link '("foob" "foob" vocab)) + (insert "Help page contents") + (fuel-help--find-in)) + "foob")))