[OS X Emacs] Re: How to call "call-process"

Pete Siemsen siemsen at ucar.edu
Wed May 5 02:10:48 EDT 2010


Ok, I RTFM'd and solved my problems. I came up with this:

(defun call-PetesLookup ()
  "Execute PetesLookup, feeding it the current selected region as a command-line argument."
  (interactive)
  (progn
    (setq searchterm (buffer-substring (point) (mark)))
    (call-process "/Users/siemsen/Applications/PetesLookup.app/Contents/MacOS/PetesLookup" nil nil nil searchterm)
  )
)
(define-key osx-key-mode-map (kbd "A-&") 'call-PetesLookup)

I'm certainly no Elisp wizard, so this may not be optimal, but it works.

Thanks!

-- Pete


On May 4, 2010, at 11:46 AM, siemsen at ucar.edu wrote:

> In Aquamacs 2-preview6, I have some minor problems executing an external program.  The problems are not Aquamacs issues, they come from my lack of understanding of Emacs Lisp.
> 
> I have a program named PetesLookup that looks up words in a dictionary (it's more than that, but imagine it's a simple dictionary).  The program takes one string argument on the command line and displays a Cocoa window containing the "definition" of the string.  Then I click an "OK" button or hit RETURN to dismiss the window and terminate the program.
> 
> I want to execute the program from Aquamacs.  I want to be able to highlight a word in an Aquamacs frame, hit a special key, and see a window pop up containing the definition of the word.  I defined this in my startup file:
> 
>   (define-key osx-key-mode-map (kbd "A-&") (call-process "/Users/siemsen/Applications/PetesLookup.app/Contents/MacOS/PetesLookup" nil nil nil "test"))
> 
> This almost works, but
> 
> Problem 1:
> The PetesLookup program is executed every time I start Aquamacs.  I obviously don't want it to execute when I start Aquamacs, but whenever I hit A-&.
> 
> Problem 2:
> Unrelated to problem 1, instead of "test", I want to feed the program the currently highlighted string in the edit buffer.  What is the syntax to pass in the string that I've highlighted with the mouse?
> 
> -- Pete
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-emacs/attachments/20100505/46fc5db6/attachment.html>


More information about the MacOSX-Emacs mailing list