Summary

I demonstrate a bit of automation used for hdc within Pen.el.

Demos

From emacs, spawn and run hdc, and automatically run appropriate command

Also, open the source code in vim.

Running the glossary system

This demonstrates that the glossary can generate buttons over any TUI application, so it’s very handy when exploring documentation through a web browser or a CLI.

Code

hdc wrapper

script
http://github.com/semiosis/pen.el/blob/master/scripts/container/hdc
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
export TTY

export EDITOR=sps-v

if ! inside-docker-p; then
    pen sh hdc "$@"
    exit "$?"
fi

if ! inside-tmux-p; then
    in-tm hdc "$@"
    exit "$?"
fi

thing="$1"

if test -n "$thing"; then
    CMD="$(cmd "$@")"
    : ${CMD:="$(cmd "$@")"}

    pen-x -allowtm -sh /root/.cabal/bin/hdc -e ">" -s "$thing" -c m -i
else
    eval "/root/.cabal/bin/hdc $CMD"
fi

elisp

pen-x generates tcl/expect code.

pen-x
http://github.com/semiosis/pen.el/blob/master/scripts/pen-x
pen-haskell.el
http://github.com/semiosis/pen.el/blob/master/src/pen-haskell.el
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(defun haskell-hdc-thing (thing)
  (interactive (list (pen-thing-at-point)))
  ;; (pen-zrepl (pen-cmd "hdc" thing))

  ;; (pen-e-spv 'haskell-show-hdc-readme)

  (if (string-match "^[^a-zA-Z]+$" thing)
      (setq thing (concat "(" thing ")")))

  (let ((parts (s-split "\\." thing)))
    (if (> (length parts) 1)
        (let ((last (-last-item parts)))
          (if (pen-re-sensitive (string-match "^[a-z]" last))
              (let ((module (s-join "." (-drop-last 1 parts))))
                ;; the last part is a function
                (pen-sps (pen-cmd "pen-x" "-allowtm" "-sh" "hdc" "-e" ">" "-s" thing "-c" "m" "-e" "search: " "-e" ">" "-sl" "0.1"
                                  "-s" (concat ":src " thing)
                                  ;; "-s" (concat ":src " last)
                                  ;; "-s" (concat ":mi " module)
                                  "-c" "m"
                                  "-i")))
            ;; the last part is just part of the module
            (pen-sps (pen-cmd "pen-x" "-allowtm" "-sh" "hdc" "-e" ">" "-s" thing "-c" "m" "-e" "search: " "-e" ">" "-sl" "0.1"
                              "-s" (concat ":md " thing)
                              "-c" "m"
                              "-i"))))
      (if (pen-re-sensitive (not (string-match "^[A-Z]" thing)))
          (pen-sps (pen-cmd "pen-x" "-allowtm" "-sh" "hdc" "-e" ">" "-s" thing "-c" "m" "-e" "search: " "-e" ">" "-sl" "0.1"
                            "-s" (concat ":src " thing)
                            "-c" "m"
                            "-i"))
        (pen-sps (pen-cmd "pen-x" "-allowtm" "-sh" "hdc" "-e" ">" "-s" thing "-c" "m" "-e" "search: " "-e" ">" "-sl" "0.1"
                          "-s" (concat ":md " thing)
                          "-c" "m"
                          "-i"))))))