Skip to content

Commit eef9388

Browse files
committed
Merge pull request #694 from gracjan/pr-modernize-haskell-doc
Modernize haskell-doc.el.
2 parents 8be3b95 + 8db5b95 commit eef9388

File tree

1 file changed

+0
-163
lines changed

1 file changed

+0
-163
lines changed

haskell-doc.el

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -294,41 +294,6 @@
294294

295295
;;; Code:
296296

297-
;;@menu
298-
;;* Constants and Variables::
299-
;;* Install as minor mode::
300-
;;* Menubar Support::
301-
;;* Haskell Doc Mode::
302-
;;* Switch it on or off::
303-
;;* Check::
304-
;;* Top level function::
305-
;;* Mouse interface::
306-
;;* Print fctsym::
307-
;;* Movement::
308-
;;* Bug Reports::
309-
;;* Visit home site::
310-
;;* Index::
311-
;;* Token::
312-
;;@end menu
313-
314-
;;@node top, Constants and Variables, (dir), (dir)
315-
;;@top
316-
317-
;;@node Constants and Variables, Install as minor mode, top, top
318-
;;@section Constants and Variables
319-
320-
;;@menu
321-
;;* Emacs portability::
322-
;;* Maintenance stuff::
323-
;;* Mode Variable::
324-
;;* Variables::
325-
;;* Prelude types::
326-
;;* Test membership::
327-
;;@end menu
328-
329-
;;@node Emacs portability, Maintenance stuff, Constants and Variables, Constants and Variables
330-
;;@subsection Emacs portability
331-
332297
(eval-when-compile (require 'cl))
333298

334299
(require 'haskell-mode)
@@ -343,8 +308,6 @@
343308
:group 'haskell
344309
:prefix "haskell-doc-")
345310

346-
;;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables
347-
;;@subsection Mode Variable
348311

349312
(defvar haskell-doc-mode nil
350313
"*If non-nil, show the type of the function near point or a related comment.
@@ -439,8 +402,6 @@ This variable is buffer-local."
439402
(defvar haskell-doc-search-distance 40 ; distance in characters
440403
"*How far to search when looking for the type declaration of fct under cursor.")
441404

442-
;;@node Variables, Prelude types, Mode Variable, Constants and Variables
443-
;;@subsection Variables
444405

445406
(defvar haskell-doc-idle-delay 0.50
446407
"*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
494455
"*String to display in mode line when Haskell-Doc Mode is enabled.")
495456

496457

497-
;;@node Prelude types, Test membership, Variables, Constants and Variables
498-
;;@subsection Prelude types
499-
500-
;;@cindex haskell-doc-reserved-ids
501-
502458
(defvar haskell-doc-reserved-ids
503459
'(("case" . "case exp of { alts [;] }")
504460
("class" . "class [context =>] simpleclass [where { cbody [;] }]")
@@ -560,7 +516,6 @@ the keyword is used.")
560516
list)))
561517
(nreverse list))))))
562518

563-
;;@cindex haskell-doc-prelude-types
564519

565520
(defun haskell-doc-extract-types (url)
566521
(with-temp-buffer
@@ -1215,7 +1170,6 @@ URL is the URL of the online doc."
12151170
)
12161171
"Alist of prelude functions and their types.")
12171172

1218-
;;@cindex haskell-doc-strategy-ids
12191173

12201174
(defvar haskell-doc-strategy-ids
12211175
(list
@@ -1277,30 +1231,20 @@ URL is the URL of the online doc."
12771231
(defvar haskell-doc-user-defined-ids nil
12781232
"Alist of functions and strings defined by the user.")
12791233

1280-
;;@node Test membership, , Prelude types, Constants and Variables
1281-
;;@subsection Test membership
12821234

1283-
;;@cindex haskell-doc-is-of
12841235
(defsubst haskell-doc-is-of (fn types)
12851236
"Check whether FN is one of the functions in the alist TYPES and return the type."
12861237
(assoc fn types) )
12871238

1288-
;;@node Install as minor mode, Menubar Support, Constants and Variables, top
1289-
;;@section Install as minor mode
12901239

12911240
;; Put this minor mode on the global minor-mode-alist.
12921241
(or (assq 'haskell-doc-mode (default-value 'minor-mode-alist))
12931242
(setq-default minor-mode-alist
12941243
(append (default-value 'minor-mode-alist)
12951244
'((haskell-doc-mode haskell-doc-minor-mode-string)))))
12961245

1297-
1298-
;;@node Menubar Support, Haskell Doc Mode, Install as minor mode, top
1299-
;;@section Menubar Support
1300-
13011246
;; a dummy definition needed for XEmacs (I know, it's horrible :-(
13021247

1303-
;;@cindex haskell-doc-install-keymap
13041248

13051249
(defvar haskell-doc-keymap
13061250
(let ((map (make-sparse-keymap)))
@@ -1344,11 +1288,6 @@ URL is the URL of the online doc."
13441288
(local-set-key [(control shift meta mouse-3)]
13451289
'haskell-doc-ask-mouse-for-type))
13461290

1347-
1348-
;;@node Haskell Doc Mode, Switch it on or off, Menubar Support, top
1349-
;;@section Haskell Doc Mode
1350-
1351-
;;@cindex haskell-doc-mode
13521291

13531292
(defvar haskell-doc-timer nil)
13541293
(defvar haskell-doc-buffers nil)
@@ -1411,61 +1350,46 @@ See variable docstring."
14111350
(>= (prefix-numeric-value ,prefix) 0)
14121351
(not ,id))) )
14131352

1414-
;;@cindex haskell-doc-show-global-types
14151353
(defun haskell-doc-show-global-types (&optional prefix)
14161354
"Turn on global types information in `haskell-doc-mode'."
14171355
(interactive "P")
14181356
(haskell-doc-toggle-var haskell-doc-show-global-types prefix)
14191357
(if haskell-doc-show-global-types
14201358
(haskell-doc-make-global-fct-index)))
14211359

1422-
;;@cindex haskell-doc-show-reserved
14231360
(defun haskell-doc-show-reserved (&optional prefix)
14241361
"Toggle the automatic display of a doc string for reserved ids."
14251362
(interactive "P")
14261363
(haskell-doc-toggle-var haskell-doc-show-reserved prefix))
14271364

1428-
;;@cindex haskell-doc-show-prelude
14291365
(defun haskell-doc-show-prelude (&optional prefix)
14301366
"Toggle the automatic display of a doc string for reserved ids."
14311367
(interactive "P")
14321368
(haskell-doc-toggle-var haskell-doc-show-prelude prefix))
14331369

1434-
;;@cindex haskell-doc-show-strategy
14351370
(defun haskell-doc-show-strategy (&optional prefix)
14361371
"Toggle the automatic display of a doc string for strategy ids."
14371372
(interactive "P")
14381373
(haskell-doc-toggle-var haskell-doc-show-strategy prefix))
14391374

1440-
;;@cindex haskell-doc-show-user-defined
14411375
(defun haskell-doc-show-user-defined (&optional prefix)
14421376
"Toggle the automatic display of a doc string for user defined ids."
14431377
(interactive "P")
14441378
(haskell-doc-toggle-var haskell-doc-show-user-defined prefix))
14451379

1446-
;;@node Switch it on or off, Check, Haskell Doc Mode, top
1447-
;;@section Switch it on or off
1448-
1449-
;;@cindex turn-on-haskell-doc-mode
14501380

14511381
;;;###autoload
14521382
(defalias 'turn-on-haskell-doc-mode 'haskell-doc-mode)
14531383

14541384
;;;###autoload
14551385
(defalias 'turn-on-haskell-doc 'haskell-doc-mode)
14561386

1457-
;;@cindex turn-off-haskell-doc-mode
14581387
(defalias 'turn-off-haskell-doc-mode 'turn-off-haskell-doc)
14591388

14601389
(defun turn-off-haskell-doc ()
14611390
"Unequivocally turn off `haskell-doc-mode' (which see)."
14621391
(haskell-doc-mode 0))
14631392

1464-
;;@node Check, Top level function, Switch it on or off, top
1465-
;;@section Check
1466-
1467-
;;@cindex haskell-doc-check-active
1468-
14691393
(defun haskell-doc-check-active ()
14701394
"Check whether the print function is hooked in.
14711395
Should be the same as the value of `haskell-doc-mode' but alas currently it
@@ -1479,10 +1403,7 @@ is not."
14791403
(substitute-command-keys
14801404
"haskell-doc is not ACTIVE \(Use \\[haskell-doc-mode] to turn it on\)"))))
14811405

1482-
;;@node Top level function, Mouse interface, Check, top
1483-
;;@section Top level function
14841406

1485-
;;@cindex haskell-doc-mode-print-current-symbol-info
14861407
;; This is the function hooked into the elisp command engine
14871408
(defun haskell-doc-mode-print-current-symbol-info ()
14881409
"Print the type of the symbol under the cursor.
@@ -1519,10 +1440,7 @@ Meant for `eldoc-documentation-function'."
15191440
(unless (symbolp msg) msg)))
15201441

15211442

1522-
;;@node Mouse interface, Print fctsym, Top level function, top
1523-
;;@section Mouse interface for interactive query
15241443

1525-
;;@cindex haskell-doc-ask-mouse-for-type
15261444
(defun haskell-doc-ask-mouse-for-type (event)
15271445
"Read the identifier under the mouse and echo its type.
15281446
This uses the same underlying function `haskell-doc-show-type' as the hooked
@@ -1533,22 +1451,6 @@ function. Only the user interface is different."
15331451
(goto-char (posn-point (event-end event)))
15341452
(haskell-doc-show-type)))
15351453

1536-
1537-
;;@node Print fctsym, Movement, Mouse interface, top
1538-
;;@section Print fctsym
1539-
1540-
;;@menu
1541-
;;* Show type::
1542-
;;* Aux::
1543-
;;* Global fct type::
1544-
;;* Local fct type::
1545-
;;@end menu
1546-
1547-
;;@node Show type, Aux, Print fctsym, Print fctsym
1548-
;;@subsection Show type
1549-
1550-
;;@cindex haskell-doc-show-type
1551-
15521454
(defun haskell-doc-in-code-p ()
15531455
(not (or (and (eq haskell-literate 'bird)
15541456
;; Copied from haskell-indent-bolp.
@@ -1769,12 +1671,9 @@ the haskell-doc database."
17691671
;; (and (symbolp sym)
17701672
;; sym)))
17711673

1772-
;;@node Aux, Global fct type, Show type, Print fctsym
1773-
;;@subsection Aux
17741674

17751675
;; ToDo: handle open brackets to decide if it's a wrapped type
17761676

1777-
;;@cindex haskell-doc-grab-line
17781677
(defun haskell-doc-grab-line (fct-and-pos)
17791678
"Get the type of an \(FCT POSITION\) pair from the current buffer."
17801679
;; (if (null fct-and-pos)
@@ -1797,7 +1696,6 @@ the haskell-doc database."
17971696
str)))))
17981697
;; (concat (car fct-and-pos) "::" (haskell-doc-string-nub-ws str))))
17991698

1800-
;;@cindex haskell-doc-wrapped-type-p
18011699
(defun haskell-doc-wrapped-type-p ()
18021700
"Check whether the type under the cursor is wrapped over several lines.
18031701
The cursor must be at the end of a line, which contains the type.
@@ -1843,7 +1741,6 @@ ToDo: Check for matching parenthesis!."
18431741
(setq res t))))))
18441742
res)))
18451743

1846-
;;@cindex haskell-doc-grab
18471744
(defun haskell-doc-grab ()
18481745
"Return the text from point to the end of the line, chopping off comments.
18491746
Leaves point at end of line."
@@ -1853,7 +1750,6 @@ Leaves point at end of line."
18531750
(substring str 0 (match-beginning 0))
18541751
str)))
18551752

1856-
;;@cindex haskell-doc-string-nub-ws
18571753
(defun haskell-doc-string-nub-ws (str)
18581754
"Replace all sequences of whitespace in STR by just one space.
18591755
ToDo: Also eliminate leading and trailing whitespace."
@@ -1879,15 +1775,13 @@ ToDo: Also eliminate leading and trailing whitespace."
18791775
;; (setq i (1+ i))))
18801776
;; res))
18811777

1882-
;;@cindex haskell-doc-chop-off-context
18831778
(defun haskell-doc-chop-off-context (str)
18841779
"Eliminate the context in a type represented by the string STR."
18851780
(let ((i (string-match "=>" str)) )
18861781
(if (null i)
18871782
str
18881783
(substring str (+ i 2)))))
18891784

1890-
;;@cindex haskell-doc-get-imenu-info
18911785
(defun haskell-doc-get-imenu-info (obj kind)
18921786
"Return a string describing OBJ of KIND \(Variables, Types, Data\)."
18931787
(cond
@@ -1900,14 +1794,10 @@ ToDo: Also eliminate leading and trailing whitespace."
19001794
(t ;; (error "Cannot get local functions in %s mode, sorry" major-mode)))
19011795
nil)))
19021796

1903-
;;@node Global fct type, Local fct type, Aux, Print fctsym
1904-
;;@subsection Global fct type
1905-
19061797
;; ToDo:
19071798
;; - modular way of defining a mapping of module name to file
19081799
;; - use a path to search for file (not just current directory)
19091800

1910-
;;@cindex haskell-doc-imported-list
19111801

19121802
(defun haskell-doc-imported-list ()
19131803
"Return a list of the imported modules in current buffer."
@@ -1929,8 +1819,6 @@ ToDo: Also eliminate leading and trailing whitespace."
19291819

19301820
;; ToDo: generalise this to "Types" etc (not just "Variables")
19311821

1932-
;;@cindex haskell-doc-rescan-files
1933-
19341822
(defun haskell-doc-rescan-files (filelist)
19351823
"Do an `imenu' rescan on every file in FILELIST and return the fct-list.
19361824
This function switches to and potentially loads many buffers."
@@ -1944,8 +1832,6 @@ This function switches to and potentially loads many buffers."
19441832
(cdr (assoc "Variables" imenu--index-alist)))))
19451833
filelist)))
19461834

1947-
;;@cindex haskell-doc-make-global-fct-index
1948-
19491835
(defun haskell-doc-make-global-fct-index ()
19501836
"Scan imported files for types of global fcts and update `haskell-doc-index'."
19511837
(interactive)
@@ -1954,8 +1840,6 @@ This function switches to and potentially loads many buffers."
19541840

19551841
;; ToDo: use a separate munge-type function to format type concisely
19561842

1957-
;;@cindex haskell-doc-get-global-fct-type
1958-
19591843
(defun haskell-doc-get-global-fct-type (&optional sym)
19601844
"Get type for function symbol SYM by examining `haskell-doc-index'."
19611845
(interactive) ; "fName of outer `include' file: \nsFct:")
@@ -1984,11 +1868,6 @@ This function switches to and potentially loads many buffers."
19841868
(setq fal (cdr fal))))
19851869
res))) ; (message res)) )
19861870

1987-
;;@node Local fct type, , Global fct type, Print fctsym
1988-
;;@subsection Local fct type
1989-
1990-
;;@cindex haskell-doc-get-and-format-fct-type
1991-
19921871
(defun haskell-doc-get-and-format-fct-type (fn)
19931872
"Get the type and kind of FN by checking local and global functions."
19941873
(save-excursion
@@ -2012,48 +1891,6 @@ This function switches to and potentially loads many buffers."
20121891
;; return the result
20131892
doc ))))
20141893

2015-
2016-
;;@appendix
2017-
2018-
;;@node Index, Token, Visit home site, top
2019-
;;@section Index
2020-
2021-
;;@index
2022-
;;* haskell-doc-ask-mouse-for-type::
2023-
;;* haskell-doc-check-active::
2024-
;;* haskell-doc-chop-off-context::
2025-
;;* haskell-doc-get-and-format-fct-type::
2026-
;;* haskell-doc-get-global-fct-type::
2027-
;;* haskell-doc-get-imenu-info::
2028-
;;* haskell-doc-grab::
2029-
;;* haskell-doc-grab-line::
2030-
;;* haskell-doc-imported-list::
2031-
;;* haskell-doc-install-keymap::
2032-
;;* haskell-doc-is-of::
2033-
;;* haskell-doc-make-global-fct-index::
2034-
;;* haskell-doc-mode::
2035-
;;* haskell-doc-mode-print-current-symbol-info::
2036-
;;* haskell-doc-prelude-types::
2037-
;;* haskell-doc-rescan-files::
2038-
;;* haskell-doc-reserved-ids::
2039-
;;* haskell-doc-show-global-types::
2040-
;;* haskell-doc-show-prelude::
2041-
;;* haskell-doc-show-reserved::
2042-
;;* haskell-doc-show-strategy::
2043-
;;* haskell-doc-show-type::
2044-
;;* haskell-doc-show-user-defined::
2045-
;;* haskell-doc-strategy-ids::
2046-
;;* haskell-doc-string-nub-ws::
2047-
;;* haskell-doc-submit-bug-report::
2048-
;;* haskell-doc-visit-home::
2049-
;;* haskell-doc-wrapped-type-p::
2050-
;;* turn-off-haskell-doc-mode::
2051-
;;* turn-on-haskell-doc-mode::
2052-
;;@end index
2053-
2054-
;;@node Token, , Index, top
2055-
;;@section Token
2056-
20571894
(provide 'haskell-doc)
20581895

20591896
;;; haskell-doc.el ends here

0 commit comments

Comments
 (0)