From 8db5b954cfb002f17b958494622b77a0141c396a Mon Sep 17 00:00:00 2001 From: Gracjan Polak Date: Thu, 4 Jun 2015 16:31:51 +0200 Subject: [PATCH] Modernize haskell-doc.el. --- haskell-doc.el | 163 ------------------------------------------------- 1 file changed, 163 deletions(-) diff --git a/haskell-doc.el b/haskell-doc.el index 98d58cfff..95d5f133c 100644 --- a/haskell-doc.el +++ b/haskell-doc.el @@ -294,41 +294,6 @@ ;;; Code: -;;@menu -;;* Constants and Variables:: -;;* Install as minor mode:: -;;* Menubar Support:: -;;* Haskell Doc Mode:: -;;* Switch it on or off:: -;;* Check:: -;;* Top level function:: -;;* Mouse interface:: -;;* Print fctsym:: -;;* Movement:: -;;* Bug Reports:: -;;* Visit home site:: -;;* Index:: -;;* Token:: -;;@end menu - -;;@node top, Constants and Variables, (dir), (dir) -;;@top - -;;@node Constants and Variables, Install as minor mode, top, top -;;@section Constants and Variables - -;;@menu -;;* Emacs portability:: -;;* Maintenance stuff:: -;;* Mode Variable:: -;;* Variables:: -;;* Prelude types:: -;;* Test membership:: -;;@end menu - -;;@node Emacs portability, Maintenance stuff, Constants and Variables, Constants and Variables -;;@subsection Emacs portability - (eval-when-compile (require 'cl)) (require 'haskell-mode) @@ -343,8 +308,6 @@ :group 'haskell :prefix "haskell-doc-") -;;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables -;;@subsection Mode Variable (defvar haskell-doc-mode nil "*If non-nil, show the type of the function near point or a related comment. @@ -439,8 +402,6 @@ This variable is buffer-local." (defvar haskell-doc-search-distance 40 ; distance in characters "*How far to search when looking for the type declaration of fct under cursor.") -;;@node Variables, Prelude types, Mode Variable, Constants and Variables -;;@subsection Variables (defvar haskell-doc-idle-delay 0.50 "*Number of seconds of idle time to wait before printing. @@ -494,11 +455,6 @@ It is probably best to manipulate this data structure with the commands "*String to display in mode line when Haskell-Doc Mode is enabled.") -;;@node Prelude types, Test membership, Variables, Constants and Variables -;;@subsection Prelude types - -;;@cindex haskell-doc-reserved-ids - (defvar haskell-doc-reserved-ids '(("case" . "case exp of { alts [;] }") ("class" . "class [context =>] simpleclass [where { cbody [;] }]") @@ -560,7 +516,6 @@ the keyword is used.") list))) (nreverse list)))))) -;;@cindex haskell-doc-prelude-types (defun haskell-doc-extract-types (url) (with-temp-buffer @@ -1215,7 +1170,6 @@ URL is the URL of the online doc." ) "Alist of prelude functions and their types.") -;;@cindex haskell-doc-strategy-ids (defvar haskell-doc-strategy-ids (list @@ -1277,16 +1231,11 @@ URL is the URL of the online doc." (defvar haskell-doc-user-defined-ids nil "Alist of functions and strings defined by the user.") -;;@node Test membership, , Prelude types, Constants and Variables -;;@subsection Test membership -;;@cindex haskell-doc-is-of (defsubst haskell-doc-is-of (fn types) "Check whether FN is one of the functions in the alist TYPES and return the type." (assoc fn types) ) -;;@node Install as minor mode, Menubar Support, Constants and Variables, top -;;@section Install as minor mode ;; Put this minor mode on the global minor-mode-alist. (or (assq 'haskell-doc-mode (default-value 'minor-mode-alist)) @@ -1294,13 +1243,8 @@ URL is the URL of the online doc." (append (default-value 'minor-mode-alist) '((haskell-doc-mode haskell-doc-minor-mode-string))))) - -;;@node Menubar Support, Haskell Doc Mode, Install as minor mode, top -;;@section Menubar Support - ;; a dummy definition needed for XEmacs (I know, it's horrible :-( -;;@cindex haskell-doc-install-keymap (defvar haskell-doc-keymap (let ((map (make-sparse-keymap))) @@ -1344,11 +1288,6 @@ URL is the URL of the online doc." (local-set-key [(control shift meta mouse-3)] 'haskell-doc-ask-mouse-for-type)) - -;;@node Haskell Doc Mode, Switch it on or off, Menubar Support, top -;;@section Haskell Doc Mode - -;;@cindex haskell-doc-mode (defvar haskell-doc-timer nil) (defvar haskell-doc-buffers nil) @@ -1411,7 +1350,6 @@ See variable docstring." (>= (prefix-numeric-value ,prefix) 0) (not ,id))) ) -;;@cindex haskell-doc-show-global-types (defun haskell-doc-show-global-types (&optional prefix) "Turn on global types information in `haskell-doc-mode'." (interactive "P") @@ -1419,34 +1357,26 @@ See variable docstring." (if haskell-doc-show-global-types (haskell-doc-make-global-fct-index))) -;;@cindex haskell-doc-show-reserved (defun haskell-doc-show-reserved (&optional prefix) "Toggle the automatic display of a doc string for reserved ids." (interactive "P") (haskell-doc-toggle-var haskell-doc-show-reserved prefix)) -;;@cindex haskell-doc-show-prelude (defun haskell-doc-show-prelude (&optional prefix) "Toggle the automatic display of a doc string for reserved ids." (interactive "P") (haskell-doc-toggle-var haskell-doc-show-prelude prefix)) -;;@cindex haskell-doc-show-strategy (defun haskell-doc-show-strategy (&optional prefix) "Toggle the automatic display of a doc string for strategy ids." (interactive "P") (haskell-doc-toggle-var haskell-doc-show-strategy prefix)) -;;@cindex haskell-doc-show-user-defined (defun haskell-doc-show-user-defined (&optional prefix) "Toggle the automatic display of a doc string for user defined ids." (interactive "P") (haskell-doc-toggle-var haskell-doc-show-user-defined prefix)) -;;@node Switch it on or off, Check, Haskell Doc Mode, top -;;@section Switch it on or off - -;;@cindex turn-on-haskell-doc-mode ;;;###autoload (defalias 'turn-on-haskell-doc-mode 'haskell-doc-mode) @@ -1454,18 +1384,12 @@ See variable docstring." ;;;###autoload (defalias 'turn-on-haskell-doc 'haskell-doc-mode) -;;@cindex turn-off-haskell-doc-mode (defalias 'turn-off-haskell-doc-mode 'turn-off-haskell-doc) (defun turn-off-haskell-doc () "Unequivocally turn off `haskell-doc-mode' (which see)." (haskell-doc-mode 0)) -;;@node Check, Top level function, Switch it on or off, top -;;@section Check - -;;@cindex haskell-doc-check-active - (defun haskell-doc-check-active () "Check whether the print function is hooked in. Should be the same as the value of `haskell-doc-mode' but alas currently it @@ -1479,10 +1403,7 @@ is not." (substitute-command-keys "haskell-doc is not ACTIVE \(Use \\[haskell-doc-mode] to turn it on\)")))) -;;@node Top level function, Mouse interface, Check, top -;;@section Top level function -;;@cindex haskell-doc-mode-print-current-symbol-info ;; This is the function hooked into the elisp command engine (defun haskell-doc-mode-print-current-symbol-info () "Print the type of the symbol under the cursor. @@ -1519,10 +1440,7 @@ Meant for `eldoc-documentation-function'." (unless (symbolp msg) msg))) -;;@node Mouse interface, Print fctsym, Top level function, top -;;@section Mouse interface for interactive query -;;@cindex haskell-doc-ask-mouse-for-type (defun haskell-doc-ask-mouse-for-type (event) "Read the identifier under the mouse and echo its type. This uses the same underlying function `haskell-doc-show-type' as the hooked @@ -1533,22 +1451,6 @@ function. Only the user interface is different." (goto-char (posn-point (event-end event))) (haskell-doc-show-type))) - -;;@node Print fctsym, Movement, Mouse interface, top -;;@section Print fctsym - -;;@menu -;;* Show type:: -;;* Aux:: -;;* Global fct type:: -;;* Local fct type:: -;;@end menu - -;;@node Show type, Aux, Print fctsym, Print fctsym -;;@subsection Show type - -;;@cindex haskell-doc-show-type - (defun haskell-doc-in-code-p () (not (or (and (eq haskell-literate 'bird) ;; Copied from haskell-indent-bolp. @@ -1769,12 +1671,9 @@ the haskell-doc database." ;; (and (symbolp sym) ;; sym))) -;;@node Aux, Global fct type, Show type, Print fctsym -;;@subsection Aux ;; ToDo: handle open brackets to decide if it's a wrapped type -;;@cindex haskell-doc-grab-line (defun haskell-doc-grab-line (fct-and-pos) "Get the type of an \(FCT POSITION\) pair from the current buffer." ;; (if (null fct-and-pos) @@ -1797,7 +1696,6 @@ the haskell-doc database." str))))) ;; (concat (car fct-and-pos) "::" (haskell-doc-string-nub-ws str)))) -;;@cindex haskell-doc-wrapped-type-p (defun haskell-doc-wrapped-type-p () "Check whether the type under the cursor is wrapped over several lines. The cursor must be at the end of a line, which contains the type. @@ -1843,7 +1741,6 @@ ToDo: Check for matching parenthesis!." (setq res t)))))) res))) -;;@cindex haskell-doc-grab (defun haskell-doc-grab () "Return the text from point to the end of the line, chopping off comments. Leaves point at end of line." @@ -1853,7 +1750,6 @@ Leaves point at end of line." (substring str 0 (match-beginning 0)) str))) -;;@cindex haskell-doc-string-nub-ws (defun haskell-doc-string-nub-ws (str) "Replace all sequences of whitespace in STR by just one space. ToDo: Also eliminate leading and trailing whitespace." @@ -1879,7 +1775,6 @@ ToDo: Also eliminate leading and trailing whitespace." ;; (setq i (1+ i)))) ;; res)) -;;@cindex haskell-doc-chop-off-context (defun haskell-doc-chop-off-context (str) "Eliminate the context in a type represented by the string STR." (let ((i (string-match "=>" str)) ) @@ -1887,7 +1782,6 @@ ToDo: Also eliminate leading and trailing whitespace." str (substring str (+ i 2))))) -;;@cindex haskell-doc-get-imenu-info (defun haskell-doc-get-imenu-info (obj kind) "Return a string describing OBJ of KIND \(Variables, Types, Data\)." (cond @@ -1900,14 +1794,10 @@ ToDo: Also eliminate leading and trailing whitespace." (t ;; (error "Cannot get local functions in %s mode, sorry" major-mode))) nil))) -;;@node Global fct type, Local fct type, Aux, Print fctsym -;;@subsection Global fct type - ;; ToDo: ;; - modular way of defining a mapping of module name to file ;; - use a path to search for file (not just current directory) -;;@cindex haskell-doc-imported-list (defun haskell-doc-imported-list () "Return a list of the imported modules in current buffer." @@ -1929,8 +1819,6 @@ ToDo: Also eliminate leading and trailing whitespace." ;; ToDo: generalise this to "Types" etc (not just "Variables") -;;@cindex haskell-doc-rescan-files - (defun haskell-doc-rescan-files (filelist) "Do an `imenu' rescan on every file in FILELIST and return the fct-list. This function switches to and potentially loads many buffers." @@ -1944,8 +1832,6 @@ This function switches to and potentially loads many buffers." (cdr (assoc "Variables" imenu--index-alist))))) filelist))) -;;@cindex haskell-doc-make-global-fct-index - (defun haskell-doc-make-global-fct-index () "Scan imported files for types of global fcts and update `haskell-doc-index'." (interactive) @@ -1954,8 +1840,6 @@ This function switches to and potentially loads many buffers." ;; ToDo: use a separate munge-type function to format type concisely -;;@cindex haskell-doc-get-global-fct-type - (defun haskell-doc-get-global-fct-type (&optional sym) "Get type for function symbol SYM by examining `haskell-doc-index'." (interactive) ; "fName of outer `include' file: \nsFct:") @@ -1984,11 +1868,6 @@ This function switches to and potentially loads many buffers." (setq fal (cdr fal)))) res))) ; (message res)) ) -;;@node Local fct type, , Global fct type, Print fctsym -;;@subsection Local fct type - -;;@cindex haskell-doc-get-and-format-fct-type - (defun haskell-doc-get-and-format-fct-type (fn) "Get the type and kind of FN by checking local and global functions." (save-excursion @@ -2012,48 +1891,6 @@ This function switches to and potentially loads many buffers." ;; return the result doc )))) - -;;@appendix - -;;@node Index, Token, Visit home site, top -;;@section Index - -;;@index -;;* haskell-doc-ask-mouse-for-type:: -;;* haskell-doc-check-active:: -;;* haskell-doc-chop-off-context:: -;;* haskell-doc-get-and-format-fct-type:: -;;* haskell-doc-get-global-fct-type:: -;;* haskell-doc-get-imenu-info:: -;;* haskell-doc-grab:: -;;* haskell-doc-grab-line:: -;;* haskell-doc-imported-list:: -;;* haskell-doc-install-keymap:: -;;* haskell-doc-is-of:: -;;* haskell-doc-make-global-fct-index:: -;;* haskell-doc-mode:: -;;* haskell-doc-mode-print-current-symbol-info:: -;;* haskell-doc-prelude-types:: -;;* haskell-doc-rescan-files:: -;;* haskell-doc-reserved-ids:: -;;* haskell-doc-show-global-types:: -;;* haskell-doc-show-prelude:: -;;* haskell-doc-show-reserved:: -;;* haskell-doc-show-strategy:: -;;* haskell-doc-show-type:: -;;* haskell-doc-show-user-defined:: -;;* haskell-doc-strategy-ids:: -;;* haskell-doc-string-nub-ws:: -;;* haskell-doc-submit-bug-report:: -;;* haskell-doc-visit-home:: -;;* haskell-doc-wrapped-type-p:: -;;* turn-off-haskell-doc-mode:: -;;* turn-on-haskell-doc-mode:: -;;@end index - -;;@node Token, , Index, top -;;@section Token - (provide 'haskell-doc) ;;; haskell-doc.el ends here