On 11/16/23 13:43, Richard Kimberly Heck wrote:
On 11/16/23 09:22, Pavel Sanda wrote:
On Thu, Nov 16, 2023 at 02:00:29PM +0100, Jean-Marc Lasgouttes wrote:
I do not have time for a detailed comment, but you should really take a hard
look at branches. They are an incredibly useful tool.
I agree. Just for a inspiration I attach how 3 different branches can be used for 3 different types of notes with the use of local layout.

Can you post an example file? I'm not getting it. It's really quite fantastic if it works.

Found the problem: The use of right_note, with the underscore, seems not to work. The InsetLayout gets converted to "Branch:read note", with a space, and then we try to look up "Branch:read_note", with the underscore. I don't remember why we replace the underscores with spaces, but this is old behavior.

We seem to need something like the attached.

LabelString does not have any effect for me, and looking at the code it's clear why. Pavel, do you have some local patch that makes that work? Should it work? Easy to do, I think.

And it is quite fantastic. I was not aware you could embed branch content in a command or an environment. It's something I've seen asked for, and I've always thought it wasn't possible yet.

Riki

From 891a2880f449b65f3135cbe0e0928bb6aeb6ec2f Mon Sep 17 00:00:00 2001
From: Richard Kimberly Heck <rikih...@lyx.org>
Date: Thu, 16 Nov 2023 14:03:34 -0500
Subject: [PATCH] Fix layout names for branches

---
 src/insets/InsetBranch.cpp | 8 ++++++++
 src/insets/InsetBranch.h   | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp
index 505871834f..af4140bcca 100644
--- a/src/insets/InsetBranch.cpp
+++ b/src/insets/InsetBranch.cpp
@@ -338,6 +338,14 @@ string InsetBranch::contextMenuName() const
 }
 
 
+docstring InsetBranch::layoutName() const
+{
+	docstring const name = support::subst(branch(), '_', ' ');
+	return from_ascii("Branch:") + name;
+}
+
+
+
 bool InsetBranch::isMacroScope() const
 {
 	// Its own scope if not selected by buffer
diff --git a/src/insets/InsetBranch.h b/src/insets/InsetBranch.h
index 16e5524e23..e2b2958f18 100644
--- a/src/insets/InsetBranch.h
+++ b/src/insets/InsetBranch.h
@@ -114,7 +114,7 @@ private:
 	///
 	void doDispatch(Cursor & cur, FuncRequest & cmd) override;
 	///
-	docstring layoutName() const override { return from_ascii("Branch:") + branch(); }
+	docstring layoutName() const override;
 	///
 	Inset * clone() const override { return new InsetBranch(*this); }
 
-- 
2.41.0

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to