Point and Click does not work on Windows

classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Point and Click does not work on Windows

Henning Plumeyer
Hope, this is the right place to post this:

I just installed  
http://download.linuxaudio.org/lilypond/binaries/mingw/lilypond-2.11.65-1.mingw.exe
on a new Windows machine.
I found, that a new protocol "textedit" gets installed.
(HKEY_LOCAL_MACHINE\SOFTWARE\Classes\textedit\shell\open\command)

The command in this registry key is:
"D:\Programme\LilyPond\usr\bin\guile.exe" -e main -s  
"D:\Programme\LilyPond\usr\bin\lilypond-invoke-editor.scm" "%1"

The script after -s exists, but without the extension ".scm", its name is
just "lilypond-invoke-editor".

I opened a pdf file with Point and Click links in Adobe Reader. I just saw  
a
a black commandline-window which dissapeared immediately.

I added the missing extension .scm to lilypond-invoke-editor. I tried again
and I got the same result.

Trying this commandline (I could read the last parameter in a popup in
Adobe Reader when I moved the mouse cursor to a note) in a separate  
window:....

c:\>"D:\Programme\LilyPond\usr\bin\guile.exe" -e main -s  
"D:\Programme\LilyPond\usr\bin\lilypond-invoke-editor.scm"  
"D:/Profile/h/Eigene%20Dateien/Notensatz/Gloria.ly:94:37:51"

...I see this error message:

lilypond-invoke-editor (GNU LilyPond) 2.11.65
ERROR: no code for module (scm editor)

I found a file  
D:\Programme\LilyPond\usr\share\lilypond\current\scm\editor.scm.

It seems to me that guile.exe does not find the module, but I don't
know scheme.

-Henning



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
Henning Plumeyer wrote
Hope, this is the right place to post this:
so do i!

textedit does not work correctly in windows xp
it does not use the editor one is used to work with

one way to make point and click work on windows xp follows - of course a solution within Lilypond would be preferred!

1. program
  copy the file textedit.bat into a program folder - e.g. C:\program files\…\…\textedit.bat
  edit it and choose or insert your preferred editor
  make sure the line and column number and file are in the correct form and order
  save it

2. register the textedit protocol
  copy the file textedit.reg anywhere (or near the above program)
  edit it and insert the full path and name of the above file - "textedit.bat" - be sure to escape all special characters…!
  save and run it (double click or so)

3. refresh after downloading Lilypond
  rerun "textedit.reg" each time you load a new version of lilypond

this program handles files with blanks in the name (which textedit delivers as "%20"). this may lead to unexpected results when using "%" in the name.

hope this is useful!
Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Gilles THIBAULT

>one way to make point and click work on windows xp follows [...]
Wonderful, it  works for me.
Great job.
Thanks you.


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
Gilles THIBAULT wrote
>one way to make point and click work on windows xp follows [...]
Wonderful, it  works for me.
Great job.
Thanks you.
thanks goes to several authors in the "Deutsches Lilypond Forum" where i took a loan from
Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

ArnoldTheresius
<quote author="Eluze">
Gilles THIBAULT wrote
>one way to make point and click work on windows xp follows [...]
...
Eluze
Hello,

in relation to issue 3306 [http://code.google.com/p/lilypond/issues/detail?id=3306]
I analized the point-and-click problem on my Win7/64 computer.
(Why does it not work out of the box after installation?)

Here the result:

The registry entry for point-and-click after the setup of version 2.17.15 and 2.17.16:
HKEY_CLASSES_ROOT\textedit\shell\open\command (type REG_EXPAND_SZ) has value
»"$INSTDIR\usr\bin\guile.exe" -e main -s "$INSTDIR\usr\bin\lilypond-invoke-editor.scm" "%1"«
where $INSTDIR is the installation directory

1. File »$INSTDIR/usr/bin/lilypond-invoke-editor.scm« does not exist.
   The correct file name is without the extension ».scm«.

2. I placed this 7-line minimal script at »$INSTDIR/usr/bin/lilypond-invoke-editor.scm«:
     #!/home/gub/gub/target/tools/root/usr/bin/guile -s
     !#
     (define (main args)
       (for-each display (list "\ncommandline = '" args "'\n"))
       (system "pause"))

     (main (command-line))

   This did show, it's executed twice. Removing the option »-e main« will it only
   make executed once.

==> corrected registry entry:
»"$INSTDIR\usr\bin\guile.exe" -s "$INSTDIR\usr\bin\lilypond-invoke-editor" "%1"«
this corresponds to the header line (for UNIX) of this lilypond-invoke-editor script.




Bug in the script file $INSTDIR/usr/bin/lilypond-invoke-editor:

3. For testing I executed it in the command shell. I got the error message
   »ERROR: no code for module (scm editor)«, because »LILYPOND_DATADIR«
   (which extends the »%load-path«) points to
   »$INSTDIR\usr/share/lilypond/2.17.16« (resp. 2.17.15),
   but this directory does not exist on a windows installation,
   the last element of the path is called »current« instead.
==> move »(define PLATFORM before »(define LILYPOND_DATADIR
    conditionaly use »"current"« instead of »TOPLEVEL-VERSION« for definition of
    LILYPOND_DATADIR if the PLATFORM is »'windows«
    Then it will find module »$INSTDIR/usr/share/lilypond/current/scm/editor.scm« to load

Modifications to $INSTDIR/usr/bin/lilypond-invoke-editor:+ (define PLATFORM
+   (string->symbol
+    (string-downcase
+     (car (string-tokenize (vector-ref (uname) 0) char-set:letter)))))
+
  (define PROGRAM-NAME "lilypond-invoke-editor")
  (define TOPLEVEL-VERSION "2.17.16")
  (define DATADIR "/usr/share")
  (define COMPILE-TIME-PREFIX
    (format #f "~a/lilypond/~a" DATADIR TOPLEVEL-VERSION))

  ;; argv0 relocation -- do in wrapper?

  (define LILYPOND_DATADIR
    (let* ((prefix
   (or (getenv "LILYPOND_DATADIR")
       (dirname  (dirname (car (command-line)))))))
   

      (if (eq? prefix (dirname DATADIR)) COMPILE-TIME-PREFIX
  (format #f "~a/share/lilypond/~a"
- prefix TOPLEVEL_VERSION))))
+ prefix
+ (if (eq? PLATFORM 'windows)
+ "current"
+ TOPLEVEL-VERSION)))))
...
- (define PLATFORM
-   (string->symbol
-    (string-downcase
-     (car (string-tokenize (vector-ref (uname) 0) char-set:letter)))))
-





There is another lilypad usage problem which may be tuned by a modification in
»$INSTDIR/usr/share/lilypond/current/scm/editor.scm«:

4. If you enable the option »-e main« again in the registry settings, you will notice
   the scripts waits until lilypad terminates, and due to this option it will open
   lilypad again and wait until it terminates again. Even without the option »-e main«
   in the registry command line and started form a GUI application there are three more
   processes running and waiting until lilypad terminates.
==> in the »editor-command-template-alist« prefix the lilypad command with »start «
    to launch lilypad in the background (equivalent to appending »&« on UNIX) if the
    PLATFORM is »'windows«.
    NOTICE: this file editor.scm is also loaded by lily.scm, but I havn't seen any effect
    caused by this modification.


Modifications to $INSTDIR/usr/share/lilypond/current/scm/editor.scm:
  (define editor-command-template-alist
-   '(("emacs" .  "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
+   `(("emacs" .  "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
      ("gvim" . "gvim --remote +:%(line)s:norm%(column)s %(file)s")
      ("uedit32" . "uedit32 %(file)s -l%(line)s -c%(char)s")
      ("nedit" . "nc -noask +%(line)s %(file)s")
      ("gedit" . "gedit +%(line)s %(file)s")
      ("jedit" . "jedit -reuseview %(file)s +line:%(line)s")
      ("syn" . "syn -line %(line)s -col %(char)s %(file)s")
-     ("lilypad" . "lilypad +%(line)s:%(char)s %(file)s")))
+     ("lilypad" . ,(if (eq? PLATFORM 'windows)
+    "start lilypad +%(line)s:%(char)s %(file)s"
+    "lilypad +%(line)s:%(char)s %(file)s"))))


ArnoldTheresius

Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
ArnoldTheresius wrote
in relation to issue 3306 [http://code.google.com/p/lilypond/issues/detail?id=3306]
I analized the point-and-click problem on my Win7/64 computer.
(Why does it not work out of the box after installation?)

Here the result:
Modifications to $INSTDIR/usr/share/lilypond/current/scm/editor.scm:
  (define editor-command-template-alist
-   '(("emacs" .  "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
+   `(("emacs" .  "emacsclient --no-wait +%(line)s:%(column)s %(file)s || (emacs +%(line)s:%(column)s %(file)s&)")
      ("gvim" . "gvim --remote +:%(line)s:norm%(column)s %(file)s")
      ("uedit32" . "uedit32 %(file)s -l%(line)s -c%(char)s")
      ("nedit" . "nc -noask +%(line)s %(file)s")
      ("gedit" . "gedit +%(line)s %(file)s")
      ("jedit" . "jedit -reuseview %(file)s +line:%(line)s")
      ("syn" . "syn -line %(line)s -col %(char)s %(file)s")
-     ("lilypad" . "lilypad +%(line)s:%(char)s %(file)s")))
+     ("lilypad" . ,(if (eq? PLATFORM 'windows)
+    "start lilypad +%(line)s:%(char)s %(file)s"
+    "lilypad +%(line)s:%(char)s %(file)s"))))
hi Arnold

that was really worth waiting

it would be nice to add a few more editors, e.g. (for windows)

context.exe            /g<column>:<line> file
notepad++.exe       -n<line> -c<column> file
pspad.exe              -<line> file

and finally (?) if the editor associated with the .ly file extension could be launched… (it is stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ly\userchoice)

thanks!
Eluze


Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

ArnoldTheresius
Eluze wrote
...
it would be nice to add a few more editors, e.g. (for windows)

context.exe            /g<column>:<line> file
notepad++.exe       -n<line> -c<column> file
pspad.exe              -<line> file

and finally (?) if the editor associated with the .ly file extension could be launched… (it is stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ly\userchoice)

thanks!
Eluze
The first three should be simple:
  ("context" . "context /g%(column)s:%(line)s %(file)s")
  ("notepad++" . "notepad++ -n%(line)s -c%(column)s %(file)s")
  ("pspad" . "pspad -%(line)s %(file)s")

To select on than it's enough to set the env. var. like
   LYEDITOR=pspad

For the last one I need to check how scheme can read the windows registry.
Hopefully I find this information.

ArnoldTheresius
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
ArnoldTheresius wrote
Eluze wrote
and finally (?) if the editor associated with the .ly file extension could be launched… (it is stored in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ly\userchoice)
The first three should be simple:
  ("context" . "context /g%(column)s:%(line)s %(file)s")
  ("notepad++" . "notepad++ -n%(line)s -c%(column)s %(file)s")
  ("pspad" . "pspad -%(line)s %(file)s")

To select on than it's enough to set the env. var. like
   LYEDITOR=pspad

For the last one I need to check how scheme can read the windows registry.
Hopefully I find this information.
if this is possible we could abandon the entry LYEDITOR?! (at least for windows)

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

ArnoldTheresius
Eluze wrote
...
if this is possible we could abandon the entry LYEDITOR?! (at least for windows)

Eluze
Well,
I would keep the environment variable(s) as a last, top priotiry choice to select which editor one is using.

From scm/editor.scm:
(define (get-editor)
  (or (getenv "LYEDITOR")
      (getenv "XEDITOR")
      (getenv "EDITOR")

      ;; FIXME: how are default/preferred editors specified on
      ;; different platforms?
      (case PLATFORM
        ((windows) "lilypad")
 ;;; my TODO suggestion: implement querying of windows registry to select the users choice
        (else
         "emacs"))))


Until now I did not find a function in guile to read registry values.
There is the command line program »REG QUERY ... « to get the information. It's standard output needs to be parsed, and the call needs to be fail save (dont throw an exception if it fails).
I tried open-input-pipe, but go the error message it cannot fork.

That looks like we need to execute a system call and redirect the output into a temporary file, then parse the file. Possibly we do this on several pathes in the windows registry until we get an string. Then we need to scan for specific keywords in this string to select one on the known editors.

ArnoldTheresius
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
ArnoldTheresius wrote
Eluze wrote
...
if this is possible we could abandon the entry LYEDITOR?! (at least for windows)
Well,
I would keep the environment variable(s) as a last, top priotiry choice to select which editor one is using.
why not - I just mean don't use it if you don't have to!

From scm/editor.scm:
(define (get-editor)
  (or (getenv "LYEDITOR")
      (getenv "XEDITOR")
      (getenv "EDITOR")

      ;; FIXME: how are default/preferred editors specified on
      ;; different platforms?
      (case PLATFORM
        ((windows) "lilypad")
 ;;; my TODO suggestion: implement querying of windows registry to select the users choice
        (else
         "emacs"))))


Until now I did not find a function in guile to read registry values.
There is the command line program »REG QUERY ... « to get the information. It's standard output needs to be parsed, and the call needs to be fail save (dont throw an exception if it fails).
I tried open-input-pipe, but go the error message it cannot fork.

That looks like we need to execute a system call and redirect the output into a temporary file, then parse the file. Possibly we do this on several pathes in the windows registry until we get an string. Then we need to scan for specific keywords in this string to select one on the known editors.
the reg query … returns only one value in the form of

   Applications\ConTEXT.exe            

where you can strip the first part by

FOR /f "tokens=3*" %%a IN (
  'REG QUERY HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ly\userchoice'
) DO IF NOT [%%a]==[] FOR /f "tokens=2* delims=\" %%a IN ("%%a") DO (SET editor=%%a)

then it is a temporary environment variable which you can get via (getenv "EDITOR")

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
In reply to this post by ArnoldTheresius
ArnoldTheresius wrote
Until now I did not find a function in guile to read registry values.
There is the command line program »REG QUERY ... « to get the information. It's standard output needs to be parsed, and the call needs to be fail save (dont throw an exception if it fails).



That looks like we need to execute a system call and redirect the output into a temporary file, then parse the file. Possibly we do this on several pathes in the windows registry until we get an string. Then we need to scan for specific keywords in this string to select one on the known editors.
I think there are two issues to consider:

 - a program is invoked which is not in a folder defined in the %path% variable
 - the file has not the extension .ly

I've attached a small program to check the user's choice for an application to open that file and to find the full command line command in HKCR\… regQuery.bat

so if you can run such a "system" call you should get this information back

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

pkx166h
hello,


On 21 April 2013 10:43, Eluze <[hidden email]> wrote:
ArnoldTheresius wrote
> Until now I did not find a function in guile to read registry values.
> There is the command line program »REG QUERY ... « to get the information.
> It's standard output needs to be parsed, and the call needs to be fail
> save (dont throw an exception if it fails).
>
> …
>
> That looks like we need to execute a
/
> system
/
>  call and redirect the output into a temporary file, then parse the file.
> Possibly we do this on several pathes in the windows registry until we get
> an string. Then we need to scan for specific keywords in this string to
> select one on the known editors.

I think there are two issues to consider:

 - a program is invoked which is not in a folder defined in the %path%
variable
 - the file has not the extension .ly

I've attached a small program to check the user's choice for an application
to open that file and to find the full command line command in HKCR\…
regQuery.bat
<http://lilypond.1069038.n5.nabble.com/file/n144800/regQuery.bat>

so if you can run such a "system" call you should get this information back



Windows 7 SP1 or other.

C:\Users\jlowe\Desktop>regQuery.bat
Environment variable my not defined

?

Am I supposed to run this bat file pre-edited or with an argument or something?

James

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
James wrote

Am I supposed to run this bat file pre-edited or with an argument or
something?
hi James

2nd

regQuery.bat myFile.ly
or
regQuery.bat "D:\data\…\myfile.ly"

thanks for the feedback!
Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

pkx166h
Hello,


On 21 April 2013 11:56, Eluze <[hidden email]> wrote:
James wrote
>
> Am I supposed to run this bat file pre-edited or with an argument or
> something?

hi James

2nd

regQuery.bat myFile.ly
or
regQuery.bat "D:\data\…\myfile.ly"


C:\Users\jlowe\Desktop>regQuery.bat Dak.ly
myExt=.ly

C:\Users\jlowe\Desktop>

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
James wrote
Hello,


On 21 April 2013 11:56, Eluze <[hidden email]> wrote:

> James wrote
> >
> > Am I supposed to run this bat file pre-edited or with an argument or
> > something?
>
> hi James
>
> 2nd
>
> regQuery.bat myFile.ly
> or
> regQuery.bat "D:\data\…\myfile.ly"
>
>
C:\Users\jlowe\Desktop>regQuery.bat Dak.ly
myExt=.ly
did you make sure .ly is registered in "Standard programs"!?

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

pkx166h
Hello,


On 21 April 2013 13:18, Eluze <[hidden email]> wrote:
James wrote
> Hello,
>
>
> On 21 April 2013 11:56, Eluze &lt;

> eluzew@

> &gt; wrote:
>
>> James wrote
>> >
>> > Am I supposed to run this bat file pre-edited or with an argument or
>> > something?
>>
>> hi James
>>
>> 2nd
>>
>> regQuery.bat myFile.ly
>> or
>> regQuery.bat "D:\data\…\myfile.ly"
>>
>>
> C:\Users\jlowe\Desktop>regQuery.bat Dak.ly
> myExt=.ly

did you make sure .ly is registered in "Standard programs"!?


I'm not sure what you mean here.

For instance in Windows there is

Control Panel\Programs\Default Programs\Set Associations

or

Control Panel\Programs\Default Programs\Set Default Programs

The first one actually has *.ly files associated with Frescobaldi (I'd forgotten I had it installed!) so I assume that Frescobaldi does that file association for you when you install it.

The second one does not have either Frescobaldi or LilyPond in the list. I don't know if that matters if you just use 'Set Associations'.

So if I 'Set Associations' with *.ly files to use another program again LilyPond is not in the list, but I can browse to the exe directly; and if I do _that_ and then run the bat file I get:

--snip--

C:\Users\jlowe\Desktop>regQuery.bat Dak.ly
myApplicationCaller="C:\Program Files\LilyPond\usr\bin\lilypond.exe"
myEditor=lilypond.exe
myExt=.ly

--snip--

So does it matter (to you) that when a user installs LilyPond there are no (I think - maybe Phil can correct me he uses LilyPond on Windows too) file associations set - certainly no 'default programs'.

or was I supposed to point the file associations at something else (lilypad.exe or lilypond-windows.exe etc.)?

HTH

James



 

_______________________________________________
lilypond-devel mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
James wrote
Hello,


On 21 April 2013 13:18, Eluze <[hidden email]> wrote:

> James wrote

I'm not sure what you mean here.

For instance in Windows there is

Control Panel\Programs\Default Programs\Set Associations

or

Control Panel\Programs\Default Programs\Set Default Programs

The first one actually has *.ly files associated with Frescobaldi (I'd
forgotten I had it installed!) so I assume that Frescobaldi does that file
association for you when you install it.

The second one does not have either Frescobaldi or LilyPond in the list. I
don't know if that matters if you just use 'Set Associations'.

So if I 'Set Associations' with *.ly files to use another program again
LilyPond is not in the list, but I can browse to the exe directly; and if I
do _that_ and then run the bat file I get:

--snip--

C:\Users\jlowe\Desktop>regQuery.bat Dak.ly
myApplicationCaller="C:\Program Files\LilyPond\usr\bin\lilypond.exe"
myEditor=lilypond.exe
myExt=.ly

--snip--

So does it matter (to you) that when a user installs LilyPond there are no
(I think - maybe Phil can correct me he uses LilyPond on Windows too) file
associations set - certainly no 'default programs'.

or was I supposed to point the file associations at something else
(lilypad.exe or lilypond-windows.exe etc.)?
thanks for testing, James!

maybe my hope to find the needed information in thess tables was to optimistic - does somebody know how the "correct" way is?

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

ArnoldTheresius
Eluze wrote
...
maybe my hope to find the needed information in thess tables was to optimistic - does somebody know how the "correct" way is?

Eluze
Well, at least here is what I did try this weekend - posted before I read all messeages which were added in the meantime.
This code is still "dirty but quick, incomplete but big"
Editors 'context' and 'pspad' are still missing.
Hopefully still good enough for some testing.

Also to clearify:
- Which of the listed editors are available for windows?
- Which one needs to be started into the background (like lilypad)?

Now, here is my code sinippet for scm/editor.scm:

(use-modules (ice-9 rdelim)) ;;!! this module is also required - add it to the modules list

(define PLATFORM  
;; no change
  (string->symbol
   (string-downcase
    (car (string-tokenize (vector-ref (uname) 0) char-set:letter)))))

(define (winreg-read key attribute)  
;;!! new function
 ;;;; this is a workaround, reading the windows registry by examination
 ;;;; of command line output (via a temorary file)
 ;;;; I know, the output depends on the users language!
 ;;;; Hopefully there are only 7bit-ASCII characters used,
 ;;;; and the "not defined" message for standard attribute is
 ;;;;  parenthesized for all languages,
 ;;;; and no other value for the standard attrbute will be parentzesized,
 ;;;; and no empty string will be defined for an attribute
 ;;;;
 ;;;; input 'key' is either a string for the registry path (use backslash!)
 ;;;;  or a list of strings (multiple elements which are to be concatenated
 ;;;;  to define the input path)
 ;;;; input 'attribute' is the attribute to look for it's value,
 ;;;;  or the empty string ("") to read the standard attribute.
 ;;;; result is a string if the operation could be executed successfully,
 ;;;;  or #f if not,
 ;;;;  or '() if the default attribute seems to be undefined
 (define (concat-stringlist-with-bs root-string trail-list)
  (if (null? trail-list)
   root-string
   (concat-stringlist-with-bs
    (string-append root-string "\\" (car trail-list))
    (cdr trail-list))))
 (define (slash-to-bs s)
  (string-map (lambda (x) (if (equal? x #\/) #\\ x)) s))
 (let* ((look-for-default-value (and (string? attribute)
                                     (> (string-length attribute) 0)))
        ;;; (tmpnam) of MinGW on Win7/64 did not use the
        ;;;  windows default temp folder(s)
        ;;; so I prefer to build temp-dir and temp-file on my own:
        (temp-dir (or (getenv "TEMP")
                      (getenv "TMP")
                      (let* ((prefix (getenv "LOCALAPPDATA")))
                       (if (string? prefix)
                        (let ((temp-path-trial
                               (string-append prefix "\\Temp")))
                         (if (access? temp-path-trial W_OK)
                          temp-path-trial
                          (let ((temp-path-trial
                                 (string-append prefix "\\Tmp")))
                           (if (access? temp-path-trial W_OK)
                            temp-path-trial #f))))
                        #f))
                      "."))
        (temp-file (slash-to-bs
                    (let* ((delim (if (or (string-suffix? "\\" temp-dir)
                                          (string-suffix? "/" temp-dir))
                                   "_" "\\_"))
                           (ct 0)
                           (test-name (string-append temp-dir delim "lily"
                                       (number->string (getpid)) "."
                                       (number->string ct) ".tmp")))
                     (while (and (access? test-name F_OK) (< ct 99999))
                      (set! ct (1+ ct))
                      (set! test-name (string-append temp-dir delim "lily"
                                       (number->string (getpid)) "."
                                       (number->string ct) ".tmp")))
                     test-name)))
        (command-to-execute
         (string-append
          "( FOR /F \"usebackq skip=1 tokens=2*\" %i IN (`REG QUERY "
          (if (pair? key)
           (concat-stringlist-with-bs (car key) (cdr key))
           key)
          (if look-for-default-value (string-append " /v " attribute) " /ve")
          "`) DO @echo %j) > "
          temp-file
          " 2>nul"))
        (execution-result (system command-to-execute)))
  (if (> execution-result 0)
   (begin
    (false-if-exception (delete-file temp-file))
    #f)
   (let ((file-port (false-if-exception (open-file temp-file "r"))))
    (if (port? file-port)
     (let ((text-line (read-line file-port 'trim)))
      (close-port file-port)
      (false-if-exception (delete-file temp-file))
      ;;debug: (for-each display (list "\ncommand-result = '" text-line "'\n"))
      (if (string? text-line)
       (if (and look-for-default-value
                (string-prefix? "(" text-line)
                (string-suffix? ")" text-line))
        '()
        text-line)
       #f))
     (begin
      (false-if-exception (delete-file temp-file))
      #f))))))

(define (users-default-editor-on-windows)  
;;!! new function
 (define (false-if-null x) (if (null? x) #f x))
 (let ((users-editor '())
       (user-choice (winreg-read (list
     "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"
     "FileExts\\.ly\\userchoice") "Progid")))
  ;;debug: (set! user-choice "Applications\\notepad++.exe")
  ;;debug: (set! user-choice "Applications\\gvim.exe")
  ;;debug: (set! user-choice #f)
  ;;debug: (for-each display (list "\nuser-choice (Explorer) = '" user-choice "'\n"))
  ;; if 'user-choice' starts with "Applications\\" followed
  ;;  by the executable name, then we allmost got the result
  (if (and (string? user-choice) (string-prefix-ci? "Applications\\" user-choice))
   (if (string-suffix-ci? "\\gvim.exe" user-choice)
    (set! users-editor "gvim")
    (if (string-suffix-ci? "\\notepad++.exe" user-choice)
     (set! users-editor "notepad++")
     (if (string-suffix-ci? "\\lilypad.exe" user-choice)
      (set! users-editor "lilypad")
  ))))
  ;; if 'user-choice' is another index value,
  ;; we'll have to look at another place
  ;; but if 'user-choice' was not found,
  ;; there's another place to get an equivalent index value
  (if (and (null? users-editor) (not (string? user-choice)))
   (set! user-choice (or
     (false-if-null (winreg-read "HKCU\\SOFTWARE\\Classes\\.ly" ""))
     (false-if-null (winreg-read "HKLM\\SOFTWARE\\Classes\\.ly" ""))
  )))
  ;;debug: (for-each display (list "\nuser-choice (Classes) = '" user-choice "'\n"))
  ;; then try to get the 'edit' or the 'open' command line
  (if (and (null? users-editor)
           (string? user-choice)
           (not (string-contains user-choice "\\")))
   (let ((users-file-command (or
       (false-if-null (winreg-read (list "HKCU\\SOFTWARE\\Classes"
          user-choice "shell\\edit\\command") ""))
       (false-if-null (winreg-read (list "HKLM\\SOFTWARE\\Classes"
          user-choice "shell\\edit\\command") ""))
       (false-if-null (winreg-read (list "HKCU\\SOFTWARE\\Classes"
          user-choice "shell\\open\\command") ""))
       (false-if-null (winreg-read (list "HKLM\\SOFTWARE\\Classes"
          user-choice "shell\\open\\command") ""))
    )))
    ;;debug: (set! users-file-command "\"C:\\Programs_privat_32\\editors\\gvim.exe\" \"%1\"")
    ;;debug: (set! users-file-command "\"C:\\Programs_privat_32\\editors\\notepad++.exe\" \"%1\"")
    ;;debug: (for-each display (list "\nusers-file-command = '" users-file-command "'\n"))
    ;; and which executable is in the command line?
    (if (string? users-file-command)
     (if (string-contains-ci users-file-command "\\gvim.exe")
      (set! users-editor "gvim")
      (if (string-contains-ci users-file-command "\\notepad++.exe")
       (set! users-editor "notepad++")
       (if (string-contains-ci users-file-command "\\lilypad.exe")
        (set! users-editor "lilypad")
  ))))))
  (false-if-null users-editor)))

(define (get-editor)  
;;!! modified
  (or (getenv "LYEDITOR")
      (getenv "XEDITOR")
      (getenv "EDITOR")

      ;; FIXME: how are default/preferred editors specified on
      ;; different platforms?
      (case PLATFORM
        ((windows) (or (users-default-editor-on-windows)  
;;!! modified here
                       "lilypad"))  
;;!! modified here
        (else
         "emacs"))))


As originally in scm/editor.scm, the functions get-editor nor users-default-editor-on-windows have an argument to specify you're looking for the editor of a specific file extension other than ".ly".

ArnoldTheresius
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

Eluze
ArnoldTheresius wrote
Eluze wrote
...
maybe my hope to find the needed information in thess tables was to optimistic - does somebody know how the "correct" way is?

Eluze
Well, at least here is what I did try this weekend - posted before I read all messeages which were added in the meantime.
This code is still "dirty but quick, incomplete but big"
Editors 'context' and 'pspad' are still missing.
Hopefully still good enough for some testing.
hi Arnold

looks great! (but sorry - I can't test)

looking at the code, this seems to be quite the same approach as what I did in my batch (except that I didn't consult the HKLM)

now - as James pointed out - this will only deliver results if a program has explicitly been associated with an extension - can you confirm this!?

if so it'd be good to have LYEDITOR as a last resource for all people who don't (want or know how to) associate programs to extensions.

Also to clearify:
- Which of the listed editors are available for windows?
Crimson
gvim
notepad
notepad++
pspad
…???

I think we should maintain a table where you can read the line and column option.

- Which one needs to be started into the background (like lilypad)?
what do you mean exactly? (I can start: lilypad "d:\data\ly\test\test.ly"

after finding a viable way textedit and it's prerequisites should be documented clearer (in AU).

Eluze
Reply | Threaded
Open this post in threaded view
|

Re: Point and Click does not work on Windows

ArnoldTheresius
Eluze wrote
ArnoldTheresius wrote
Eluze wrote
...
maybe my hope to find the needed information in thess tables was to optimistic - does somebody know how the "correct" way is?

Eluze
Well, at least here is what I did try this weekend - posted before I read all messeages which were added in the meantime.
This code is still "dirty but quick, incomplete but big"
Editors 'context' and 'pspad' are still missing.
Hopefully still good enough for some testing.
hi Arnold

looks great! (but sorry - I can't test)

...
Also to clearify:
- Which of the listed editors are available for windows?
Crimson
gvim
notepad
notepad++
pspad
…???

I think we should maintain a table where you can read the line and column option.

- Which one needs to be started into the background (like lilypad)?
what do you mean exactly? (I can start: lilypad "d:\data\ly\test\test.ly"

after finding a viable way textedit and it's prerequisites should be documented clearer (in AU).

Eluze
Well, let's to back to the roots.

There is the problem "after installation of Lilypond point-and-click does not work out of the box". (without installation of an 'integrated development environment', e.g. frescobaldi)
I categorize this as 'bug'.
I located the problems to the windows installer and the file lilypond-invoke-editor in the bin directory of the windows installation.
Suggested solution is: changes in the installation script and in lilypond-invoke-editor
Result to obtain: Opens lilypad by point-and-click out of a pdf-viewer, e.g. Acrobat reader.
  If the environment variable LYEDITOR (or XEDITOR or EDITOR) is defined (supported values: emacs, gvim, uedit32, jedit ...),
  then this editor will be launched instead of lilypond.
  For testing you can enter the textedit command in the command interpreter (DOS shell), e.g. »C:\...\usr\bin\guile.exe -s C:\...\usr\bin\lilypond-invoke-editor textedit://C:/MyLilypondWorkDir/testfile.ly:17:9:9«
Unchanged standard behavior: If the editor is not in the search path for command line usage, you still have to qualify the complete call with all options in the environment variable.
 


Next Problem: "each time I click in the pdf a new tab is opened in my browser!" (Eluze, 2012-04-11, bugs/point and click implementation)
Also testable: the commandline execution listed above does not return until lilypad is closed.
I categorize this as 'usability or bug'.
Related Problem: support additional editors (on windows)
I categorize this as 'enhancement'.
I located: in file scm/editor.scm is an assiciation list 'editor-command-template-alist'.
Suggested solution is:
  Expand the association list 'editor-command-template-alist'
  On (eq? PLATFORM 'windows) use »start lilypad ...«
Result to obtain:
  new editors 'context', 'notepad++' and 'pspad' available (by specification in env. var. LYEDITOR)
  launch of lilypad does no longer create an empty tab in the browser, and executing the textedit command line in the command interpreter (DOS Shell) does no longer wait for lilypad.
Still to examine:
  Do other editor commands require the »start« prefix in windows? (most simple: command line check)
  I just tested 'gvim': no start prefix required.



Next Problem: "FIXME: how aore default/preferred editors specified on different paltforms?" (from scm/editor.scm)
              Try this for windows by reading from the windows registry.
Clearification in progress:
  Which the listed editors are available for windows:
    According to wikipedia these are: emacs, gvim, uedit32, gedit, jedit, syn, context, notepad++, pspad, and of course lilypad,
      while not availabe for windows is nedit.


TODO:
Who has emacs, uedit32, gedit, jedit, syn, context, notepad++ and/or pspad installed on his windows computer?
  Then correct the script lilypond-invoke-editor (see my mail form 2012-04-16), and make the command line check.
  Does it open the editor, and will the command prompt be back immediately or only after closing the editor window.

Are there other important methods known how to select the default editor in windows, and who they store this information (in the windows registry)?

Who will (and can off course) initiate the modification to the installer and the lilypond-invoke-editor script?


And some more information I found:

On https://github.com/janneke/gub/blob/master/nsis/lilypond-prepost.nsh I found in line 83:
  WriteRegExpandStr HKCR "textedit\shell\open\command" "" '"$INSTDIR\usr\bin\guile.exe" -e main -s "$INSTDIR\usr\bin\lilypond-invoke-editor.scm" "%1"'
Is this the installation script template used by the windows installer? Who may change it to
  WriteRegExpandStr HKCR "textedit\shell\open\command" "" '"$INSTDIR\usr\bin\guile.exe" -s "$INSTDIR\usr\bin\lilypond-invoke-editor" "%1"'
and make it take effect on the next unstable build?

In the same file you find the registry definitons
  ...\Lilypond\shell\edit\command "" = ... and ...\Lilypond\shell\generate\command "" = ...
This adds the additional right mouse button selections 'edit source' and 'generate PDF' to the context menu in the file explorer.
(Nice to know. Perhaps you can use it in another situation)

If the registry entry ...\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ly\userchoice contains in Progid a value
Applications\xxx.exe , then the command to open (including the full path to the binary) can be found in
...\Software\Classes\Applications\xxx.exe\shell\open\command
Since I just want to scan for the short name, I do not need the complete path.

The template for ...\bin\lilypond-invoke-editor seems to be scripts/lilypond-invoke-editor.scm in the source tarball.
The "-e main" option was removed from this file 2006-11-07.
Who will initiate the modifications there?


And finally:
I'll have a closer look to the documentation when the modifications for scm/editor.scm will be more clear.
The global default (for all operating systems) seems to be:
- Lilypond tries to evalute which editor you want to use - but the success will ever be limited, therfore
- you can define the environment variable LYEDITOR to select the editor to use.
- Set LYEDITOR to the short name of one of the predefined invoke editor syntax (e.g. emacs, gvim, lilypad - effectively listed in file scm/editor.scm) if this editor can be found by command line usage, i.e. its path is included in the search path.
- Otherwise set LYEDITOR to qualify the full path name AND all additional options for the textedit launch.

ArnoldTheresius
12