Permalink
Browse files

Haskell menu mode (initial read-only version). Invoke with M-x haskel…

…l-menu.
  • Loading branch information...
1 parent d9474f8 commit 3b362768194725a3ba588ff7488eba4276d6b47b @chrisdone chrisdone committed Feb 10, 2013
Showing with 236 additions and 25 deletions.
  1. +1 −0 Makefile
  2. +131 −0 haskell-menu.el
  3. +104 −25 haskell-site-file.el
View
1 Makefile
@@ -21,6 +21,7 @@ ELFILES = \
haskell-interactive-mode.el \
haskell-package.el \
haskell-process.el \
+ haskell-menu.el \
haskell-session.el \
haskell-string.el \
ghc-core.el \
View
131 haskell-menu.el
@@ -0,0 +1,131 @@
+;;; haskell-menu.el -- A Haskell sessions menu.
+
+;; Copyright (C) 2013 Chris Done
+
+;; Author: Chris Done <chrisdone@gmail.com>
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;;; Todo:
+
+;;; Code:
+
+(require 'cl)
+
+(defcustom haskell-menu-buffer-name
+ "*haskell-menu*"
+ "The path for starting cabal-dev."
+ :group 'haskell
+ :type 'string)
+
+;;;###autoload
+(defun haskell-menu ()
+ "Launch the Haskell sessions menu."
+ (interactive)
+ (or (get-buffer haskell-menu-buffer-name)
+ (with-current-buffer (get-buffer-create haskell-menu-buffer-name)
+ (haskell-menu-mode)))
+ (switch-to-buffer-other-window (get-buffer haskell-menu-buffer-name)))
+
+(define-derived-mode haskell-menu-mode special-mode "Haskell Session Menu"
+ "Major mode for managing Haskell sessions.
+Each line describes one session.
+Letters do not insert themselves; instead, they are commands."
+ (setq buffer-read-only t)
+ (set (make-local-variable 'revert-buffer-function)
+ 'haskell-menu-revert-function)
+ (setq truncate-lines t)
+ (haskell-menu-revert-function nil t))
+
+(defun haskell-menu-revert-function (arg1 arg2)
+ "Function to refresh the display."
+ (let ((buffer-read-only nil)
+ (orig-line (line-number-at-pos))
+ (orig-col (current-column)))
+ (or (eq buffer-undo-list t)
+ (setq buffer-undo-list nil))
+ (erase-buffer)
+ (haskell-menu-insert-menu)
+ (goto-char (point-min))
+ (forward-line (1- orig-line))
+ (forward-char orig-col)))
+
+(defun haskell-menu-insert-menu ()
+ "Insert the Haskell sessions menu to the current buffer."
+ (if (null haskell-sessions)
+ (insert "No Haskell sessions.")
+ (haskell-menu-tabulate
+ (list "Name" "PID" "Time" "RSS" "Cabal directory" "Working directory" "Command")
+ (mapcar (lambda (session)
+ (let* ((process (haskell-process-process (haskell-session-process session)))
+ (id (process-id process)))
+ (list (propertize (haskell-session-name session) 'face 'buffer-menu-buffer)
+ (if (process-live-p process) (number-to-string id) "-")
+ (if (process-live-p process)
+ (format-time-string "%H:%M:%S"
+ (encode-time (caddr (assoc 'etime (process-attributes id)))
+ 0 0 0 0 0))
+ "-")
+ (if (process-live-p process)
+ (concat (number-to-string (/ (cdr (assoc 'rss (process-attributes id)))
+ 1024))
+ "MB")
+ "-")
+ (haskell-session-cabal-dir session)
+ (haskell-session-current-dir session)
+ (mapconcat 'identity (process-command process) " "))))
+ haskell-sessions))))
+
+(defun haskell-menu-tabulate (headings rows)
+ "Prints a list of lists as a formatted table to the current buffer."
+ (let* ((columns (length headings))
+ (widths (make-list columns 0)))
+ ;; Calculate column widths. This is kind of hideous.
+ (dolist (row rows)
+ (setq widths
+ (let ((list (list)))
+ (dotimes (i columns)
+ (setq list (cons (max (nth i widths)
+ (1+ (length (nth i row)))
+ (1+ (length (nth i headings))))
+ list)))
+ (reverse list))))
+ ;; Print headings.
+ (let ((heading (propertize " " 'display '(space :align-to 0))))
+ (dotimes (i columns)
+ (setq heading (concat heading
+ (format (concat "%-" (number-to-string (nth i widths)) "s")
+ (nth i headings)))))
+ (setq header-line-format heading))
+ ;; Print tabulated rows.
+ (dolist (row rows)
+ (dotimes (i columns)
+ (insert (format (concat "%-" (number-to-string (nth i widths)) "s")
+ (nth i row))))
+ (insert "\n"))))
+
+(defvar haskell-menu-mode-map
+ (let ((map (make-keymap))
+ (menu-map (make-sparse-keymap)))
+ (suppress-keymap map t)
+ menu-map))
+
+;; Local Variables:
+;; byte-compile-warnings: (not cl-functions)
+;; End:
+;;; haskell-menu.el ends here
View
129 haskell-site-file.el
@@ -1,6 +1,6 @@
;;;### (autoloads (ghc-core-mode ghc-core-create-core) "ghc-core"
-;;;;;; "ghc-core.el" (20327 38141))
+;;;;;; "ghc-core.el" (20443 5401))
;;; Generated autoloads from ghc-core.el
(autoload 'ghc-core-create-core "ghc-core" "\
@@ -18,7 +18,7 @@ Major mode for GHC Core files.
;;;***
;;;### (autoloads (haskell-align-imports) "haskell-align-imports"
-;;;;;; "haskell-align-imports.el" (20341 28472))
+;;;;;; "haskell-align-imports.el" (20443 5401))
;;; Generated autoloads from haskell-align-imports.el
(autoload 'haskell-align-imports "haskell-align-imports" "\
@@ -28,8 +28,8 @@ Align all the imports in the buffer.
;;;***
-;;;### (autoloads (haskell-c-mode) "haskell-c" "haskell-c.el" (20327
-;;;;;; 38141))
+;;;### (autoloads (haskell-c-mode) "haskell-c" "haskell-c.el" (20443
+;;;;;; 5401))
;;; Generated autoloads from haskell-c.el
(add-to-list 'auto-mode-alist '("\\.hsc\\'" . haskell-c-mode))
@@ -42,7 +42,7 @@ Major mode for Haskell FFI files.
;;;***
;;;### (autoloads (haskell-cabal-get-dir haskell-cabal-mode) "haskell-cabal"
-;;;;;; "haskell-cabal.el" (20334 23077))
+;;;;;; "haskell-cabal.el" (20743 35780))
;;; Generated autoloads from haskell-cabal.el
(add-to-list 'auto-mode-alist '("\\.cabal\\'" . haskell-cabal-mode))
@@ -61,7 +61,7 @@ Get the Cabal dir for a new project. Various ways of figuring this out,
;;;***
;;;### (autoloads (haskell-decl-scan-mode) "haskell-decl-scan" "haskell-decl-scan.el"
-;;;;;; (20327 38141))
+;;;;;; (20443 5401))
;;; Generated autoloads from haskell-decl-scan.el
(autoload 'haskell-decl-scan-mode "haskell-decl-scan" "\
@@ -111,7 +111,7 @@ Invokes `haskell-decl-scan-mode-hook'.
;;;***
;;;### (autoloads (haskell-doc-show-type haskell-doc-mode) "haskell-doc"
-;;;;;; "haskell-doc.el" (20327 38141))
+;;;;;; "haskell-doc.el" (20743 33798))
;;; Generated autoloads from haskell-doc.el
(autoload 'haskell-doc-mode "haskell-doc" "\
@@ -134,7 +134,7 @@ current buffer.
;;;***
;;;### (autoloads (haskell-indent-mode) "haskell-indent" "haskell-indent.el"
-;;;;;; (20327 38141))
+;;;;;; (20443 5401))
;;; Generated autoloads from haskell-indent.el
(autoload 'haskell-indent-mode "haskell-indent" "\
@@ -166,7 +166,7 @@ Invokes `haskell-indent-hook' if not nil.
;;;***
;;;### (autoloads (haskell-indentation-mode) "haskell-indentation"
-;;;;;; "haskell-indentation.el" (20328 13471))
+;;;;;; "haskell-indentation.el" (20743 33798))
;;; Generated autoloads from haskell-indentation.el
(autoload 'haskell-indentation-mode "haskell-indentation" "\
@@ -181,12 +181,15 @@ autofill-mode.
;;;### (autoloads (haskell-interactive-mode-echo haskell-interactive-switch
;;;;;; haskell-interactive-bring haskell-interactive-mode) "haskell-interactive-mode"
-;;;;;; "haskell-interactive-mode.el" (20338 50718))
+;;;;;; "haskell-interactive-mode.el" (20743 38828))
;;; Generated autoloads from haskell-interactive-mode.el
(autoload 'haskell-interactive-mode "haskell-interactive-mode" "\
Interactive mode for Haskell.
+Key bindings:
+\\{haskell-interactive-mode-map}
+
\(fn SESSION)" t nil)
(autoload 'haskell-interactive-bring "haskell-interactive-mode" "\
@@ -206,11 +209,22 @@ Echo a read only piece of text before the prompt.
;;;***
+;;;### (autoloads (haskell-menu) "haskell-menu" "haskell-menu.el"
+;;;;;; (20758 59167))
+;;; Generated autoloads from haskell-menu.el
+
+(autoload 'haskell-menu "haskell-menu" "\
+Launch the Haskell sessions menu.
+
+\(fn)" t nil)
+
+;;;***
+
;;;### (autoloads (haskell-hayoo haskell-hoogle literate-haskell-mode
-;;;;;; haskell-mode) "haskell-mode" "haskell-mode.el" (20341 54213))
+;;;;;; haskell-mode) "haskell-mode" "haskell-mode.el" (20754 28319))
;;; Generated autoloads from haskell-mode.el
-(add-to-list 'load-path (or (file-name-directory load-file-name) (car load-path)))
+(when load-file-name (add-to-list 'load-path (file-name-directory load-file-name)))
(autoload 'haskell-mode "haskell-mode" "\
Major mode for editing Haskell programs.
@@ -276,19 +290,19 @@ Do a Hayoo search for QUERY.
;;;***
;;;### (autoloads (haskell-move-nested) "haskell-move-nested" "haskell-move-nested.el"
-;;;;;; (20328 13471))
+;;;;;; (20443 5401))
;;; Generated autoloads from haskell-move-nested.el
(autoload 'haskell-move-nested "haskell-move-nested" "\
-Not documented
+
\(fn COLUMNS)" nil nil)
;;;***
;;;### (autoloads (haskell-navigate-imports-return haskell-navigate-imports-go
;;;;;; haskell-navigate-imports) "haskell-navigate-imports" "haskell-navigate-imports.el"
-;;;;;; (20328 13471))
+;;;;;; (20443 5401))
;;; Generated autoloads from haskell-navigate-imports.el
(autoload 'haskell-navigate-imports "haskell-navigate-imports" "\
@@ -310,15 +324,31 @@ Return to the non-import point we were at before going to the module list.
;;;***
;;;### (autoloads (haskell-process haskell-process-start haskell-process-cabal
-;;;;;; haskell-process-cabal-build haskell-process-load-file) "haskell-process"
-;;;;;; "haskell-process.el" (20340 57610))
+;;;;;; haskell-process-cabal-build haskell-process-load-or-reload
+;;;;;; haskell-process-reload-file haskell-process-load-file haskell-process-generate-tags)
+;;;;;; "haskell-process" "haskell-process.el" (20758 52795))
;;; Generated autoloads from haskell-process.el
+(autoload 'haskell-process-generate-tags "haskell-process" "\
+Regenerate the TAGS table.
+
+\(fn &optional AND-THEN-FIND-THIS-TAG)" t nil)
+
(autoload 'haskell-process-load-file "haskell-process" "\
Load the current buffer file.
\(fn)" t nil)
+(autoload 'haskell-process-reload-file "haskell-process" "\
+Re-load the current buffer file.
+
+\(fn)" t nil)
+
+(autoload 'haskell-process-load-or-reload "haskell-process" "\
+Load or reload. Universal argument toggles which.
+
+\(fn &optional TOGGLE)" t nil)
+
(autoload 'haskell-process-cabal-build "haskell-process" "\
Build the Cabal project.
@@ -342,7 +372,7 @@ Get the current process from the current session.
;;;***
;;;### (autoloads (haskell-session-process haskell-session) "haskell-session"
-;;;;;; "haskell-session.el" (20344 42487))
+;;;;;; "haskell-session.el" (20758 58606))
;;; Generated autoloads from haskell-session.el
(autoload 'haskell-session "haskell-session" "\
@@ -357,8 +387,32 @@ Get the session process.
;;;***
+;;;### (autoloads (haskell-show-parse haskell-show-parse-and-insert
+;;;;;; haskell-show-replace) "haskell-show" "haskell-show.el" (20468
+;;;;;; 38083))
+;;; Generated autoloads from haskell-show.el
+
+(autoload 'haskell-show-replace "haskell-show" "\
+Replace the given region containing a Show value with a pretty
+ printed collapsible version.
+
+\(fn START END)" nil nil)
+
+(autoload 'haskell-show-parse-and-insert "haskell-show" "\
+Parse a `string' containing a Show instance value and insert
+ it pretty printed into the current buffer.
+
+\(fn GIVEN)" nil nil)
+
+(autoload 'haskell-show-parse "haskell-show" "\
+Parse the given input into a tree.
+
+\(fn GIVEN)" nil nil)
+
+;;;***
+
;;;### (autoloads (haskell-sort-imports) "haskell-sort-imports" "haskell-sort-imports.el"
-;;;;;; (20328 13471))
+;;;;;; (20443 5401))
;;; Generated autoloads from haskell-sort-imports.el
(autoload 'haskell-sort-imports "haskell-sort-imports" "\
@@ -368,11 +422,32 @@ Sort the import list at the point.
;;;***
+;;;### (autoloads (haskell-is-prefix-of haskell-string-take haskell-trim)
+;;;;;; "haskell-string" "haskell-string.el" (20468 34407))
+;;; Generated autoloads from haskell-string.el
+
+(autoload 'haskell-trim "haskell-string" "\
+
+
+\(fn STRING)" nil nil)
+
+(autoload 'haskell-string-take "haskell-string" "\
+Take n chars from string.
+
+\(fn STRING N)" nil nil)
+
+(autoload 'haskell-is-prefix-of "haskell-string" "\
+Is x string a prefix of y string?
+
+\(fn X Y)" nil nil)
+
+;;;***
+
;;;### (autoloads (inferior-haskell-find-haddock inferior-haskell-find-definition
-;;;;;; inferior-haskell-info inferior-haskell-type inferior-haskell-send-decl
-;;;;;; inferior-haskell-load-and-run inferior-haskell-load-file
-;;;;;; switch-to-haskell) "inf-haskell" "inf-haskell.el" (20333
-;;;;;; 43796))
+;;;;;; inferior-haskell-info inferior-haskell-kind inferior-haskell-type
+;;;;;; inferior-haskell-send-decl inferior-haskell-load-and-run
+;;;;;; inferior-haskell-load-file switch-to-haskell) "inf-haskell"
+;;;;;; "inf-haskell.el" (20652 876))
;;; Generated autoloads from inf-haskell.el
(defalias 'run-haskell 'switch-to-haskell)
@@ -406,6 +481,11 @@ The returned info is cached for reuse by `haskell-doc-mode'.
\(fn EXPR &optional INSERT-VALUE)" t nil)
+(autoload 'inferior-haskell-kind "inf-haskell" "\
+Query the haskell process for the kind of the given expression.
+
+\(fn TYPE)" t nil)
+
(autoload 'inferior-haskell-info "inf-haskell" "\
Query the haskell process for the info of the given expression.
@@ -437,8 +517,7 @@ we load it.
;;;### (autoloads nil nil ("haskell-checkers.el" "haskell-font-lock.el"
;;;;;; "haskell-ghci.el" "haskell-hugs.el" "haskell-package.el"
-;;;;;; "haskell-simple-indent.el" "haskell-string.el" "init.el")
-;;;;;; (20344 42495 885853))
+;;;;;; "haskell-simple-indent.el") (20758 59176 912583))
;;;***

0 comments on commit 3b36276

Please sign in to comment.