* spelling-remove-local removes words for a given language from the document's local
spelling dictionary.
+
+* index-tag-all adds a copy of the index entry under cursor to after all occurrences of the
+ word that precedes the index inset.
* inset-insert-copy inserts the inset's content (in ToC pane) at the position of the cursor.
\end_layout
\begin_layout Verbatim
+
This is Verbatim.
\end_layout
\begin_layout Verbatim
\noindent
\align block
+
The following 2 lines are empty:
\end_layout
\end_layout
\begin_layout Verbatim
+
Almost everything is allowed in Verbatim:"%&$ยง#~'`
\backslash
}][{|
\end_layout
\begin_layout Verbatim*
+
This is Verbatim*.
\end_layout
arg "index-insert"
\end_inset
+
+\change_inserted -712698321 1667668430
+ (but see section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:Convenience-Functions-Index"
+
+\end_inset
+
+ for some advanced methods)
+\change_unchanged
.
A
-\change_inserted -712698321 1667110584
+\change_inserted -712698321 1667665903
collapsible inset
\change_unchanged
\change_deleted -712698321 1667110543
box
-\change_inserted -712698321 1667110812
+\change_inserted -712698321 1667665903
with green label
\change_unchanged
is inserted
-\change_inserted -712698321 1667110886
+\change_inserted -712698321 1667665903
; this
\change_unchanged
\change_deleted -712698321 1667110903
contain
-\change_inserted -712698321 1667110904
+\change_inserted -712698321 1667665903
holds
\change_deleted -712698321 1667110872
ing
\change_unchanged
the text that appears in the index
-\change_inserted -712698321 1667112993
+\change_inserted -712698321 1667665903
(if you read this in \SpecialChar LyX
, see the
\begin_inset Quotes eld
\change_unchanged
.
The word where the cursor is in
-\change_inserted -712698321 1667112984
+\change_inserted -712698321 1667665903
,
\change_unchanged
or the currently highlighted text
-\change_inserted -712698321 1667112984
+\change_inserted -712698321 1667665903
,
\change_unchanged
is proposed by \SpecialChar LyX
the
\change_unchanged
index entry
-\change_inserted -712698321 1667112984
+\change_inserted -712698321 1667665903
(i.
\begin_inset space \thinspace{}
\end_inset
\end_layout
+\begin_layout Subsection
+
+\change_inserted -712698321 1667669398
+\begin_inset CommandInset label
+LatexCommand label
+name "subsec:Convenience-Functions-Index"
+
+\end_inset
+
+Convenience Functions for Index Handling
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1667669552
+Indexing a document can be a tedious task, since you often have to insert
+ the same index entry multiple times in order to refer to passages at different
+ pages.
+ This is not only time-consuming, but also error-prone; e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g., you have to remember how exactly an inset entry has been inserted to
+ avoid redundant entries.
+ \SpecialChar LyX
+ provides some functions to ease the task.
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1667669398
+First, if you want to add an entry which you already used before, you can
+ open the outliner via
+\family sans
+View\SpecialChar menuseparator
+Outline Pane
+\family default
+ (see section
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "subsec:The-Outliner"
+
+\end_inset
+
+), select the
+\family sans
+Index Entries
+\family default
+ section (it is convenient to have this open while indexing anyway), scroll
+ to the entry in question (if you check
+\family sans
+Sort
+\family default
+, it will be more easier), then
+\emph on
+right
+\emph default
+-click on the entry and select
+\family sans
+Insert Copy at Cursor Position
+\family default
+ from the context menu.
+ This will do just what it says: it will insert a copy of that index inset
+ at the position where the cursor is.
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1667669772
+Second, \SpecialChar LyX
+ also provides a semi-automated solution to index a word.
+ If you right-click on an index entry inset, you can select from the context
+ menu
+\family sans
+Index All Occurrences of this Word
+\family default
+.
+ This will search the whole document (only single documents, not master
+ and child documents) and insert a copy of this index inset after each occurrenc
+e of the word that precedes the inset.
+ Note that casing of the word does not matter, but only full words in the
+ same grammatical form are considered (so if
+\emph on
+table
+\emph default
+ is the word before the index entry,
+\emph on
+Table
+\emph default
+ will be considered as well, but not
+\emph on
+tables
+\emph default
+).
+ Please take care to not overuse this function and to carefully check the
+ result afterwards.
+ Remember, a good index does not simply list all occurrences of a given
+ word in a specific document (that is a concordance rather), but only relevant
+ occurrences! So as convenient as this function might seem, it is suitable
+ especially for particular cases.
+ With others, you will have more work with removing again falsely inserted
+ entries than you would have with manually inserting them at the right place.
+\end_layout
+
\begin_layout Subsection
Index
\change_deleted -712698321 1667120869
Menu "context-index"
IndicesContext
Separator
+ Item "Index All Occurrences of this Word|W" "index-tag-all"
+ Separator
OptItem "Single Page (No Page Range)|P" "inset-modify changeparam range none"
OptItem "Start Page Range|t" "inset-modify changeparam range start"
OptItem "End Page Range|E" "inset-modify changeparam range end"
#include "MetricsInfo.h"
#include "Paragraph.h"
#include "Session.h"
+#include "texstream.h"
#include "Text.h"
#include "TextMetrics.h"
#include "TexRow.h"
#include "insets/InsetCitation.h"
#include "insets/InsetCommand.h" // ChangeRefs
#include "insets/InsetGraphics.h"
+#include "insets/InsetIndex.h"
#include "insets/InsetRef.h"
#include "insets/InsetText.h"
break;
}
+ case LFUN_INDEX_TAG_ALL: {
+ Inset * ins = cur.nextInset();
+ if (!ins || ins->lyxCode() != INDEX_CODE)
+ // not at index inset
+ break;
+
+ // clone the index inset
+ InsetIndex * cins =
+ new InsetIndex(static_cast<InsetIndex &>(*cur.nextInset()));
+ // In order to avoid duplication, we compare the
+ // LaTeX output if we find another index inset after
+ // the word
+ odocstringstream oilatex;
+ otexstream oits(oilatex);
+ OutputParams rp(&cur.buffer()->params().encoding());
+ ins->latex(oits, rp);
+ cap::copyInsetToTemp(cur, cins);
+
+ // move backwards into preceding word
+ // skip over other index insets
+ cur.backwardPosIgnoreCollapsed();
+ while (true) {
+ if (cur.inset().lyxCode() == INDEX_CODE)
+ cur.pop_back();
+ else if (cur.prevInset() && cur.prevInset()->lyxCode() == INDEX_CODE)
+ cur.backwardPosIgnoreCollapsed();
+ else
+ break;
+ }
+ if (!cur.inTexted()) {
+ // Nothing to do here.
+ setCursorFromInset(ins);
+ break;
+ }
+ // Get word or selection
+ cur.text()->selectWord(cur, WHOLE_WORD);
+ docstring const searched_string = cur.selectionAsString(false);
+ // Start from the beginning
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_BEGIN));
+ while (findOne(this, searched_string,
+ false,// case sensitive
+ true,// match whole word only
+ true,// forward
+ false,//find deleted
+ false,//check wrap
+ false,// auto-wrap
+ false,// instant
+ false// only selection
+ )) {
+ cur.clearSelection();
+ Inset * ains = cur.nextInset();
+ if (ains && ains->lyxCode() == INDEX_CODE) {
+ // We have an index inset.
+ // Check whether it has the same
+ // LaTeX content and move on if so.
+ odocstringstream filatex;
+ otexstream fits(filatex);
+ ains->latex(fits, rp);
+ if (oilatex.str() == filatex.str())
+ continue;
+ }
+ // Paste the inset and possibly continue
+ cap::pasteFromTemp(cursor(), cursor().buffer()->errorList("Paste"));
+ }
+ // Go back to start position.
+ setCursorFromInset(ins);
+ dr.screenUpdate(cur.result().screenUpdate());
+ if (cur.result().needBufferUpdate())
+ dr.forceBufferUpdate();
+ break;
+ }
+
case LFUN_MARK_OFF:
cur.clearSelection();
dr.setMessage(from_utf8(N_("Mark off")));
LFUN_BRANCH_SYNC_ALL, // sanda 20220415
LFUN_INDEXMACRO_INSERT, // spitz 20220220
LFUN_INSET_INSERT_COPY, // spitz 20221101
+ LFUN_INDEX_TAG_ALL, // spitz 20221105
+ // 395
LFUN_LASTACTION // end of the table
};
*/
{ LFUN_INDEX_INSERT, "index-insert", Noop, Edit },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_INDEX_TAG_ALL
+ * \li Action: Tags all occurrences of the word before the cursor with the
+ * index inset at cursor.
+ * \li Notion: It automatically takes the word on the cursor position.
+ * \li Syntax: index-tag-all
+ * \li Origin: spitz, 5 Nov 2022
+ * \endvar
+ */
+ { LFUN_INDEX_TAG_ALL, "index-tag-all", AtPoint, Edit },
+
/*!
* \var lyx::FuncCode lyx::LFUN_INDEX_PRINT
* \li Action: Inserts list of Index entries on a new page.
class InsetCollapsible;
class InsetCommand;
class InsetGraphics;
+class InsetIndex;
class InsetIterator;
class InsetLayout;
class InsetList;
virtual InsetCommand const * asInsetCommand() const { return nullptr; }
/// is this inset based on the InsetArgument class?
virtual InsetArgument const * asInsetArgument() const { return nullptr; }
+ /// is this inset based on the InsetIndex class?
+ virtual InsetIndex const * asInsetIndex() const { return nullptr; }
/// is this inset based on the InsetGraphics class?
virtual InsetGraphics * asInsetGraphics() { return nullptr; }
/// is this inset based on the InsetGraphics class?
case LFUN_INDEXMACRO_INSERT:
return macrosPossible(cmd.getArg(0));
+ case LFUN_INDEX_TAG_ALL:
+ return true;
+
default:
return InsetCollapsible::getStatus(cur, cmd, flag);
}
const InsetIndexParams& params() const { return params_; }
///
int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
+ ///
+ InsetIndex const * asInsetIndex() const override { return this; }
private:
///
bool hasSettings() const override;