[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cgreek:00018] A little error
- To: cgreek-emacs-mule discussion list <cgreek@xxxxxxxx>
- Subject: [cgreek:00018] A little error
- From: Robin Smith <rasmith@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 21 Jul 2000 21:45:04 -0500
- Reply-to: cgreek@xxxxxxxx
I'm afraid the version of tlg-idt.lex I just distributed may not
work reliably. The problem is that the code it generates may fail to
be evaluated properly in the works list buffer. The solution is just
to add two lines of C code: applying this patch should work:
-----------BEGIN PATCH
*** Versions/2000.07.21/tlg/tlg-idt.lex Fri Jul 21 08:20:45 2000
--- tlg/tlg-idt.lex Fri Jul 21 19:35:28 2000
***************
*** 1444,1449 ****
--- 1444,1450 ----
this_work=who->worklist;
printf("(setq tlg-author \"%s\" tlg-authorno \"%s\")\n",
who->name,who->file);
+ printf("(setq tlg-works nil)\n");
while (this_work) {
print_work(this_work->worknum);
this_work=this_work->next;
---------------END PATCH
I also have a working solution to the problem of untranslated beta
code strings in titles and author names, though I don't know how
good it is. (It may very well not work on Meadow). The solution is
to use a function tlg-translate-beta that sends strings to a process
started by emacs as a translation daemon. The process itself is a slightly
hacked version of tlg2emacs (hacked to expect its input on stdin); I
run this as 'tlgd". These functions are then added to tlg-util.el:
;; This provides a facility for translating arbitrary beta-code
;; Strings must be terminated with a newline, which will be trimmed
;; out of the return.
(defvar tlg-tlgd-program
(expand-file-name "~/cgreek-emacs20/tlg/tlgd")
"*TLG converter daemon.")
(defvar tlgd-return)
;; This needs some failure provisions
(start-process "tlgd" "*tlgd*" tlg-tlgd-program)
(set-process-filter (get-process "tlgd") 'simple-filter)
(defun simple-filter (proc str)
(setq tlgd-return (substring str 0 (- (length str) 1)))
; (setq tlgd-return (format "%s" str))
)
;; Needs to verify that there's a tlgd process or do nothing
(defun tlg-translate-beta (str)
"Translate a TLG beta code string into multibyte characters.
Strings are prepended with '&' to make Latin the default (it
takes '$' to switch to Greek)."
(interactive)
(process-send-string "tlgd" (concat "&" str "\n"))
(accept-process-output (get-process "tlgd"))
(eval tlgd-return)
)
;;end of functions
I then call tlg-translate-beta in tlg-find-idt-file and tlg-open-single-work
to translate the author and title strings:
(defun tlg-find-idt-file (idtfile)
"Open a buffer and display a list of works for a TLG author as
found in idtfile.idt. If path is given, prepends path to idtfile."
(interactive)
(let ((buf (get-buffer-create (format "*Works in %s*" idtfile)))
authorname
filename)
(set-buffer buf)
(erase-buffer)
(setq filename (concat tlg-tlgpath idtfile))
(toggle-enable-multibyte-characters)
(let ((coding-system-for-read 'no-conversion))
(shell-command
(format "%s %s %d"
tlg-idt-converter-program
filename
(charset-id 'cgreek))
t))
(toggle-enable-multibyte-characters)
(goto-char (point-min))
(switch-to-buffer buf)
(emacs-lisp-mode)
(make-local-variable 'tlg-works)
(eval-buffer)
(erase-buffer)
(insert (format "Works list for %s\n Type M-f to open the work on a line\n "
(tlg-translate-beta tlg-author)))
(mapcar (lambda (w)
(insert
(format "\n%s %s"
(car w)
(tlg-translate-beta (cdr (assoc 'title w)))
)
)
) tlg-works)
(local-set-key "\M-f" 'tlg-open-single-work-at-beginning-of-line)
)
)
(defun tlg-open-single-work (w)
"Open a single work from a TLG .txt file in a buffer. Citation
information is processed as text properties, author and title
information are stored in buffer-local variables, and tlg-mode
is turned on. The single argument must be an alist of the form
produced from tlgidt2emacs."
(interactive )
(let ((buf (generate-new-buffer (cdr (assoc 'title w)))))
(set-buffer buf)
(toggle-enable-multibyte-characters)
(let ((coding-system-for-read 'no-conversion))
(shell-command
(format "%s -f %s -b %s -o %s -A \"%s\" -B \"%s\""
cgreek-tlg-cites-converter-program
(concat tlg-tlgpath (cdr (assoc 'file w)))
(cdr (assoc 'work w))
(cdr (assoc 'start w))
(cdr (assoc 'author w))
(cdr (assoc 'title w)))
t))
(toggle-enable-multibyte-characters t)
(goto-char (point-min))
(switch-to-buffer buf)
(goto-char (point-min))
(tlg-add-ref-properties)
(goto-char (point-max))
(make-local-variable 'tlg-current-ref)
(make-local-variable 'tlg-workno)
(make-local-variable 'tlg-authorno)
(make-local-variable 'tlg-title)
(make-local-variable 'tlg-author)
(make-local-variable 'tlg-auth-abbr)
(make-local-variable 'tlg-title-abbr)
(re-search-backward "^\\(.*\\)\\(.*\\)\\(.*\\)\\(.*\\)" (point-min) t)
(setq tlg-author
(tlg-translate-beta (buffer-substring (match-beginning 1) (match-end 1)))
tlg-title
(tlg-translate-beta (buffer-substring (match-beginning 2) (match-end 2)))
tlg-title-abbr
(buffer-substring (match-beginning 3) (match-end 3))
tlg-auth-abbr
(buffer-substring (match-beginning 4) (match-end 4))
)
(replace-match "")
(goto-char (point-min))
(tlg-mode))
)
Finally, you need something to run as tlgd. I am using Takahashi's tlg.lex
patched as follows (and compiled as tlgd). You could just run my tlgcites2emacs
with "\|" as the only option and get the same result, except that it's probably
slower and might behave strangely.
*** /home/rasmith/cgreek-emacs20/tlg/tlg.lex Thu Oct 14 07:21:48 1999
--- /home/rasmith/cgreek-emacs20/tlg/tlgd.lex Wed Jul 19 18:11:41 2000
***************
*** 504,524 ****
{
FILE *file;
! if (argc < 2 || argc > 3) {
! fprintf(stderr, "usage: %s filename [leading_code]\n", argv[0]);
exit(-1);
}
! if (argc == 3) {
! lc_g2 = atoi(argv[2]);
}
- file = fopen(argv[1], "r");
- if (!file) {
- fprintf(stderr, "cannot open %s\n", argv[1]);
- exit(-1);
- }
! yyin = file;
yylex();
}
--- 504,521 ----
{
FILE *file;
! if (argc > 2) {
! fprintf(stderr, "usage: %s [leading_code]\n", argv[0]);
exit(-1);
}
! if (argc == 2) {
! lc_g2 = atoi(argv[1]);
}
! yyin=stdin;
!
!
yylex();
}
Even with this, however, Greek doesn't display as Greek in the
mode line. Can anyone help?
If anyone else actually gets all this to work, please let me know.
Robin Smith
Department of Philosophy rasmith@xxxxxxxx
Texas A&M University Voice (409) 845-5696
College Station, TX 77843-4237 FAX (409) 845-0458