294
294
295
295
; ;; Code:
296
296
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
-
332
297
(eval-when-compile (require 'cl ))
333
298
334
299
(require 'haskell-mode )
343
308
:group 'haskell
344
309
:prefix " haskell-doc-" )
345
310
346
- ; ;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables
347
- ; ;@subsection Mode Variable
348
311
349
312
(defvar haskell-doc-mode nil
350
313
" *If non-nil, show the type of the function near point or a related comment.
@@ -439,8 +402,6 @@ This variable is buffer-local."
439
402
(defvar haskell-doc-search-distance 40 ; distance in characters
440
403
" *How far to search when looking for the type declaration of fct under cursor." )
441
404
442
- ; ;@node Variables, Prelude types, Mode Variable, Constants and Variables
443
- ; ;@subsection Variables
444
405
445
406
(defvar haskell-doc-idle-delay 0.50
446
407
" *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
494
455
" *String to display in mode line when Haskell-Doc Mode is enabled." )
495
456
496
457
497
- ; ;@node Prelude types, Test membership, Variables, Constants and Variables
498
- ; ;@subsection Prelude types
499
-
500
- ; ;@cindex haskell-doc-reserved-ids
501
-
502
458
(defvar haskell-doc-reserved-ids
503
459
'((" case" . " case exp of { alts [;] }" )
504
460
(" class" . " class [context =>] simpleclass [where { cbody [;] }]" )
@@ -560,7 +516,6 @@ the keyword is used.")
560
516
list )))
561
517
(nreverse list ))))))
562
518
563
- ; ;@cindex haskell-doc-prelude-types
564
519
565
520
(defun haskell-doc-extract-types (url )
566
521
(with-temp-buffer
@@ -1215,7 +1170,6 @@ URL is the URL of the online doc."
1215
1170
)
1216
1171
" Alist of prelude functions and their types." )
1217
1172
1218
- ; ;@cindex haskell-doc-strategy-ids
1219
1173
1220
1174
(defvar haskell-doc-strategy-ids
1221
1175
(list
@@ -1277,30 +1231,20 @@ URL is the URL of the online doc."
1277
1231
(defvar haskell-doc-user-defined-ids nil
1278
1232
" Alist of functions and strings defined by the user." )
1279
1233
1280
- ; ;@node Test membership, , Prelude types, Constants and Variables
1281
- ; ;@subsection Test membership
1282
1234
1283
- ; ;@cindex haskell-doc-is-of
1284
1235
(defsubst haskell-doc-is-of (fn types )
1285
1236
" Check whether FN is one of the functions in the alist TYPES and return the type."
1286
1237
(assoc fn types) )
1287
1238
1288
- ; ;@node Install as minor mode, Menubar Support, Constants and Variables, top
1289
- ; ;@section Install as minor mode
1290
1239
1291
1240
; ; Put this minor mode on the global minor-mode-alist.
1292
1241
(or (assq 'haskell-doc-mode (default-value 'minor-mode-alist ))
1293
1242
(setq-default minor-mode-alist
1294
1243
(append (default-value 'minor-mode-alist )
1295
1244
'((haskell-doc-mode haskell-doc-minor-mode-string)))))
1296
1245
1297
-
1298
- ; ;@node Menubar Support, Haskell Doc Mode, Install as minor mode, top
1299
- ; ;@section Menubar Support
1300
-
1301
1246
; ; a dummy definition needed for XEmacs (I know, it's horrible :-(
1302
1247
1303
- ; ;@cindex haskell-doc-install-keymap
1304
1248
1305
1249
(defvar haskell-doc-keymap
1306
1250
(let ((map (make-sparse-keymap )))
@@ -1344,11 +1288,6 @@ URL is the URL of the online doc."
1344
1288
(local-set-key [(control shift meta mouse-3)]
1345
1289
'haskell-doc-ask-mouse-for-type ))
1346
1290
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
1352
1291
1353
1292
(defvar haskell-doc-timer nil )
1354
1293
(defvar haskell-doc-buffers nil )
@@ -1411,61 +1350,46 @@ See variable docstring."
1411
1350
(>= (prefix-numeric-value , prefix ) 0 )
1412
1351
(not , id ))) )
1413
1352
1414
- ; ;@cindex haskell-doc-show-global-types
1415
1353
(defun haskell-doc-show-global-types (&optional prefix )
1416
1354
" Turn on global types information in `haskell-doc-mode' ."
1417
1355
(interactive " P" )
1418
1356
(haskell-doc-toggle-var haskell-doc-show-global-types prefix)
1419
1357
(if haskell-doc-show-global-types
1420
1358
(haskell-doc-make-global-fct-index)))
1421
1359
1422
- ; ;@cindex haskell-doc-show-reserved
1423
1360
(defun haskell-doc-show-reserved (&optional prefix )
1424
1361
" Toggle the automatic display of a doc string for reserved ids."
1425
1362
(interactive " P" )
1426
1363
(haskell-doc-toggle-var haskell-doc-show-reserved prefix))
1427
1364
1428
- ; ;@cindex haskell-doc-show-prelude
1429
1365
(defun haskell-doc-show-prelude (&optional prefix )
1430
1366
" Toggle the automatic display of a doc string for reserved ids."
1431
1367
(interactive " P" )
1432
1368
(haskell-doc-toggle-var haskell-doc-show-prelude prefix))
1433
1369
1434
- ; ;@cindex haskell-doc-show-strategy
1435
1370
(defun haskell-doc-show-strategy (&optional prefix )
1436
1371
" Toggle the automatic display of a doc string for strategy ids."
1437
1372
(interactive " P" )
1438
1373
(haskell-doc-toggle-var haskell-doc-show-strategy prefix))
1439
1374
1440
- ; ;@cindex haskell-doc-show-user-defined
1441
1375
(defun haskell-doc-show-user-defined (&optional prefix )
1442
1376
" Toggle the automatic display of a doc string for user defined ids."
1443
1377
(interactive " P" )
1444
1378
(haskell-doc-toggle-var haskell-doc-show-user-defined prefix))
1445
1379
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
1450
1380
1451
1381
;;;### autoload
1452
1382
(defalias 'turn-on-haskell-doc-mode 'haskell-doc-mode )
1453
1383
1454
1384
;;;### autoload
1455
1385
(defalias 'turn-on-haskell-doc 'haskell-doc-mode )
1456
1386
1457
- ; ;@cindex turn-off-haskell-doc-mode
1458
1387
(defalias 'turn-off-haskell-doc-mode 'turn-off-haskell-doc )
1459
1388
1460
1389
(defun turn-off-haskell-doc ()
1461
1390
" Unequivocally turn off `haskell-doc-mode' (which see)."
1462
1391
(haskell-doc-mode 0 ))
1463
1392
1464
- ; ;@node Check, Top level function, Switch it on or off, top
1465
- ; ;@section Check
1466
-
1467
- ; ;@cindex haskell-doc-check-active
1468
-
1469
1393
(defun haskell-doc-check-active ()
1470
1394
" Check whether the print function is hooked in.
1471
1395
Should be the same as the value of `haskell-doc-mode' but alas currently it
@@ -1479,10 +1403,7 @@ is not."
1479
1403
(substitute-command-keys
1480
1404
" haskell-doc is not ACTIVE \( Use \\ [haskell-doc-mode] to turn it on\) " ))))
1481
1405
1482
- ; ;@node Top level function, Mouse interface, Check, top
1483
- ; ;@section Top level function
1484
1406
1485
- ; ;@cindex haskell-doc-mode-print-current-symbol-info
1486
1407
; ; This is the function hooked into the elisp command engine
1487
1408
(defun haskell-doc-mode-print-current-symbol-info ()
1488
1409
" Print the type of the symbol under the cursor.
@@ -1519,10 +1440,7 @@ Meant for `eldoc-documentation-function'."
1519
1440
(unless (symbolp msg) msg)))
1520
1441
1521
1442
1522
- ; ;@node Mouse interface, Print fctsym, Top level function, top
1523
- ; ;@section Mouse interface for interactive query
1524
1443
1525
- ; ;@cindex haskell-doc-ask-mouse-for-type
1526
1444
(defun haskell-doc-ask-mouse-for-type (event )
1527
1445
" Read the identifier under the mouse and echo its type.
1528
1446
This uses the same underlying function `haskell-doc-show-type' as the hooked
@@ -1533,22 +1451,6 @@ function. Only the user interface is different."
1533
1451
(goto-char (posn-point (event-end event)))
1534
1452
(haskell-doc-show-type )))
1535
1453
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
-
1552
1454
(defun haskell-doc-in-code-p ()
1553
1455
(not (or (and (eq haskell-literate 'bird )
1554
1456
; ; Copied from haskell-indent-bolp.
@@ -1769,12 +1671,9 @@ the haskell-doc database."
1769
1671
; ; (and (symbolp sym)
1770
1672
; ; sym)))
1771
1673
1772
- ; ;@node Aux, Global fct type, Show type, Print fctsym
1773
- ; ;@subsection Aux
1774
1674
1775
1675
; ; ToDo: handle open brackets to decide if it's a wrapped type
1776
1676
1777
- ; ;@cindex haskell-doc-grab-line
1778
1677
(defun haskell-doc-grab-line (fct-and-pos )
1779
1678
" Get the type of an \( FCT POSITION\) pair from the current buffer."
1780
1679
; ; (if (null fct-and-pos)
@@ -1797,7 +1696,6 @@ the haskell-doc database."
1797
1696
str)))))
1798
1697
; ; (concat (car fct-and-pos) "::" (haskell-doc-string-nub-ws str))))
1799
1698
1800
- ; ;@cindex haskell-doc-wrapped-type-p
1801
1699
(defun haskell-doc-wrapped-type-p ()
1802
1700
" Check whether the type under the cursor is wrapped over several lines.
1803
1701
The cursor must be at the end of a line, which contains the type.
@@ -1843,7 +1741,6 @@ ToDo: Check for matching parenthesis!."
1843
1741
(setq res t ))))))
1844
1742
res)))
1845
1743
1846
- ; ;@cindex haskell-doc-grab
1847
1744
(defun haskell-doc-grab ()
1848
1745
" Return the text from point to the end of the line, chopping off comments.
1849
1746
Leaves point at end of line."
@@ -1853,7 +1750,6 @@ Leaves point at end of line."
1853
1750
(substring str 0 (match-beginning 0 ))
1854
1751
str)))
1855
1752
1856
- ; ;@cindex haskell-doc-string-nub-ws
1857
1753
(defun haskell-doc-string-nub-ws (str )
1858
1754
" Replace all sequences of whitespace in STR by just one space.
1859
1755
ToDo: Also eliminate leading and trailing whitespace."
@@ -1879,15 +1775,13 @@ ToDo: Also eliminate leading and trailing whitespace."
1879
1775
; ; (setq i (1+ i))))
1880
1776
; ; res))
1881
1777
1882
- ; ;@cindex haskell-doc-chop-off-context
1883
1778
(defun haskell-doc-chop-off-context (str )
1884
1779
" Eliminate the context in a type represented by the string STR."
1885
1780
(let ((i (string-match " =>" str)) )
1886
1781
(if (null i)
1887
1782
str
1888
1783
(substring str (+ i 2 )))))
1889
1784
1890
- ; ;@cindex haskell-doc-get-imenu-info
1891
1785
(defun haskell-doc-get-imenu-info (obj kind )
1892
1786
" Return a string describing OBJ of KIND \( Variables, Types, Data\) ."
1893
1787
(cond
@@ -1900,14 +1794,10 @@ ToDo: Also eliminate leading and trailing whitespace."
1900
1794
(t ; ; (error "Cannot get local functions in %s mode, sorry" major-mode)))
1901
1795
nil )))
1902
1796
1903
- ; ;@node Global fct type, Local fct type, Aux, Print fctsym
1904
- ; ;@subsection Global fct type
1905
-
1906
1797
; ; ToDo:
1907
1798
; ; - modular way of defining a mapping of module name to file
1908
1799
; ; - use a path to search for file (not just current directory)
1909
1800
1910
- ; ;@cindex haskell-doc-imported-list
1911
1801
1912
1802
(defun haskell-doc-imported-list ()
1913
1803
" Return a list of the imported modules in current buffer."
@@ -1929,8 +1819,6 @@ ToDo: Also eliminate leading and trailing whitespace."
1929
1819
1930
1820
; ; ToDo: generalise this to "Types" etc (not just "Variables")
1931
1821
1932
- ; ;@cindex haskell-doc-rescan-files
1933
-
1934
1822
(defun haskell-doc-rescan-files (filelist )
1935
1823
" Do an `imenu' rescan on every file in FILELIST and return the fct-list.
1936
1824
This function switches to and potentially loads many buffers."
@@ -1944,8 +1832,6 @@ This function switches to and potentially loads many buffers."
1944
1832
(cdr (assoc " Variables" imenu--index-alist)))))
1945
1833
filelist)))
1946
1834
1947
- ; ;@cindex haskell-doc-make-global-fct-index
1948
-
1949
1835
(defun haskell-doc-make-global-fct-index ()
1950
1836
" Scan imported files for types of global fcts and update `haskell-doc-index' ."
1951
1837
(interactive )
@@ -1954,8 +1840,6 @@ This function switches to and potentially loads many buffers."
1954
1840
1955
1841
; ; ToDo: use a separate munge-type function to format type concisely
1956
1842
1957
- ; ;@cindex haskell-doc-get-global-fct-type
1958
-
1959
1843
(defun haskell-doc-get-global-fct-type (&optional sym )
1960
1844
" Get type for function symbol SYM by examining `haskell-doc-index' ."
1961
1845
(interactive ) ; "fName of outer `include' file: \nsFct:")
@@ -1984,11 +1868,6 @@ This function switches to and potentially loads many buffers."
1984
1868
(setq fal (cdr fal))))
1985
1869
res))) ; (message res)) )
1986
1870
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
-
1992
1871
(defun haskell-doc-get-and-format-fct-type (fn )
1993
1872
" Get the type and kind of FN by checking local and global functions."
1994
1873
(save-excursion
@@ -2012,48 +1891,6 @@ This function switches to and potentially loads many buffers."
2012
1891
; ; return the result
2013
1892
doc ))))
2014
1893
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
-
2057
1894
(provide 'haskell-doc )
2058
1895
2059
1896
; ;; haskell-doc.el ends here
0 commit comments