The attached patch strips date-insert (and the related rc entry and
helper functions) from master. The function is obsoleted by the more
flexible and powerful date info-insets.

Objections?
Jürgen
diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index 2a1157eea5..9fa91e3c88 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -29,6 +29,10 @@
 * \use_qimage
   This is no longer necessary due to the rewrite of the painter.
 
+* \date_insert_format
+  The function date-insert has been removed and superseded by info-insert date.
+  The latter does not need a pref value anymore.
+
 
 !!!The following new LyX functions have been introduced in 2.4:
 
@@ -42,6 +46,11 @@
 * info-insert buffer vcs-*: renamed to info-insert vcs *
 
 
+!!!The following LyX functions have been removed in 2.4:
+
+* date-insert: obsoleted by info-insert date.
+
+
 
 !!!The following LyX documents have been moved in 2.4:
 
diff --git a/lib/scripts/prefs2prefs_lfuns.py b/lib/scripts/prefs2prefs_lfuns.py
index 2ffb7f1d74..ec65f97925 100644
--- a/lib/scripts/prefs2prefs_lfuns.py
+++ b/lib/scripts/prefs2prefs_lfuns.py
@@ -217,6 +217,10 @@ def info_rename_vcstreerevision(line):
 	return simple_renaming(line, "info-insert buffer vcs-tree-revision", "info-insert vcs tree-revision")
 
 
+def remove_date_insert(line):
+	return simple_remove(line, "date-insert")
+
+
 #
 ###########################################################
 
@@ -253,6 +257,7 @@ conversions = [
 		info_rename_vcsdate,
 		info_rename_vcstime,
 		info_rename_vcsrevision,
-		info_rename_vcstreerevision
+		info_rename_vcstreerevision,
+		remove_date_insert
 	]]
 ]
diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py
index 8ea20723ab..5e7c0bf627 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -111,6 +111,9 @@
 # Incremented to format 27, by spitz
 #   Add optional flavor value to needaux flag
 
+# Incremented to format 28, by spitz
+#   Remove date_insert_format
+
 # NOTE: The format should also be updated in LYXRC.cpp and
 # in configure.py.
 
@@ -405,6 +408,11 @@ def remove_font_encoding(line):
 		return no_match
 	return (True, "")
 
+def remove_date_insert_format(line):
+	if not line.lower().startswith("\\date_insert_format "):
+		return no_match
+	return (True, "")
+
 # End conversions for LyX 2.3 to 2.4
 ####################################
 
@@ -446,5 +454,6 @@ conversions = [
 	[ 24, [rename_collapsible]],
 	[ 25, [remove_use_qimage]],
 	[ 26, [remove_font_encoding]],
-	[ 27, []]
+	[ 27, []],
+	[ 28, [remove_date_insert_format]]
 ]
diff --git a/src/FuncCode.h b/src/FuncCode.h
index 7b8fedc435..3798786018 100644
--- a/src/FuncCode.h
+++ b/src/FuncCode.h
@@ -241,7 +241,7 @@ enum FuncCode
 	LFUN_PREFERENCES_SAVE,
 	LFUN_HELP_OPEN,                 // Jug 990627
 	// 175
-	LFUN_DATE_INSERT,               // jdblair 20000131
+	LFUN_LAYOUT_TOGGLE,             // lasgouttes 20180514
 	LFUN_LANGUAGE,                  // Dekel 20000203
 	LFUN_ERT_INSERT,                // Jug 20000218
 	LFUN_FOOTNOTE_INSERT,           // Jug 20000307
@@ -479,9 +479,8 @@ enum FuncCode
 	LFUN_BUFFER_ANONYMIZE,          // sanda, 20180201
 	LFUN_GRAPHICS_UNIFY,            // sanda, 20180207
 	LFUN_MASTER_BUFFER_EXPORT,      // rkh, 20180417
-	LFUN_LAYOUT_TOGGLE,             // lasgouttes 20180514
-	// 375
 	LFUN_INSET_END_EDIT,            // gb/rkh, 20180605
+	// 375
 	LFUN_LASTACTION                 // end of the table
 };
 
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 4f424883f7..43f4e80a99 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -1365,19 +1365,6 @@ void LyXAction::init()
  */
 		{ LFUN_CUT, "cut", Noop, Edit },
 
-/*!
- * \var lyx::FuncCode lyx::LFUN_DATE_INSERT
- * \li Action: Inserts the current date.
- * \li Syntax: date-insert [<ARG>]
- * \li Params: <ARG>: Format of date. The default value (%x) can be set
-                      in Preferences->Output->General->Date format. For
-                      possible formats see the manual page of the
-                      strftime function.
- * \li Origin: jdblair, 31 Jan 2000
- * \endvar
- */
-		{ LFUN_DATE_INSERT, "date-insert", Noop, Edit },
-
 /*!
  * \var lyx::FuncCode lyx::LFUN_DEBUG_LEVEL_SET
  * \li Action: Set debug output level.
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 5e8d38c798..d11181fcc5 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -59,7 +59,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 27; // spitz: add flavor value to needaux flag
+static unsigned int const LYXRC_FILEFORMAT = 28; // spitz: remove \\date_insert_format
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
 	{ "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -92,7 +92,6 @@ LexerKeyword lyxrcTags[] = {
 	{ "\\copier", LyXRC::RC_COPIER },
 	{ "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
 	{ "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
-	{ "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
 	{ "\\def_file", LyXRC::RC_DEFFILE },
 	{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
 	{ "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
@@ -311,7 +310,6 @@ void LyXRC::setDefaults()
 	show_banner = true;
 	windows_style_tex_paths = false;
 	tex_allows_spaces = false;
-	date_insert_format = "%x";
 	cursor_follows_scrollbar = false;
 	scroll_below_document = false;
 	scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
@@ -917,9 +915,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
 			if (lexrc.next())
 				default_length_unit = (Length::UNIT) lexrc.getInteger();
 			break;
-		case RC_DATE_INSERT_FORMAT:
-			lexrc >> date_insert_format;
-			break;
 		case RC_LANGUAGE_CUSTOM_PACKAGE:
 			lexrc >> language_custom_package;
 			break;
@@ -1592,15 +1587,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
 		if (tag != RC_LAST)
 			break;
 		// fall through
-	case RC_DATE_INSERT_FORMAT:
-		if (ignore_system_lyxrc ||
-		    date_insert_format != system_lyxrc.date_insert_format) {
-			os << "\\date_insert_format \"" << date_insert_format
-			   << "\"\n";
-		}
-		if (tag != RC_LAST)
-			break;
-		// fall through
 	case RC_USER_NAME:
 		os << "\\user_name \"" << user_name << "\"\n";
 		if (tag != RC_LAST)
@@ -2913,7 +2899,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
 	case LyXRC::RC_COPIER:
 	case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
 	case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
-	case LyXRC::RC_DATE_INSERT_FORMAT:
 	case LyXRC::RC_GUI_LANGUAGE:
 	case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT:
 	case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT:
@@ -3153,11 +3138,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
 		str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
 		break;
 
-	case RC_DATE_INSERT_FORMAT:
-		//xgettext:no-c-format
-		str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
-		break;
-
 	case RC_DEFFILE:
 		str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
 		break;
diff --git a/src/LyXRC.h b/src/LyXRC.h
index b499c7aebf..8a371d902c 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -66,7 +66,6 @@ public:
 		RC_COPIER,
 		RC_CURSOR_FOLLOWS_SCROLLBAR,
 		RC_CURSOR_WIDTH,
-		RC_DATE_INSERT_FORMAT,
 		RC_DEFAULT_DECIMAL_POINT,
 		RC_DEFAULT_LENGTH_UNIT,
 		RC_DEFAULT_OTF_VIEW_FORMAT,
@@ -357,8 +356,6 @@ public:
 	///
 	std::string lyxpipes;
 	///
-	std::string date_insert_format;
-	///
 	std::string language_custom_package;
 	///
 	bool language_auto_begin;
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 7d1142c139..918064c336 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1750,14 +1750,6 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 		break;
 	}
 
-	case LFUN_DATE_INSERT: {
-		string const format = cmd.argument().empty()
-			? lyxrc.date_insert_format : to_utf8(cmd.argument());
-		string const time = formatted_time(current_time(), format);
-		lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, time));
-		break;
-	}
-
 	case LFUN_MOUSE_TRIPLE:
 		if (cmd.button() == mouse_button::button1) {
 			tm->cursorHome(cur);
@@ -3271,13 +3263,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
 		enable = !inDescriptionItem(cur);
 		break;
 
-	case LFUN_DATE_INSERT: {
-		string const format = cmd.argument().empty()
-			? lyxrc.date_insert_format : to_utf8(cmd.argument());
-		enable = support::os::is_valid_strftime(format);
-		break;
-	}
-
 	case LFUN_LANGUAGE:
 		enable = !cur.paragraph().isPassThru();
 		flag.setOnOff(cmd.getArg(0) == cur.real_current_font.language()->lang());
diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp
index f79d4d3f28..c08245c858 100644
--- a/src/frontends/qt4/GuiPrefs.cpp
+++ b/src/frontends/qt4/GuiPrefs.cpp
@@ -349,35 +349,6 @@ static void setComboxFont(QComboBox * cb, string const & family,
 }
 
 
-/////////////////////////////////////////////////////////////////////
-//
-// StrftimeValidator
-//
-/////////////////////////////////////////////////////////////////////
-
-class StrftimeValidator : public QValidator
-{
-public:
-	StrftimeValidator(QWidget *);
-	QValidator::State validate(QString & input, int & pos) const;
-};
-
-
-StrftimeValidator::StrftimeValidator(QWidget * parent)
-	: QValidator(parent)
-{
-}
-
-
-QValidator::State StrftimeValidator::validate(QString & input, int & /*pos*/) const
-{
-	if (is_valid_strftime(fromqstr(input)))
-		return QValidator::Acceptable;
-	else
-		return QValidator::Intermediate;
-}
-
-
 /////////////////////////////////////////////////////////////////////
 //
 // PrefOutput
@@ -389,12 +360,9 @@ PrefOutput::PrefOutput(GuiPreferences * form)
 {
 	setupUi(this);
 
-	DateED->setValidator(new StrftimeValidator(DateED));
 	dviCB->setValidator(new NoNewLineValidator(dviCB));
 	pdfCB->setValidator(new NoNewLineValidator(pdfCB));
 
-	connect(DateED, SIGNAL(textChanged(QString)),
-		this, SIGNAL(changed()));
 	connect(plaintextLinelengthSB, SIGNAL(valueChanged(int)),
 		this, SIGNAL(changed()));
 	connect(overwriteCO, SIGNAL(activated(int)),
@@ -430,19 +398,8 @@ PrefOutput::PrefOutput(GuiPreferences * form)
 }
 
 
-void PrefOutput::on_DateED_textChanged(const QString &)
-{
-	QString t = DateED->text();
-	int p = 0;
-	bool valid = DateED->validator()->validate(t, p)
-		     == QValidator::Acceptable;
-	setValid(DateLA, valid);
-}
-
-
 void PrefOutput::applyRC(LyXRC & rc) const
 {
-	rc.date_insert_format = fromqstr(DateED->text());
 	rc.plaintext_linelen = plaintextLinelengthSB->value();
 	rc.forward_search_dvi = fromqstr(dviCB->currentText());
 	rc.forward_search_pdf = fromqstr(pdfCB->currentText());
@@ -467,7 +424,6 @@ void PrefOutput::applyRC(LyXRC & rc) const
 
 void PrefOutput::updateRC(LyXRC const & rc)
 {
-	DateED->setText(toqstr(rc.date_insert_format));
 	plaintextLinelengthSB->setValue(rc.plaintext_linelen);
 	dviCB->setEditText(toqstr(rc.forward_search_dvi));
 	pdfCB->setEditText(toqstr(rc.forward_search_pdf));
@@ -3440,7 +3396,6 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 	addModule(new PrefLanguage(this));
 	addModule(new PrefSpellchecker(this));
 
-	//for strftime validator
 	PrefOutput * output = new PrefOutput(this);
 	addModule(output);
 	addModule(new PrefLatex(this));
@@ -3464,9 +3419,6 @@ GuiPreferences::GuiPreferences(GuiView & lv)
 	bc().setApply(buttonBox->button(QDialogButtonBox::Apply));
 	bc().setCancel(buttonBox->button(QDialogButtonBox::Cancel));
 	bc().setRestore(buttonBox->button(QDialogButtonBox::Reset));
-
-	// initialize the strftime validator
-	bc().addCheckedLineEdit(output->DateED);
 }
 
 
diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h
index 4f564992d9..d6f7602113 100644
--- a/src/frontends/qt4/GuiPrefs.h
+++ b/src/frontends/qt4/GuiPrefs.h
@@ -163,9 +163,6 @@ public:
 
 	virtual void applyRC(LyXRC & rc) const;
 	virtual void updateRC(LyXRC const & rc);
-
-private Q_SLOTS:
-	void on_DateED_textChanged(const QString &);
 };
 
 
diff --git a/src/frontends/qt4/ui/PrefOutputUi.ui b/src/frontends/qt4/ui/PrefOutputUi.ui
index 0c24c05fbe..890d6ea773 100644
--- a/src/frontends/qt4/ui/PrefOutputUi.ui
+++ b/src/frontends/qt4/ui/PrefOutputUi.ui
@@ -192,39 +192,12 @@
         </item>
        </layout>
       </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_7">
-        <item>
-         <widget class="QLabel" name="DateLA">
-          <property name="text">
-           <string>&amp;Date format:</string>
-          </property>
-          <property name="buddy">
-           <cstring>DateED</cstring>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QLineEdit" name="DateED">
-          <property name="sizePolicy">
-           <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-            <horstretch>0</horstretch>
-            <verstretch>0</verstretch>
-           </sizepolicy>
-          </property>
-          <property name="toolTip">
-           <string>Date format for strftime output</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
       <item>
        <layout class="QHBoxLayout" name="horizontalLayout_8">
         <item>
diff --git a/src/support/lyxtime.cpp b/src/support/lyxtime.cpp
index 5415ac4eeb..f3318eb3f0 100644
--- a/src/support/lyxtime.cpp
+++ b/src/support/lyxtime.cpp
@@ -31,15 +31,6 @@ time_t current_time()
 }
 
 
-string const formatted_time(time_t t, string const & fmt)
-{
-	struct tm * loc_tm = localtime(&t);
-	char date[50];
-	strftime(date, sizeof(date), fmt.c_str(), loc_tm);
-	return string(date);
-}
-
-
 docstring formatted_datetime(time_t t, string const & fmt)
 {
 	QString qres;
diff --git a/src/support/lyxtime.h b/src/support/lyxtime.h
index bc545b8c5d..05cbc50841 100644
--- a/src/support/lyxtime.h
+++ b/src/support/lyxtime.h
@@ -24,13 +24,6 @@ namespace support {
 
 time_t current_time();
 
-/** Returns a locale-dependent formatting of the date
- *  and time encoded in \c time. The \p fmt string
- *  holds the formatting arguments of \c strftime.
- *  Prefer the function formatted_datetime below.
- */
-std::string const formatted_time(time_t t, std::string const & fmt);
-
 /** Returns a locale-dependent formatting of the date and time encoded in \c t
  *  The \p fmt string holds the formatting arguments of QDateTime::toString().
  *  If fmt is empty then the formatting of the date and time is itself according
diff --git a/src/support/os.h b/src/support/os.h
index 9b38e4e44e..07d6d7ba76 100644
--- a/src/support/os.h
+++ b/src/support/os.h
@@ -111,9 +111,6 @@ std::string latex_path(std::string const & p);
  */
 std::string latex_path_list(std::string const & p);
 
-/// Checks if the format string is suitable on the OS
-bool is_valid_strftime(std::string const & p);
-
 /** Returns a string suitable to be passed to popen when
  *  reading a file.
  */
diff --git a/src/support/os_unix.cpp b/src/support/os_unix.cpp
index 5a6c21fe63..34cfd478a6 100644
--- a/src/support/os_unix.cpp
+++ b/src/support/os_unix.cpp
@@ -193,23 +193,6 @@ string latex_path_list(string const & p)
 }
 
 
-bool is_valid_strftime(string const & p)
-{
-	string::size_type pos = p.find_first_of('%');
-	while (pos != string::npos) {
-		if (pos + 1 == string::npos)
-			break;
-		if (!containsOnly(p.substr(pos + 1, 1),
-			"aAbBcCdDeEFgGhHIjklmMnOpPrRsStTuUVwWxXyYzZ%+"))
-			return false;
-		if (pos + 2 == string::npos)
-		      break;
-		pos = p.find_first_of('%', pos + 2);
-	}
-	return true;
-}
-
-
 char const * popen_read_mode()
 {
 	return "r";

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to