41
41
(haskell-process-start (haskell-interactive-session)))
42
42
43
43
(defun haskell-process-start (session )
44
- " Start the inferior Haskell process."
44
+ " Start the inferior Haskell process with a given SESSION.
45
+ You can create new session using function `haskell-session-make' ."
45
46
(let ((existing-process (get-process (haskell-session-name (haskell-interactive-session)))))
46
47
(when (processp existing-process)
47
48
(haskell-interactive-mode-echo session " Restarting process ..." )
77
78
process))
78
79
79
80
(defun haskell-process-send-startup (process )
80
- " Send the necessary start messages."
81
+ " Send the necessary start messages to haskell PROCESS ."
81
82
(haskell-process-queue-command
82
83
process
83
84
(make-haskell-command
@@ -136,16 +137,18 @@ If I break, you can:
136
137
(interrupt-process (haskell-process-process (haskell-commands-process))))
137
138
138
139
(defun haskell-process-reload-with-fbytecode (process module-buffer )
139
- " Reload FILE-NAME with -fbyte-code set, and then restore -fobject-code."
140
+ " Query a PROCESS to reload MODULE-BUFFER with -fbyte-code set.
141
+ Restores -fobject-code after reload finished.
142
+ MODULE-BUFFER is the actual Emacs buffer of the module being loaded."
140
143
(haskell-process-queue-without-filters process " :set -fbyte-code" )
141
144
(haskell-process-touch-buffer process module-buffer)
142
145
(haskell-process-queue-without-filters process " :reload" )
143
146
(haskell-process-queue-without-filters process " :set -fobject-code" ))
144
147
145
148
;;;### autoload
146
149
(defun haskell-process-touch-buffer (process buffer )
147
- " Updates mtime on the file for BUFFER by queing a touch on
148
- PROCESS ."
150
+ " Query PROCESS to `:!touch` BUFFER's file.
151
+ Use to update mtime on BUFFER's file ."
149
152
(interactive )
150
153
(haskell-process-queue-command
151
154
process
@@ -166,7 +169,8 @@ PROCESS."
166
169
(defvar url-http-end-of-headers )
167
170
168
171
(defun haskell-process-hayoo-ident (ident )
169
- " Hayoo for IDENT, returns a list of modules asyncronously through CALLBACK."
172
+ ; ; FIXME Obsolete doc string, CALLBACK is not used.
173
+ " Hayoo for IDENT, return a list of modules asyncronously through CALLBACK."
170
174
; ; We need a real/simulated closure, because otherwise these
171
175
; ; variables will be unbound when the url-retrieve callback is
172
176
; ; called.
@@ -189,7 +193,7 @@ PROCESS."
189
193
(warn " HTTP error %s fetching %s" url-http-response-status url)))))
190
194
191
195
(defun haskell-process-hoogle-ident (ident )
192
- " Hoogle for IDENT, returns a list of modules."
196
+ " Hoogle for IDENT, return a list of modules."
193
197
(with-temp-buffer
194
198
(let ((hoogle-error (call-process " hoogle" nil t nil " search" " --exact" ident)))
195
199
(goto-char (point-min ))
@@ -203,7 +207,7 @@ PROCESS."
203
207
" \n " ))))))
204
208
205
209
(defun haskell-process-haskell-docs-ident (ident )
206
- " Search with haskell-docs for IDENT, returns a list of modules."
210
+ " Search with haskell-docs for IDENT, return a list of modules."
207
211
(cl-remove-if-not
208
212
(lambda (a ) (string-match " ^[[:upper:]][[:alnum:]_'.]+$" a))
209
213
(split-string
@@ -218,8 +222,7 @@ PROCESS."
218
222
" \n " )))
219
223
220
224
(defun haskell-process-import-modules (process modules )
221
- " Import `modules' with :m +, and send any import statements
222
- from `module-buffer' ."
225
+ " Query PROCESS `:m +' command to import MODULES."
223
226
(when haskell-process-auto-import-loaded-modules
224
227
(haskell-process-queue-command
225
228
process
@@ -232,14 +235,14 @@ from `module-buffer'."
232
235
233
236
;;;### autoload
234
237
(defun haskell-describe (ident )
235
- " Describe the given identifier."
238
+ " Describe the given identifier IDENT ."
236
239
(interactive (list (read-from-minibuffer " Describe identifier: "
237
240
(haskell-ident-at-point))))
238
241
(let ((results (read (shell-command-to-string
239
242
(concat " haskell-docs --sexp "
240
243
ident)))))
241
244
(help-setup-xref (list #'haskell-describe ident)
242
- (called-interactively-p 'interactive ))
245
+ (called-interactively-p 'interactive ))
243
246
(save-excursion
244
247
(with-help-window (help-buffer )
245
248
(with-current-buffer (help-buffer )
@@ -269,9 +272,10 @@ from `module-buffer'."
269
272
270
273
;;;### autoload
271
274
(defun haskell-rgrep (&optional prompt )
272
- " Grep the effective project for the symbol at point. Very
273
- useful for codebase navigation. Prompts for an arbitrary regexp
274
- given a prefix arg."
275
+ " Grep the effective project for the symbol at point.
276
+ Very useful for codebase navigation.
277
+
278
+ Prompts for an arbitrary regexp given a prefix arg PROMPT."
275
279
(interactive " P" )
276
280
(let ((sym (if prompt
277
281
(read-from-minibuffer " Look for: " )
@@ -310,7 +314,11 @@ If PROMPT-VALUE is non-nil, request identifier via mini-buffer."
310
314
311
315
;;;### autoload
312
316
(defun haskell-process-do-type (&optional insert-value )
313
- " Print the type of the given expression."
317
+ ; ; FIXME insert value functionallity seems to be missing.
318
+ " Print the type of the given expression.
319
+
320
+ Given INSERT-VALUE prefix indicates that result type signature
321
+ should be inserted."
314
322
(interactive " P" )
315
323
(if insert-value
316
324
(haskell-process-insert-type)
@@ -334,8 +342,10 @@ If PROMPT-VALUE is non-nil, request identifier via mini-buffer."
334
342
335
343
;;;### autoload
336
344
(defun haskell-mode-jump-to-def-or-tag (&optional next-p )
337
- " Jump to the definition (by consulting GHCi), or (fallback)
338
- jump to the tag.
345
+ ; ; FIXME NEXT-P arg is not used
346
+ " Jump to the definition.
347
+ Jump to definition of identifier at point by consulting GHCi, or
348
+ tag table as fallback.
339
349
340
350
Remember: If GHCi is busy doing something, this will delay, but
341
351
it will always be accurate, in contrast to tags, which always
@@ -359,16 +369,15 @@ position with `xref-pop-marker-stack'."
359
369
360
370
;;;### autoload
361
371
(defun haskell-mode-goto-loc ()
362
- " Go to the location of the thing at point. Requires the :loc-at
363
- command from GHCi."
372
+ " Go to the location of the thing at point.
373
+ Requires the :loc-at command from GHCi."
364
374
(interactive )
365
375
(let ((loc (haskell-mode-loc-at)))
366
376
(when loc
367
377
(haskell-mode-goto-span loc))))
368
378
369
379
(defun haskell-mode-goto-span (span )
370
- " Jump to the span, whatever file and line and column it needs
371
- to to get there."
380
+ " Jump to the SPAN, whatever file and line and column it needs to get there."
372
381
(xref-push-marker-stack )
373
382
(find-file (expand-file-name (plist-get span :path )
374
383
(haskell-session-cabal-dir (haskell-interactive-session))))
@@ -377,8 +386,8 @@ to to get there."
377
386
(forward-char (plist-get span :start-col )))
378
387
379
388
(defun haskell-process-insert-type ()
380
- " Get the identifer at the point and insert its type, if
381
- possible, using GHCi's :type."
389
+ " Get the identifer at the point and insert its type.
390
+ Use GHCi's :type if it's possible ."
382
391
(let ((ident (haskell-ident-at-point)))
383
392
(when ident
384
393
(let ((process (haskell-interactive-process))
@@ -405,17 +414,17 @@ possible, using GHCi's :type."
405
414
(insert (format " %s \n " (replace-regexp-in-string " \n $" " " response)))))))))))))
406
415
407
416
(defun haskell-mode-find-def (ident )
408
- " Find definition location of identifier. Uses the GHCi process
409
- to find the location. Returns `nil' if it can't find the
410
- identifier or the identifier isn't a string.
417
+ ; ; TODO Check if it possible to exploit `haskell-process-do-info'
418
+ " Find definition location of identifier IDENT.
419
+ Uses the GHCi process to find the location. Returns nil if it
420
+ can't find the identifier or the identifier isn't a string.
411
421
412
422
Returns:
413
423
414
424
(library <package> <module>)
415
425
(file <path> <line> <col>)
416
426
(module <name>)
417
- nil
418
- "
427
+ nil"
419
428
(when (stringp ident)
420
429
(let ((reply (haskell-process-queue-sync-request
421
430
(haskell-interactive-process)
@@ -447,15 +456,15 @@ Returns:
447
456
448
457
;;;### autoload
449
458
(defun haskell-mode-jump-to-def (ident )
450
- " Jump to definition of identifier at point."
459
+ " Jump to definition of identifier IDENT at point."
451
460
(interactive (list (haskell-ident-at-point)))
452
461
(let ((loc (haskell-mode-find-def ident)))
453
462
(when loc
454
463
(haskell-mode-handle-generic-loc loc))))
455
464
456
465
(defun haskell-mode-handle-generic-loc (loc )
457
- " Either jump to or display a generic location. Either a file or
458
- a library."
466
+ " Either jump to or echo a generic location LOC.
467
+ Either a file or a library."
459
468
(cl-case (car loc)
460
469
(file (haskell-mode-jump-to-loc (cdr loc)))
461
470
(library (message " Defined in `%s' (%s ). "
@@ -465,8 +474,8 @@ a library."
465
474
(elt loc 1 )))))
466
475
467
476
(defun haskell-mode-loc-at ()
468
- " Get the location at point. Requires the :loc-at command from
469
- GHCi."
477
+ " Get the location at point.
478
+ Requires the :loc-at command from GHCi."
470
479
(let ((pos (or (when (region-active-p )
471
480
(cons (region-beginning )
472
481
(region-end )))
@@ -503,6 +512,7 @@ GHCi."
503
512
504
513
;;;### autoload
505
514
(defun haskell-process-cd (&optional not-interactive )
515
+ ; ; FIXME optional arg is not used
506
516
" Change directory."
507
517
(interactive )
508
518
(let* ((session (haskell-interactive-session))
@@ -515,7 +525,10 @@ GHCi."
515
525
dir)))
516
526
517
527
(defun haskell-session-pwd (session &optional change )
518
- " Prompt for the current directory."
528
+ " Prompt for the current directory.
529
+ Return current working directory for SESSION.
530
+ Optional CHANGE argument makes user to choose new working directory for SESSION.
531
+ In this case new working directory path will be returned."
519
532
(or (unless change
520
533
(haskell-session-get session 'current-dir ))
521
534
(progn (haskell-session-set-current-dir
@@ -530,7 +543,8 @@ GHCi."
530
543
(haskell-session-get session 'current-dir ))))
531
544
532
545
(defun haskell-process-change-dir (session process dir )
533
- " Change the directory of the current process."
546
+ " Change SESSION's current directory.
547
+ Query PROCESS to `:cd` to directory DIR."
534
548
(haskell-process-queue-command
535
549
process
536
550
(make-haskell-command
@@ -555,7 +569,7 @@ GHCi."
555
569
" :set -optP-include -optPdist/build/autogen/cabal_macros.h" ))
556
570
557
571
(defun haskell-process-do-try-info (sym )
558
- " Get info of `sym' and echo in the minibuffer."
572
+ " Get info of SYM and echo in the minibuffer."
559
573
(let ((process (haskell-interactive-process)))
560
574
(haskell-process-queue-command
561
575
process
@@ -573,7 +587,7 @@ GHCi."
573
587
(haskell-mode-message-line response)))))))
574
588
575
589
(defun haskell-process-do-try-type (sym )
576
- " Get type of `sym' and echo in the minibuffer."
590
+ " Get type of SYM and echo in the minibuffer."
577
591
(let ((process (haskell-interactive-process)))
578
592
(haskell-process-queue-command
579
593
process
@@ -684,7 +698,9 @@ happened since function invocation)."
684
698
685
699
;;;### autoload
686
700
(defun haskell-process-generate-tags (&optional and-then-find-this-tag )
687
- " Regenerate the TAGS table."
701
+ " Regenerate the TAGS table.
702
+ If optional AND-THEN-FIND-THIS-TAG argument is present it is used with
703
+ function `find-tag' after new table was generated."
688
704
(interactive )
689
705
(let ((process (haskell-interactive-process)))
690
706
(haskell-process-queue-command
@@ -716,9 +732,10 @@ happened since function invocation)."
716
732
(haskell-mode-message-line " Tags generated." ))))))
717
733
718
734
(defun haskell-process-add-cabal-autogen ()
719
- " Add <cabal-project-dir>/dist/build/autogen/ to the ghci search
720
- path. This allows modules such as 'Path_...', generated by cabal,
721
- to be loaded by ghci."
735
+ " Add cabal's autogen dir to the GHCi search path.
736
+ Add <cabal-project-dir>/dist/build/autogen/ to GHCi seatch path.
737
+ This allows modules such as 'Path_...', generated by cabal, to be
738
+ loaded by GHCi."
722
739
(unless (eq 'cabal-repl (haskell-process-type)) ; ; redundant with "cabal repl"
723
740
(let*
724
741
((session (haskell-interactive-session))
@@ -730,8 +747,9 @@ to be loaded by ghci."
730
747
731
748
;;;### autoload
732
749
(defun haskell-process-unignore ()
733
- " Unignore any files that were specified as being ignored by the
734
- inferior GHCi process."
750
+ " Unignore any ignored files.
751
+ Do not ignore files that were specified as being ignored by the
752
+ inferior GHCi process."
735
753
(interactive )
736
754
(let ((session (haskell-interactive-session))
737
755
(changed nil ))
@@ -756,7 +774,7 @@ to be loaded by ghci."
756
774
757
775
;;;### autoload
758
776
(defun haskell-session-change-target (target )
759
- " Set the build target for cabal repl "
777
+ " Set the build TARGET for cabal REPL. "
760
778
(interactive " sNew build target:" )
761
779
(let* ((session haskell-session)
762
780
(old-target (haskell-session-get session 'target )))
@@ -778,9 +796,9 @@ to be loaded by ghci."
778
796
(goto-char (+ column (point )))))
779
797
780
798
(defun haskell-mode-buffer-apply-command (cmd )
781
- " Execute shell command CMD with current buffer as input and
782
- replace the whole buffer with the output. If CMD fails the buffer
783
- remains unchanged."
799
+ " Execute shell command CMD with current buffer as input and output.
800
+ Use buffer as input and replace the whole buffer with the
801
+ output. If CMD fails the buffer remains unchanged."
784
802
(set-buffer-modified-p t )
785
803
(let* ((chomp (lambda (str )
786
804
(while (string-match " \\ `\n+\\|^\\s-+\\|\\s-+$\\|\n+\\' " str)
@@ -826,7 +844,7 @@ remains unchanged."
826
844
827
845
;;;### autoload
828
846
(defun haskell-mode-find-uses ()
829
- " Find uses of the identifier at point, highlight them all."
847
+ " Find use cases of the identifier at point and highlight them all."
830
848
(interactive )
831
849
(let ((spans (haskell-mode-uses-at)))
832
850
(unless (null spans)
@@ -835,7 +853,7 @@ remains unchanged."
835
853
do (haskell-mode-make-use-highlight span)))))
836
854
837
855
(defun haskell-mode-make-use-highlight (span )
838
- " Make a highlight overlay at the given span ."
856
+ " Make a highlight overlay at the given SPAN ."
839
857
(save-window-excursion
840
858
(save-excursion
841
859
(haskell-mode-goto-span span)
@@ -853,8 +871,8 @@ remains unchanged."
853
871
(point )))))))
854
872
855
873
(defun haskell-mode-uses-at ()
856
- " Get the locations of uses for the ident at point. Requires
857
- the :uses command from GHCi."
874
+ " Get the locations of use cases for the ident at point.
875
+ Requires the :uses command from GHCi."
858
876
(let ((pos (or (when (region-active-p )
859
877
(cons (region-beginning )
860
878
(region-end )))
0 commit comments