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: Gianmaria Lari
Subject: Re: The Guide to getting Point and Click going with Gvim under Ubuntu 18
Date: Thu, 28 Feb 2019 10:17:37 +0100

Ciao Andrew,

if I remember correctly you decided to use gvim instead of frescobaldi because of some performance problem, isn't it?
Anyway, in case you didn't yet do it, could you mention the pros and cons of both choice?

Thank you Andrew!
g.


On Mon, 25 Feb 2019 at 08:57, Andrew Bernard <address@hidden> wrote:
Hi All,

Federico has pointed out that it seems to be the season for people wanting to get point and click going (for some reason!). In the spirit of the season I offer the fruit of my work on this, trying to get it all going over the last week.

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

Andrew

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)
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

Setting LYEDITOR is not required.

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.


Installing Gvim
---------------

Gvim is in the following package, not a package called gvim.

# apt install vim-gtk3


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

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

[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

Check that this works. Install the gnome-open program:

$ sudo apt install libgnome2-bin

Then:

$ gnome-open textedit:///etc/issue:1:0:0

If all is correct lilypond-invoke-editor will run and display the file.


Configuring Ubuntu Apparmor for Evince
--------------------------------------

The Ubuntu mandatory access control system called Apparmor particular gaurds
with some ferocity the actions of Evince, so as to prevent malicious PDF's from
causing damage to the system. The apparmor configuration file for evince needs
to be modified. [The NR is lacking some crucial information here, which can
waste a lot of time as most people are not au fait with apparmor.]

As root, edit '/etc/apparmor.d/local/usr.bin.evince' to have the following
lines (it will most likely be an empty file):

# For Textedit links
#/usr/local/bin/lilypond-invoke-editor Cx -> sanitized_helper,
/home/andro/bin/lilypond-invoke-editor Cx -> sanitized_helper,

Note the comma on the end - this is not an error. Adjust the path as per the
exmaples to where your lilypond is installed.

Next, edit '/etc/apparmor.d/usr.bin.evince' and uncomment the line:

  # Site-specific additions and overrides. See local/README for details.
  include <local/usr.bin.evince>

[It's right at the end.] The local files provide for extending and adding
information to the base apparmor files without interfering with them, and
making system upgrades easier.

Reconfigure evince apparmor:

# apparmor_parser -r -T -W /etc/apparmor.d/usr.bin.evince

To update apparmor:

# systemctl reload apparmor

Many people are confused by this step so it's important to get it exactly
right, and be aware of which apparmor file is which - there are two files
involved.


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('+acd')||!&acd|if haslocaldir()|cd -|lcd -|elseif getcwd() ==# '/home/andro'|cd -|endif|endif
::1898:norm3|cal foreground()|if &im|star|en|redr|f 

And also 'Press ENTER or type command to continue'.

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.

[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.


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

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.




_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user

reply via email to

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