Subject: mailing-list for TeXmacs Users
List archive
From : Giovanni Piredda <address@hidden>- To: address@hidden
- Subject: Re: export to pdf (windows)
- Date: Wed, 20 Apr 2022 19:39:50 +0000
I think I have found a way to make it work, even if I miss understanding important features of the functions.
The default definition of (propose-name-buffer) is (from progs/texmacs/texmacs/tm-files.scm, copied from GitHub)
(tm-define (propose-name-buffer)
(with name (url->unix (current-buffer))
(cond ((not (url-scratch? name)) name)
((os-win32?) "")
(else (string-append (var-eval-system "pwd") "/")))))
and it does not work on Windows because it does not put the colon after the drive volume letter (one obtains for example "/E/Varie/Test/..." where the ellipsis stands for the rest of the path, which is not ok).
I modified it in the following way
(tm-define (propose-name-buffer)
(with name (url->system (current-buffer))
(cond ((not (url-scratch? name)) name)
((os-win32?) "")
(else (string-append (var-eval-system "pwd") "/")))))
using url->system instead of url->unix
I do not know whether this is the best way of modifying the function, since I do not know what the cond form does. But it works after, further, modifying its output, which contains double backslashes, to contain single slashes (I write a function that does this):
(define (prop-name-buffer) (string-join (string-split (propose-name-buffer) #\\ ) "/"))
So that one writes (propose-pdf-name) using the function (prop-name-buffer) in place of (propose-name-buffer)
(define (propose-pdf-name)
(with name (prop-name-buffer)
(if (string-ends? name ".tm")
(string-append (string-drop-right name 3) ".pdf"))))
which works with
(define (export-to-proposed-pdf)
(let ((pdf-name (propose-pdf-name)))
(wrapped-print-to-file pdf-name)))
Since the redefinition of (propose-name-buffer) may interfere with other uses of this function, maybe one can assign the modified "name-proposing" function to another name :
(tm-define (my-propose-name-buffer)
(with name (url->system (current-buffer))
(cond ((not (url-scratch? name)) name)
((os-win32?) "")
(else (string-append (var-eval-system "pwd") "/")))))
and
(define (prop-name-buffer) (string-join (string-split (my-propose-name-buffer) #\\ ) "/"))
Summary (please let me know if it works):
;---- export pdf on Windows ----
(tm-define (my-propose-name-buffer)
(with name (url->system (current-buffer))
(cond ((not (url-scratch? name)) name)
((os-win32?) "")
(else (string-append (var-eval-system "pwd") "/")))))
(define (prop-name-buffer) (string-join (string-split (my-propose-name-buffer) #\\ ) "/"))
(define (propose-pdf-name)
(with name (prop-name-buffer)
(if (string-ends? name ".tm")
(string-append (string-drop-right name 3) ".pdf"))))
(define (export-to-proposed-pdf)
(let ((pdf-name (propose-pdf-name)))
(wrapped-print-to-file pdf-name)))
(kbd-map
("M-e p" (export-to-proposed-pdf)))
Am 14.04.2022 um 00:52 schrieb Giovanni Piredda:
On 14.04.22 00:08, vincent douce wrote:
Hello
this code works very fine on my mac and i use it since months, a real gain of time for me
but we dont manage to install in on a windows of a colleague
by her, "meta" corresponds to no key (we dont manage to assign a key to it) but works fine as "esc"
for example in math mode if we type esc then A, we get a tree
so we have tried esc and then e and then p but it makes nothing
an idea ?
Vincent
;---- export pdf ----
(define (propose-pdf-name)
(with name (propose-name-buffer)
(if (string-ends? name ".tm")
(string-append (string-drop-right name 3) ".pdf"))))
(define (export-to-proposed-pdf)
(let ((pdf-name (propose-pdf-name)))
(wrapped-print-to-file pdf-name)))
(kbd-map
("M-e p" (export-to-proposed-pdf)))
The only way I know of to figure out what is happening on Windows is to execute the commands in a Scheme session.
Id est, you have to execute the command itself, by writing it---in this case (export-to-proposed-pdf)---and pressing Return, not the keyboard shortcut. If there are any errors, they will appear as output in the Scheme session.
- export to pdf (windows), vincent douce, 04/14/2022
- Re: export to pdf (windows), Giovanni Piredda, 04/14/2022
- Re: export to pdf (windows), Giovanni Piredda, 04/20/2022
- Re: export to pdf (windows), Giovanni Piredda, 04/14/2022
Archive powered by MHonArc 2.6.24.