lilypond-user
[Top][All Lists]
Advanced

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

Re: The Guide to getting Point and Click going with Gvim under Ubuntu 18


From: David Wright
Subject: Re: The Guide to getting Point and Click going with Gvim under Ubuntu 18
Date: Thu, 28 Feb 2019 15:41:56 -0600
User-agent: NeoMutt/20170113 (1.7.2)

On Wed 27 Feb 2019 at 10:36:49 (+0100), Federico Bruni wrote:
> First review after trying your tutorial in Fedora (for the purpose of
> adapting these instructions for the Usage manual).
> Fedora doesn't use AppArmor. I don't have SELinux enabled, so I'm not
> sure if that might be a problem.

A few comments from the point of view of Debian (stretch) with no
gnome or other desktop, just fvwm. No SELinux or apparmor either.

> Il giorno lun 25 feb 2019 alle 8:56, Andrew Bernard <address@hidden> ha 
> scritto:

> > I hope this may be able to be incorporated into the NR. If not,
> > it's here now in the archives for future reference.

> > The Guide to getting Point and Click going with Gvim under Ubuntu 18
> > --------------------------------------------------------------------
> > 
> > The NR leaves out some important information about how to configure a Ubuntu
> > system to use Gvim for point and click from Lilypond PDF files.
> > Where the NR is substantially correct, that information is copied here.
> > 
> > Requirements
> > ------------
> > 
> > Ubuntu 18.10
> > Document Viewer (evince)

My observations apply to both evince and zathura in equal measure.

> > gvim version 8.0 (vim-gtk3 package)
> > [assumes bash shell]
> > 
> > Setting the EDITOR variable
> > ---------------------------
> > 
> > Lilypond uses the environment variable EDITOR to select which editor to use 
> > to
> > display point and click links. For gvim, simply use the value 'gvim':
> > 
> > export EDITOR=gvim

Use this even where you are using vim as the actual editor.

> > Setting LYEDITOR is not required.

I too have found no use for LYEDITOR, but see further below.

> > You can start evince from a terminal command to view a PDF. But if you want 
> > to
> > click on a PDF in GNOME Nautilus to view it then just exporting this 
> > variable
> > from the various bash startup files is inadequate. Gnome is started by 
> > Xsession
> > in X11 before terminals and shells. Therefore it is unable to see 
> > environment
> > variables set in .bashrc (or .bash_profile, etc). To resolve this matter,
> > recall that Xsession uses the startup file $HOME/.xsessionrc. For 
> > environment
> > variables that are to be shared between GNOME applications and terminal 
> > shells,
> > do the following. Create a file for variable declarations, of arbitrary 
> > name.
> > Add the EDITOR setting to that file:
> > 
> >  $ echo 'export EDITOR=gvim' > ~/.my_env_vars
> > 
> > Then edit ~/.xsessionrc to contain:
> > 
> > if [ -f ~/.my_env_vars ]; then
> >     . ~/.my_env_vars
> > fi
> > 
> > Now also add these same lines to ~/.bashrc. Some like to use .bash_profile 
> > or
> > other mechanisms, but the principle is the same. Manage any shared variables
> > that Nautilus and a bash shell both need in this third file. To make this 
> > take
> > effect, logout and login again so that a new Xsession is started.
> > 
> 
> In Fedora GNOME is able to read environment variables defined in
> .bashrc or .bash_profile.
> You just need to logout and login again.

Yes, this is something that really comes down to the distribution
you're using, and needs sorting out regardless of point-and-click,
LilyPond and anything else.

And if you have control over command invocations, as I do, you can
just specify EDITOR=foo at the beginning of the commandline.
Aliasing this also works.

> > Installing Gvim
> > ---------------
> > 
> > Gvim is in the following package, not a package called gvim.
> > 
> > # apt install vim-gtk3
> > 
> In Fedora it's called vim-X11.

vim-gtk in Debian.

> > Configuring the GNOME 3 Desktop
> > -------------------------------

This step is required to make evince and zathura call the editor,
and has nothing to do with whether you actually run gnome or a DE.

> > Create the file 'lilypond-invoke-editor.desktop':

This file will likely be installed in at least two locations, so to
save having yet another copy lying around, you can use /tmp as the
working directory.

> > [Desktop Entry]
> > Version=1.0
> > Name=lilypond-invoke-editor
> > GenericName=Textedit URI handler
> > Comment=URI handler for textedit:
> > Exec=lilypond-invoke-editor %u
> > Terminal=false
> > Type=Application
> > MimeType=x-scheme-handler/textedit;
> > Categories=Editor
> > NoDisplay=true
> > 
> > Run:
> > 
> > $ xdg-desktop-menu install ./lilypond-invoke-editor.desktop
> > $ xdg-mime default lilypond-invoke-editor.desktop x-scheme-handler/textedit

On Debian, that creates/modifies:

~/.config/menus/applications-merged/xdg-desktop-menu-dummy.menu
~/.gnome/apps/lilypond-invoke-editor.desktop
~/.local/share/applications/lilypond-invoke-editor.desktop
~/.local/share/applications/defaults.list
~/.local/share/applications/mimeapps.list

> > Check that this works. Install the gnome-open program:
> > 
> > $ sudo apt install libgnome2-bin
> > 
> > Then:
> > 
> > $ gnome-open textedit[…]
> > 
> > If all is correct lilypond-invoke-editor will run and display the file.
> 
> No need to install libgnome2-bin. You should use xdg-open, which
> _should_ be available in all modern Linux installations. (package
> xdg-utils, at least in Fedora)

Ditto in Debian: xdg-open in xdg-utils.

I don't know what gnome-open does, but before issuing
$ xdg-open textedit:[…]
you should start your editor server, else you may see an E247
error. However, with gvim this is harmless because the gvim
instance that starts up is a server version and will handle
future point-and-clicks. This may not be the case for emacs,
where you need to issue    ESC x server-start
after which the same applies.

> > Configuring Gvim
> > ----------------
> > 
> > Not all users see this problem, but if you do, it is hard to solve if you 
> > don't
> > know. On a plain new gvim install, every time you click on a lilypond grob
> > under the setup described here, the following rather daunting error message 
> > is
> > shown, and you have to press ENTER to continue, each time.
> > 
> > :if !exists […]
> > 
> > And also 'Press ENTER or type command to continue'.
> 
> Yep, I see this problem.

Ditto Debian.

> > The solution to this is to change the size of the message display
> > in gvim. Add
> > the following to ~/.gvimrc:
> > 
> > if exists('+cmdheight') && (&ch < 2)
> >   set ch=2
> > endif
> > 
> > You may need to set the height to 3, depending on various sizes.

While you're about it, add the same lines to ~/.vimrc as well.

> > [As for why some people do not see this issue, I am unclear.]
> > 
> > A Personal Preference
> > ---------------------
> > 
> > Because gvim comes by default with mouse enabled, and this is a useful 
> > feature,
> > if you click in the window after lilypond-invoke-editgor has set the cursor
> > position in the file, the cursor will move to the mouse click. You can 
> > either
> > disable mouse in gvim, or do what I prefer which is to use the GNOME Tweaks
> > tool in Ubuntu and change the window behaviour to be 'focus on hover'. This 
> > is
> > a personal matter.

Yes, I don't mind this behaviour with the mouse, but what's important
to me (in emacs) is that pasting is done at "point" (the blob in the
text), not at where you click with the mouse. That's achieved with
(setq mouse-yank-at-point t)
in emacs's startup file.

> All the other editors I tried automatically get the window focus, so
> you can start editing the .ly file immediately after click. I think
> this is a must. Any way to set this in Gvim?

Ah, perhaps now I understand why Andrew mentioned clicking here at all:
is it to get focus to switch to the editor? My Debian/fvwm observations
on point-and-clicking:

emacs:

If the editor is running in a window, and that window is in a
different viewport, fvwm will move to that viewport. Focus, however,
will always remain under the mouse cursor, which doesn't move on the
screen. (Like Andrew, I have MouseFocus on all windows except for
things like clocks etc.)
If emacs is running in an xterm, fvwm takes no part in the process.

gvim:

Behaves like a non-windowed emacs: nothing happens.

If you want focus to move in a case where it doesn't, I think
foxfanfare cracked this by inserting a   wmctrl -a   command
into the editor call. foxfanfare put some work into this call
in order to support multiple instances of viewer/editor pairs,
which also involved not relying on the default GVIM servername.
I don't know whether this depends on using LYEDITOR as opposed
to EDITOR.

  lists.gnu.org/archive/html/lilypond-user/2019-02/msg00423.html

> > Running Gvim and Evince
> > -----------------------
> > 
> > Run gvim in server mode by doing - exactly nothing! Simply running gvim will
> > start the process in a new window. From the terminal this suffixes:
> > 
> > $ gvim

On Debian, there's actually no need to run gvim at all! Just ignore
the E247 error when you first point-and-click, and a fully-formed
server instance of gvim will be created.

> > By default gvim will respond to remote requests such as from
> > lilypond-invoke-editor. There is no need to use the --servername option
> > as the name defaults to GVIM (and you can see this in the title bar). By
> > default lilypond sends point and click requests to the gvim server named 
> > GVIM.
> > 
> > Run evince from the shell or by clicking on a PDF file in Nautilus. Now
> > clicking on a grob will take you to the line and column where that object 
> > is in
> > the lilypond source file.
> 
> That's true.

However, if you want vim to run as vim in an xterm (ie not gvim in a
window), then you do need to specify the servername GVIM [sic] or this
instance of vim will be ignored (and a windowed version created).

$ vim --servername GVIM

I don't know whether there's a vim command equivalent of server-start
in emacs.

Finally, it's point-and-doubleclick in zathura, rather than point-and-click.

Cheers,
David.



reply via email to

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