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

Add comment