Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

windows, elisp function to call batch file, shell-command, Whitaker's words

26 views
Skip to first unread message

Hugh Lawson

unread,
Dec 2, 2016, 8:49:19 AM12/2/16
to
The problem is that William Whitaker's Words program returns an error when I try to call it with this setup, in Windows 10. I have a Latin text in a buffer. I put the cursor on a Latin word, and strike F12. The elisp function calls the latin.bat bath file, which calls the words latin dictionary program. I think something is wrong either with my elisp function or my batch file.

The following error is displayed:

=>Raised END_ERROR, although in STANDARD_INPUT
^Z is inappropriate keyboard input, WORDS should be terminated with a blank line
Giving up!

In .emacs file:

(defun whitaker-lookup ()
"Lookup Latin word at point in Whitaker's words"
(interactive )
(shell-command (concat "C:\latin " (thing-at-point 'word))))
;;C:\latin is a batch file
(global-set-key (kbd "<f12>") 'whitaker-lookup)


Here is the batch file, latin.bat

cd c:\WORDS
words


The same error occurs if I issue these commands:

m-x shell-command
latin

However, if I go into the shell mode buffer I can make things work:

mx-shell

c:\> cd c:\words
c:\words> words
;;calls the words program with no error
c:\words> latin
;; calls the batch file which calls the words program, successfully.

Hugh Lawson

unread,
Dec 2, 2016, 10:03:13 AM12/2/16
to
On Friday, December 2, 2016 at 8:49:19 AM UTC-5, Hugh Lawson wrote:
> The problem is that William Whitaker's Words program returns an error when I try to call it with this setup, in Windows 10. I have a Latin text in a buffer. I put the cursor on a Latin word, and strike F12. The elisp function calls the latin.bat bath file, which calls the words latin dictionary program. I think something is wrong either with my elisp function or my batch file.

[snip ]
> Here is the batch file, latin.bat
>
> cd c:\WORDS
> words

I found the problem in my batch file, which I revised as follows:
@Echo off
cd c:\WORDS
words.exe %1


B. T. Raven

unread,
Dec 2, 2016, 12:04:13 PM12/2/16
to
Yes, the batch file needs to be setup to accept argument(s). But you
don't really need the batch file if you hardcode the path info into the
elisp function:

(defun wwwd ()
"Lookup Latin word at point with William Whitaker's Words program"
(interactive )
(cd "c:/wwwd") ;; where I unzipped everything
(shell-command (concat "wwwd " (thing-at-point 'sentence))) ;; renamed
word.exe to wwwd.exe
(cd "c:/mydocu~1")) ;; reset current directory for emacs

(global-set-key (kbd "<f12>") 'wwwd)

To use the 'sentence "thing" instead of the 'word "thing" you might have
to mess with these settings:

'(sentence-end "[.?!][]\"')}]*\\($\\| $\\| \\| \\)[
]*")
'(sentence-end-double-space nil)

or else just enter a series of space-separated Latin forms on the same
line. With the following (all punctuation removed), the programm parsed
all tokens up to and including the words "bonorum omnium," most of them
correctly.

Quo usque tandem abutere Catilina, patientia nostra quam diu etiam furor
iste tuus nos eludet quem ad finem sese effrenata iactabit audacia
Nihilne te nocturnum praesidium Palati nihil urbis vigiliae nihil timor
populi nihil concursus bonorum omnium nihil hic munitissimus habendi
senatus locus nihil horum ora voltusque moverunt Patere tua consilia non
sentis constrictam iam horum omnium scientia teneri coniurationem tuam
non vides

So there is a limit to the number a arguments that the program will
accept, even though it's written in Ada.

Ed


Hugh Lawson

unread,
Dec 18, 2016, 9:41:25 PM12/18/16
to
On Friday, December 2, 2016 at 12:04:13 PM UTC-5, B. T. Raven wrote:

[big snip]
Ed, that is extremely impressive. It will take me hours of study to figure that out. Many thanks. Hugh
0 new messages