help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shortcut to compile "highlighted Text/Tag"


From: Rami A
Subject: Re: Shortcut to compile "highlighted Text/Tag"
Date: Fri, 19 Apr 2013 16:25:36 -0700 (PDT)
User-agent: G2/1.0

Dan, 
I was actually able to copy/paste the whole gid.el code into my dotemacs file.
It did actually work :)
It figures out the pattern the cursor is at and applies the compile gid command 
on it.

The only this I am still trying to solve is skipping the confirmation question 
so I don't have to press RET every time I search for a symbol.

So now when I press F4 I get:
Run gid (with args): PATERN

I need to confirm.

Do you know of a way I could skip the confirmation?

This is the code I copied:

;;;; gid.el -- run gid using compilation mode.

(require 'compile)
;;(require 'elisp-utils)
(provide 'gid)

(defvar gid-command "gid" "The command run by the gid function.")

(defun gid (args)
  "Run gid, with user-specified ARGS, and collect output in a buffer.
While gid runs asynchronously, you can use the \\[next-error] command to
find the text that gid hits refer to. The command actually run is
defined by the gid-command variable."
  (interactive (list (read-input
     (concat "Run " gid-command " (with args): ") (word-around-point))))
    ;; Preserve the present compile-command
  (let (compile-command
(compilation-buffer-name-function
(lambda (mode) (concat "*gid " args "*"))))
    ;; For portability between v18 & v19, use compile rather than 
compile-internal
    (compile (concat gid-command " " args))))

(defun word-around-point ()
  "Return the word around the point as a string."
  (save-excursion
    (if (not (eobp))
(forward-char 1))
    (forward-word -1)
    (forward-word 1)
    (forward-sexp -1)
    (let ((beg (point)))
      (forward-sexp 1)
      (buffer-substring beg (point)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]