eev
[Top][All Lists]
Advanced

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

Re: wset for frames


From: Erich Ruff
Subject: Re: wset for frames
Date: Fri, 05 Nov 2021 09:09:38 +0100
User-agent: mu4e 1.6.1; emacs 27.2

Good Morning Eduardo,

you proposed to split my function into 2 and use ee-template0 to
construct the cmd-lines:

Here is my working solution: (w/o error checking)
Is this what you meant?
Do you think the code needs impprovement?


------------------------------ code begin --------------------
;; the cmd-line to parse w/o the comment ';;' is:
;; (code-tla-pdf 'fig1 
"/mnt/fichte/fuchs_erich-fichte_im_gespraech_1_1762-1798.pdf")

(defun write-tlas ()
  "parse the given code-tla-pdf line"
  (interactive)
  (let* (
         (beg (line-beginning-position))
         (end (line-end-position))
         (strx (buffer-substring-no-properties beg end))
         ;; (strx "code-tla-pdf 'fuch1 
/mnt/fichte/fuchs_erich-fichte_im_gespraech_1_1762-1798.pdf")
         (tlax (nth 1 (split-string strx)))
         (tla  (replace-regexp-in-string "'" "" tlax))
         (TLA (concat (capitalize tla) "x"))
         (fnamex (nth 2 (split-string strx )))
         (fname  (replace-regexp-in-string ")" "" fnamex))
         )
    ;; (message "%s -- %s  -- %s"  tla TLA fname)
    (compose-and-write tla TLA fname)
    )
  )


(defun compose-and-write ( tla TLA fname )
  "receive tla TLA and fname from
   parsing function"
  (interactive)
  ;; define all the substrings
  (let* (
         (ia "(interactive)\n")
         (posa  "(&rest pos-spec-list")
         (posb  "pos-spec-list")
         (posc ",@pos-spec-list)))")
         (apply  "(apply 'find-pdf-txt")
         (fwset "(find-wset \"F_\"")
         (xgans "\"" )
         ;; compose the 'tlas' with ee-template0
         (alla (ee-template0 "\n(defun {tla}x {posa} )\n {ia} {apply} {fname} 
{posb} ))\n"))
         (allb (ee-template0 "\n(defun {TLA}  {posa} )\n {ia} {fwset} 
{xgans}{TLA}{xgans} `({tla}x {posc}\n"))
         )
    ;; go down, insert 'tlas' and a final seperating line
    (goto-char (line-end-position))
    (insert "\n")
    (insert alla)
    (insert allb)
    (insert "\n;; ")
    (cl-loop for i from 1 to 80 do (insert "-"))
    (insert "\n\n")
    )
  )
------------------------------ code end --------------------





On Di 02 Nov 2021 at 13:30, Eduardo Ochs <eduardoochs@gmail.com> wrote:

> Also here:
>
> http://angg.twu.net/eev-current/eev-template0.el.html#lexical-binding
>
> On Tue, 2 Nov 2021 at 13:26, Eduardo Ochs <eduardoochs@gmail.com> wrote:
>>
>> That's a very good approach!
>>
>> I would rewrite it as two functions: one that just receives tla,
>> TLA, and fname, and uses ee-template0 to produce a big string
>> from them, and a second one that processes the current line,
>> obtains tla, TLA, and fname, calls the first function, and
>> inserts the string that the first one produces. I'll send you
>> some examples later. Ah, btw, I started to rewrite your code with
>> ee-template0, but I didn't finish because I found something more
>> urgent - below.
>>
>> Did you try to use ee-template0? Did you fail? I just wrote an
>> explanation - much better than the previous one - for why it
>> needs dynamic binding... it is here:
>>
>> (find-wgeta-elisp "http://angg.twu.net/eev-current/eev-template0.el";
>> "lexical-binding")
>>
>> More later! =),
>>   Eduardo
>>
>> On Tue, 2 Nov 2021 at 11:51, Erich Ruff <erich_ruff@t-online.de> wrote:
>> >
>> >
>> > Hello Eduardo,
>> >
>> > here is my code - if you can improve it: please do so!
>> >
>> > ----
>> >
>> > if your cursor stands on the line beginning with --> (code-tla-pdf
>> > call --> write-tlas
>> >
>> > (code-tla-pdf 'fig1 
>> > "/mnt/fichte/fuchs_erich-fichte_im_gespraech_1_1762-1798.pdf")
>> >
>> >
>> > (defun write-tlas ()
>> >   "take a code-tla-pdf line and create
>> >    defun     to  txt-version of pdf
>> >    find-wset to  open it in a persistent frame"
>> >   (interactive)
>> >   (let* ((beg (line-beginning-position))
>> >          (end (line-end-position))
>> >          (strx (buffer-substring-no-properties beg end))
>> >          (tlax (nth 1 (split-string strx )))
>> >          (tla  (replace-regexp-in-string "'" "" tlax))
>> >          (fnamex (nth 2 (split-string strx )))
>> >          (fname  (replace-regexp-in-string ")" "" fnamex))
>> >          (posa  "(&rest pos-spec-list")
>> >          (posb  "pos-spec-list")
>> >          (ia "(interactive)\n")
>> >          (apply  "(apply 'find-pdf-txt")
>> >          (posz  "pos-spec-list")
>> >          (TLA (concat (capitalize tla) "x"))
>> >          (fwset "(find-wset \"F_\" ")
>> >          (wrest (concat "`(" tla "x"  " ,@pos-spec-list)))"))
>> >          (alla (concat "\n(defun " tla "x" " " posa ")\n" ia " " apply " " 
>> > fname " " posb "))\n"))
>> >          (allb (concat "\n(defun " TLA " " posa ")\n" ia " " fwset  " \"" 
>> > TLA "\""  " " wrest "\n"))
>> >          )
>> >     (forward-line 1)
>> >     (insert alla)
>> >     (forward-line 1)
>> >     (insert allb)
>> >     (forward-line 1)
>> >     (insert ";; ")
>> >     (cl-loop for i from 1 to 80 do (insert "-"))
>> >     (insert "\n\n")
>> >     )
>> >   )
>> >
>> > Cheers
>> >  Erich
>> >
>> >
>> > On Di 02 Nov 2021 at 11:25, Eduardo Ochs <eduardoochs@gmail.com> wrote:
>> >
>> > > Please share!
>> > > I'll try to fix find-wset "F".



reply via email to

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