eev
[Top][All Lists]
Advanced

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

Re: suffix for pdfs


From: Erich Ruff
Subject: Re: suffix for pdfs
Date: Tue, 08 Jun 2021 15:23:24 +0200
User-agent: mu4e 1.4; emacs 27.2

Hi Eduardo,

thank you for your quick answer and the code!

It works very well and the 2nd solution is magic.

But it pops up a new problem.

Coetzee99.pdf gets converted to text w/o problems.

But I tested with different other pdfs and I always get text with
ESC-sequences loaded in an emacs-buffer as raw text.

using pdftotext with '-layout -enc Latin1' or 'UTF-8' renders the pdf to
text w/o ESQ-sequences - but the internal conversion with eev produces
the same text with \351 etc.

# (find-schlkpage 14 "Es k\366nnen aber Umst\344nde eintreten")
# (find-schlktext 14 "Es k\366nnen aber Umst\344nde eintreten")
# (find-schlkpage (+ 0 14) "Es k\366nnen aber Umst\344nde eintreten")
# (find-schlktext (+ 0 14) "Es k\366nnen aber Umst\344nde eintreten")

for txt and pdf  the link with \366 works.

Corrected to --> "Es k├Ânnen" leaves only pdf working.

Is there a way to instruct emacs to load the converted text in an
utf-8-buffer w/o a lot of \xxx. ?



On Mo 07 Jun 2021 at 23:00, Eduardo Ochs <eduardoochs@gmail.com> wrote:

> Hi Erich,
>
> here are two solutions. This one is the obvious one:
>
>
> --snip--snip-- code of the first solution: --snip--snip--
>
> ;;  Skel: (find-code-xxx-links "tla-pdf" "tla fnamepdf" "")
> ;;
> (defun      code-tla-pdf (tla fnamepdf)
>   (eval (ee-read      (ee-code-tla-pdf tla fnamepdf))))
> (defun find-code-tla-pdf (tla fnamepdf)
>   (find-estring-elisp (ee-code-tla-pdf tla fnamepdf)))
> (defun   ee-code-tla-pdf (tla fnamepdf)
>   (ee-template0 "\
> ;; (find-code-tla-pdf \"{tla}\" \"{fnamepdf}\")
> ;;      (code-tla-pdf \"{tla}\" \"{fnamepdf}\")
>
> (defun {tla}p (&optional page &rest rest)
>   (interactive)
>   (find-pdf-page \"{fnamepdf}\" page))
> (defun {tla}t (&optional page &rest rest)
>   (interactive)
>   (apply 'find-pdf-text \"{fnamepdf}\" page rest))
> "))
>
> ;; Compare:
> ;; (find-code-tla     'coe "~/Coetzee99.tex")
> ;; (find-code-tla-pdf 'coe "~/Coetzee99.pdf")
>
> ;; Try:
> ;; (code-tla-pdf 'coe "~/Coetzee99.pdf")
> ;; (coep 1)
> ;; (coet)
> ;; (coet "LECTURE I")
>
> --snip--snip-- end of the first solution --snip--snip--
>
>
>
> Do you know how to use this? I use it all the time...
>
>   (find-pdf-like-intro "10. Generating a pair with the page number")
>
> The first solution doesn't support that. Here is a solution that SORT
> OF supports it:
>
>
>
> --snip--snip-- code of the second solution: --snip--snip--
>
> ;;  Skel: (find-code-xxx-links "tla-pdf" "tla fnamepdf offset" "")
> ;;
> (defun      code-tla-pdf (tla fnamepdf &optional offset)
>   (eval (ee-read      (ee-code-tla-pdf tla fnamepdf offset))))
> (defun find-code-tla-pdf (tla fnamepdf &optional offset)
>   (find-estring-elisp (ee-code-tla-pdf tla fnamepdf offset)))
> (defun   ee-code-tla-pdf (tla fnamepdf offset)
>   (let ((offsetstr (if offset (format " %d" offset) "")))
>     (ee-template0 "\
> ;; (find-code-tla-pdf \"{tla}\" \"{fnamepdf}\"{offsetstr})
> ;;      (code-tla-pdf \"{tla}\" \"{fnamepdf}\"{offsetstr})
>
> (code-pdf-page \"{tla}\" \"{fnamepdf}\")
> (code-pdf-text \"{tla}\" \"{fnamepdf}\"{offsetstr})
>
> (defalias '{tla}p 'find-{tla}page)
> (defalias '{tla}t 'find-{tla}text)
> ")))
>
>
> ;; Try:
> ;;   (find-code-tla-pdf 'coe "~/Coetzee99.pdf")
> ;;   (find-code-tla-pdf 'coe "~/Coetzee99.pdf" -110)
> ;;        (code-tla-pdf 'coe "~/Coetzee99.pdf" -110)
> ;;
> ;; Then links like these should work,
> ;;   (coep)
> ;;   (coep 3)
> ;;   (coet 3 "LECTURE I")
> ;;
> ;; and this too... run the two sexps below and then type `M-h M-p'
> ;; in the buffer with the PDF converted to text:
> ;;
> ;;    (kill-new "wrong thoughts")
> ;;    (coet (+ -110 127) "wrong thoughts")
> ;;
> ;; you should get a temporary buffer containing four links like these
> ;; ones (and other stuff):
> ;;
> ;;    (find-coepage 17 "wrong thoughts")
> ;;    (find-coetext 17 "wrong thoughts")
> ;;    (find-coepage (+ -110 127) "wrong thoughts")
> ;;    (find-coetext (+ -110 127) "wrong thoughts")
> ;;
> ;; in more realistic examples you would mark a region of the PDF
> ;; converted to text, and type `M-w M-h M-p'...
>
> --snip--snip-- end of the second solution --snip--snip--
>
>
>   Can you try it and tell me if it makes sense?
>     [[]] =),
>       Eduardo
>
> On Mon, 7 Jun 2021 at 15:00, Erich Ruff <erich_ruff@t-online.de> wrote:
>>
>>
>> Hi Eduardo, hi list,
>>
>> the new approach to select the pdf-viewer with
>>  (defalias 'find-pdf-page 'find-xpdf-page)
>>  (defalias 'find-pdf-page 'find-pdftools-page)
>>  (defalias 'find-pdf-page 'find-evince-page)
>> works great.
>>
>> irritating (and tedious) is, that I have to rename in the tla all pdfs
>> to *.tex to point to the pdf.
>>
>> (code-tla 'spe "/mnt/phil/speiser/speiser-xxx-yyyy.tex")
>>
>> calling --> spei  does nothing
>>
>> calling --> speip  opens in the preselected pdf viewer
>>
>>
>> defining a tla for the pdf:
>>
>> (code-tla 'spex "/mnt/phil/speiser/speiser-xxx-yyyy.pdf")
>>
>> --> see the x in spe
>> opens the pdf in emacs pdf-view and not in the previous selected viewer.
>>
>> Is it possible to leave the suffix and open then pdf in presel. viewer?
>>
>>
>> Erich
>>



reply via email to

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