about photos bookshelf portfolio blog home
Begin main content

Doing autosys / autorep searches in an emacs buffer

I'm going to need to start an emacs code page - It's actually quite easy once you get the hang of lisp. I'm surprised it took me so long to realise that if you think like TCL then you're half way there!

(defun arep (arep-job)
  "Lookup a JOB with autorep"
  (interactive "sJob: ")
  (setq arep-query (concat "%" arep-job "%"))
  (setq arep-buffer-name (concat "*autorep " arep-query "*"))
  (pop-to-buffer arep-buffer-name)
  (setq buffer-read-only nil)
  (erase-buffer)

  (call-process "autorep" nil arep-buffer-name t "-j" arep-query)

  (highlight-regexp "__+" 'hi-red-b)

  (call-process "autorep" nil arep-buffer-name t "-j" arep-query "-q")

  (highlight-regexp "----+" 'hi-red-b)
  (highlight-regexp "^ *[^#: ]+:" 'font-lock-builtin-face)
  (highlight-regexp "#.*$" 'font-lock-comment-face)
  (goto-line 1)
  (setq buffer-read-only t)
  (set-buffer-modified-p nil)
)
Update: If you like the above, you'll love jil-mode.el - I should be able to replace the bodgy highlight-regexp with it. I had to make the following change to correctly highlight lines preceded with spaces:
(defconst jil-font-lock-keywords
  '(("^[ \t]*\\(\\(\\sw\\|\\s_\\)+\\)\\>:" (1 font-lock-constant-face))
    ("<\\([^>\t ]+\\)\\([\t ]*\\([^=>]+\\)=\\([^>\t ]+\\)\\)*>"
     (1 font-lock-builtin-face)
     (3 font-lock-type-face nil t)
     (4 font-lock-variable-name-face nil t))
    ("\\<\\(SUCCESS\\|FAIL\\|AND\\|EXITCODE\\)\\>" (1 font-lock-function-name-face)))
  "Additional expressions to highlight in Assembler mode.")

12:54 PM, 13 Feb 2006 by Mark Aufflick Permalink | Comments (0)

Search ruby docs (ri) in emacs

It's far from perfect, but it's a start and it applies ansi colors. My emacs lisp is pretty bad, so please feel free to provide enhancements.

Note one MAJOR bug is that if you have a buffer called *shell* it will switch there instead of your docs (so rename your shell buffers to something else). What I really need to do is figure out how to use ansi-color.el outside the interactive shell.

(defun ri (ruby-class-name)
  "Lookup a class in ri and put it into a buffer"
  (interactive "sClass: ")
  (let* ((explicit-shell-file-name "ri")
         (explicit-ri-args '("-T" "-f" "ansi"))
         (rishell-buffer-name (concat "*ri " ruby-class-name "*")))
    (comint-check-proc rishell-buffer-name) ; see shell.el
    (if (not (get-buffer rishell-buffer-name))
        (progn
          (setq ansi-color-for-comint-mode t)
          (add-to-list 'explicit-ri-args ruby-class-name)
          (shell)
          (rename-buffer rishell-buffer-name)
          ))
    (pop-to-buffer (get-buffer rishell-buffer-name))
    (setq buffer-read-only t)
    (setq buffer-modified-p nil)
    (goto-line '1)
    ))

01:45 AM, 13 Feb 2006 by Mark Aufflick Permalink | Comments (0)

XML

Blog Categories

software (4)
  ..heads up 'tunes (4)

Notifications

Icon of Envelope Request notifications

Syndication Feed

XML

Recent Comments

  1. Mark Aufflick: all good ideas
  2. Unregistered Visitor: Excellent!
  3. Mark Aufflick: Hey thanks
  4. Unregistered Visitor: Fantastic entry
  5. Mark Aufflick: Bah - dashboard widgets
  6. Unregistered Visitor: Nice
  7. Mark Aufflick: elegant maths (as opposed to elegant rabbit)
  8. Unregistered Visitor: Does that really matter?
  9. Mark Aufflick: Inspiration
  10. Unregistered Visitor: Perhaps...