Attached is a patch with a detailed commit message, and a screenshot of
the paths preferences tab with the patch.

Any thoughts?

Scott
From a2cb63c10cc6a7978c914ff50ff45db97598d9d5 Mon Sep 17 00:00:00 2001
From: Scott Kostyshak <skost...@lyx.org>
Date: Sun, 17 Jul 2016 04:57:39 -0400
Subject: [PATCH 1/2] Rel. path in paths prefs preserved as rel. paths

Before this commit, in the paths preferences tab if you put a
relative path, LyX would convert it behind the scenes to an absolute
path by evaluating the relative path with respect to the working
directory of the LyX instance where the preference change is taking
place. This seems confusing because (1) it is done behind the scenes
(after the preferences dialog is closed) and (2) if the user chooses
to enter a relative path, the safest thing to do is to preserve it
as a relative path, instead of making the assumption that the user
intended for it to be expanded to an absolute path.

Because the behavior of paths is consistent for all paths, we do not
need an explanation for idiosyncratic treatment of paths in
individual tooltips, thus the tooltip for TEXINPUTS prefix is
simplified. An explanation of how relative paths are handled is
given at the bottom of the paths tab. Note that the height/width of
the preferences window is not changed as a result of adding this
explanatory comment because the height of the preferences dialog is
already stretched by other tabs.

Another dimension of consistency that is achieved with this commit
is that the behavior of LyX is now the same when a relative path is
specified in the preferences dialog as when it is manually specified
in the preferences file. Before, if the preferences file were
manually edited and a relative path were inserted, the next time the
user made a change to preferences with the GUI (even if the
preference change was a different preference, e.g. instant preview),
the relative path would be silently converted to an absolute path,
evaluated with respect to the working directory of that instance.

Beyond improving clarity and consistency (IMO), this commit allows
for a new feature to be implemented of using relative paths in the
paths preferences. For example, the user may now enter '.' as the
"Working directory" path and now whenever they start LyX from a
directory and create a new file, the default location of the file
will be the directory from which they started LyX, instead of the
user's home directory, which is LyX's default and is less intuitive.

No prefs2prefs work is needed because if a relative path were
entered in the preferences dialog before this commit, it was
converted to an absolute path before being stored in preferences. If
a relative path were specified by manually editing the preferences
file, then (unless the path were already automatically converted to
an absolute path by a GUI preferences change, as described above)
the behavior will be the same (the path will be treated as a
relative path).

For related discussion, see the lyx-devel thread here:
https://www.mail-archive.com/search?l=mid&q=20160616003010.bnymtcouar7g55ti%40cotopaxi

This commit removes the last use of lyx::support::expandPath() in
LyX's sources.
---
 src/LyXRC.cpp                       | 32 ++++++++------------------------
 src/frontends/qt4/ui/PrefPathsUi.ui | 20 +++++++-------------
 2 files changed, 15 insertions(+), 37 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 8b7c3b3..4f5516a 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -632,45 +632,33 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
                        break;
 
                case RC_DOCUMENTPATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                document_path = 
os::internal_path(lexrc.getString());
-                               document_path = expandPath(document_path);
-                       }
                        break;
 
                case RC_EXAMPLEPATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                example_path = 
os::internal_path(lexrc.getString());
-                               example_path = expandPath(example_path);
-                       }
                        break;
 
                case RC_TEMPLATEPATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                template_path = 
os::internal_path(lexrc.getString());
-                               template_path = expandPath(template_path);
-                       }
                        break;
 
                case RC_TEMPDIRPATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                tempdir_path = 
os::internal_path(lexrc.getString());
-                               tempdir_path = expandPath(tempdir_path);
-                       }
                        break;
 
                case RC_THESAURUSDIRPATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                thesaurusdir_path = 
os::internal_path(lexrc.getString());
-                               thesaurusdir_path = 
expandPath(thesaurusdir_path);
-                       }
                        break;
 
                case RC_HUNSPELLDIR_PATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                hunspelldir_path = 
os::internal_path(lexrc.getString());
-                               hunspelldir_path = expandPath(hunspelldir_path);
-                       }
                        break;
 
                case RC_USELASTFILEPOS:
@@ -811,10 +799,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
                        break;
 
                case RC_SERVERPIPE:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                lyxpipes = os::internal_path(lexrc.getString());
-                               lyxpipes = expandPath(lyxpipes);
-                       }
                        break;
 
                case RC_CURSOR_FOLLOWS_SCROLLBAR:
@@ -899,10 +885,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
                        lexrc >> save_origin;
                        break;
                case RC_BACKUPDIR_PATH:
-                       if (lexrc.next()) {
+                       if (lexrc.next())
                                backupdir_path = 
os::internal_path(lexrc.getString());
-                               backupdir_path = expandPath(backupdir_path);
-                       }
                        break;
                case RC_DEFAULT_DECIMAL_POINT:
                        lexrc >> default_decimal_point;
diff --git a/src/frontends/qt4/ui/PrefPathsUi.ui 
b/src/frontends/qt4/ui/PrefPathsUi.ui
index 3d80efd..de1aa07 100644
--- a/src/frontends/qt4/ui/PrefPathsUi.ui
+++ b/src/frontends/qt4/ui/PrefPathsUi.ui
@@ -20,20 +20,14 @@
     <number>6</number>
    </property>
    <item row="12" column="0" colspan="3" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Expanding</enum>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Relative and absolute paths are allowed. Relative paths will be 
expanded with respect to the directory from which you start LyX, and thus could 
change for each LyX session. The path "." (without quotes) is a common example 
of a relative path and refers to the directory from which LyX is run.</string>
      </property>
-     <property name="sizeHint" stdset="0" >
-      <size>
-       <width>329</width>
-       <height>16</height>
-      </size>
+     <property name="wordWrap">
+      <bool>true</bool>
      </property>
-    </spacer>
+    </widget>
    </item>
    <item row="10" column="0" >
     <widget class="QLabel" name="pathPrefixLA" >
@@ -65,7 +59,7 @@
    <item row="11" column="1" colspan="2">
     <widget class="QLineEdit" name="texinputsPrefixED">
      <property name="toolTip">
-      <string>Specify those directories which should be prepended to the 
TEXINPUTS environment variable. A '.' represents the current document 
directory. Use the OS native format.</string>
+      <string>Specify those directories which should be prepended to the 
TEXINPUTS environment variable. Use the OS native format.</string>
      </property>
     </widget>
    </item>
-- 
2.7.4

Attachment: signature.asc
Description: PGP signature

Reply via email to