Mailing List Archive


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

Re: [tlug] searching for kanji strings, ignore punctuation and endof lines: Perl Solution and comments



>>>>> "David" == David Riggs <dariggs@example.com> writes:

    David> The ugly part is that I have to go edit the perl script
    David> file each time, and do a little emacs deal to insert the $w
    David> between each kanji. Still, it works!

Perl probably has a split function; make the kanji string a varaible
(see below for why), and split it on "" which will give you an array
of characters.  Then do a join with "\$w".

(defun mung-run-perl (kanji)
  (interactive "sTarget: ")
  (search-forward "# comment on line before kanji_string"
  (forward-line 1)
  (kill-line 1)   ;; remove the existing "$kanji_string =" line
  (insert "  $kanji_string = " kanji ";")  ; does perl need a terminating ;? whatever
  (save-buffer)
  (shell-command (buffer-file-name))
  )

Change to the buffer with the perl code in it, and M-x mung-run-perl.
Season to taste.

    David> Steven, are you serious, can you do something like this
    David> with egrep and elisp? That would be great. I would love to
    David> hear more.

The perl will do as well as the egrep, and you've already got that
working.  I'm not sure, maybe egrep would be faster.  Elisp itself is
much too slow for this job, and Emacsen like to read entire files into
the buffer; that's why I suggested a simple grep into a buffer and
post-processing with elisp for presentation.

But 60 seconds is a long time.  You really should find some way to get
this indexed.  Is there any restriction on the strings, or are they
basically arbitrary sequences of CJK ideographs?


-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links