From 0db513c4d62525f3f2cbb6a6a9ca31d5f2a2160a Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 28 May 2015 15:43:12 +0200 Subject: [PATCH] Make case-changing lfuns operate on full words by default This is for people who cannot grasp the superior conventions of emacs ;) A new argument "partial" has been added to word-upcase, word-lowcase and word-capitalize that restores the old emacs-like behavior. The (x)emacs bindings are updated to use the "partial" argument, and also to bind correctly M-u and M-l (M-c is unfortunately not available). Fixes bug #2826. --- lib/RELEASE-NOTES | 29 ++++++------ lib/bind/emacs.bind | 10 +++++ lib/bind/xemacs.bind | 9 ++++ lib/doc/LFUNs.lyx | 104 +++++++++++++++++++++++++------------------ src/LyXAction.cpp | 25 +++++++---- src/Text.cpp | 9 ++-- src/Text.h | 2 +- src/Text3.cpp | 6 +-- 8 files changed, 121 insertions(+), 73 deletions(-) diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES index c03ffe5c30..ec105fdf73 100644 --- a/lib/RELEASE-NOTES +++ b/lib/RELEASE-NOTES @@ -14,19 +14,19 @@ * The prefix for subsections in labels and references has been changed from "sub:" to "subsec:" in order to avoid a clash with subfloats (conflicting - \subref command, see bug #7550). Files are automatically converted to the new - scheme. Please assure that you adapt external refstyle or prettyref definitions + \subref command, see bug #7550). Files are automatically converted to the new + scheme. Please assure that you adapt external refstyle or prettyref definitions and your own layout files. -* Support for printing from within LyX (File> Print) has been removed. LyX's - printing support was very limited, and most users will want to print after +* Support for printing from within LyX (File> Print) has been removed. LyX's + printing support was very limited, and most users will want to print after reviewing an output document (e.g., a PDF), anyway, which can be done from the - PDF viewer. - Users who would like to restore this functionality can create a "printer" - format from within LyX and then define, say, a pdf->printer converter that does - nothing but call lpd, or a2ps, or whatever. The "printer" will then be available - as an export option. - + PDF viewer. + Users who would like to restore this functionality can create a + "printer" format from within LyX and then define, say, a + pdf->printer converter that does nothing but call lpd, or a2ps, or + whatever. The "printer" will then be available as an export option. + !!!The following pref variables were added in 2.2: @@ -62,7 +62,7 @@ * \print_to_printer * \print_to_file * \print_file_extension: - These were used for print support, which has been removed. + These were used for print support, which has been removed. !!!The following new LyX functions have been introduced in 2.2: @@ -79,14 +79,17 @@ !!!The following LyX functions have been changed in 2.2: - +* word-upcase, word-lowcase and word-capitalize do not select the word + to operate on in the emacs way (that is, starting at cursor + position); this behaviour can be restored by using the argument + "partial". !!!The following LyX key bindings have been changed in 2.2: * For bindings where Control + {PgDn, PgUp} switches to the {next, previous} tab, Control + Shift + {PgDn, PgUp} moves the current tab to the {next, previous} tab. - + * The shortcuts for "bookmark-save x" have been changed from C-M-S-x to S-Fx ("x" stands for the number of the bookmark.) diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind index bfd42b448c..516976e10d 100644 --- a/lib/bind/emacs.bind +++ b/lib/bind/emacs.bind @@ -238,6 +238,10 @@ Format 2 \bind "M-period" "specialchar-insert dots" \bind "M-w" "copy" \bind "Escape" "meta-prefix" +\bind "M-u" "word-upcase partial" +\bind "M-l" "word-lowcase partial" +# This conflicts with the character menu. +#bind "M-c" "word-capitalize partial" # Numeric keypad (if Shift+KP_XXX does not switch the NumLock state) \bind "S-KP_Right" "char-right-select" @@ -269,3 +273,9 @@ Format 2 \bind_file latinkeys.bind \bind_file cyrkeys.bind \bind_file greekkeys.bind + +# the following bindings have to be adapted w.r.t. menus.bind +\bind "M-c Down" "word-lowcase partial" +\bind "M-c Up" "word-upcase partial" +\bind "M-c Right" "word-capitalize partial" + diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind index 4d1d8abfdb..7ccf816f2b 100644 --- a/lib/bind/xemacs.bind +++ b/lib/bind/xemacs.bind @@ -237,6 +237,10 @@ Format 2 \bind "M-period" "specialchar-insert dots" \bind "M-w" "copy" \bind "Escape" "meta-prefix" +\bind "M-u" "word-upcase partial" +\bind "M-l" "word-lowcase partial" +# This conflicts with the character menu. +#bind "M-c" "word-capitalize partial" # Numeric keypad (if Shift+KP_XXX does not switch the NumLock state) \bind "S-KP_Right" "char-right-select" @@ -355,3 +359,8 @@ Format 2 \bind_file latinkeys.bind \bind_file cyrkeys.bind \bind_file greekkeys.bind + +# the following bindings have to be adapted w.r.t. menus.bind +\bind "M-c Down" "word-lowcase partial" +\bind "M-c Up" "word-upcase partial" +\bind "M-c Right" "word-capitalize partial" diff --git a/lib/doc/LFUNs.lyx b/lib/doc/LFUNs.lyx index e36e00bad7..36ab901755 100644 --- a/lib/doc/LFUNs.lyx +++ b/lib/doc/LFUNs.lyx @@ -98,7 +98,7 @@ The LyX Team \end_layout \begin_layout Date -2014-11-14 +2015-05-28 \end_layout \begin_layout Section* @@ -1834,7 +1834,7 @@ alpha) \begin_inset Newline newline \end_inset - icon: icon of lfun used in toolbar + icon: icon of lfun used in toolbar or direct icon name \begin_inset Newline newline \end_inset @@ -3144,7 +3144,7 @@ Action Inserts various characters into the document. Syntax specialchar-insert \end_layout \begin_layout Description -Params : hyphenation, ligature-break, slash, nobreakdash, dots, end-of-sentence, menu-separator. +Params : hyphenation, ligature-break, slash, nobreakdash, dots, end-of-sentence, menu-separator, lyx, tex, latex, latex2e. \end_layout \begin_layout Description Origin JSpitzm, 6 Dec 2007 @@ -3154,7 +3154,7 @@ Origin JSpitzm, 6 Dec 2007 spelling-add \end_layout \begin_layout Description -Action Add the word under the cursor to the respective spell checker dictionary. +Action Add the word under the cursor to the respective spell checker dictionary. The default for the language is retrieved from the cursor position. \end_layout \begin_layout Description Syntax spelling-add [] [] @@ -3183,7 +3183,7 @@ Origin vfr, 24 March 2013 spelling-ignore \end_layout \begin_layout Description -Action Let the spell checker ignore the word under the cursor in the current session for the given language. +Action Let the spell checker ignore the word under the cursor in the current session for the given language. The default for the language is retrieved from the cursor position. \end_layout \begin_layout Description Syntax spelling-ignore [] [] @@ -3199,7 +3199,7 @@ Origin JSpitzm, 18 Jan 2010 spelling-remove \end_layout \begin_layout Description -Action Remove the word under the cursor from the respective spell checker dictionary. +Action Remove the word under the cursor from the respective spell checker dictionary. The default for the language is retrieved from the cursor position. \end_layout \begin_layout Description Syntax spelling-remove [] [] @@ -3357,10 +3357,13 @@ Syntax word-backward-select word-capitalize \end_layout \begin_layout Description -Action Capitalizes the words in the selection (i.e. the first letters) or the letter on the cursor position. +Action Capitalizes the words in the selection (i.e. the first letters) or the first letter of word at cursor position. \end_layout \begin_layout Description -Syntax word-capitalize +Syntax word-capitalize [] +\end_layout +\begin_layout Description +Params : if this is equal to "partial", then the default word starts at cursor position (emacs-style). Otherwise, the whole word is considered. \end_layout \begin_layout Subsection* @@ -3509,10 +3512,13 @@ Origin dov, 28 Oct 2007 word-lowcase \end_layout \begin_layout Description -Action Change the words in the selection or from the cursor position to the end of word to the lower case. +Action Change the words in the selection or word at cursor position to lower case. \end_layout \begin_layout Description -Syntax word-lowcase +Syntax word-lowcase [] +\end_layout +\begin_layout Description +Params : if this is equal to "partial", then the default word starts at cursor position (emacs-style). Otherwise, the whole word is considered. \end_layout \begin_layout Subsection* @@ -3588,10 +3594,13 @@ Origin Andre, 11 Sep 2002 word-upcase \end_layout \begin_layout Description -Action Change the words in the selection or from the cursor position to the end of word to the upper case. +Action Change the words in the selection or word at cursor position to upper case. \end_layout \begin_layout Description -Syntax word-upcase +Syntax word-upcase [] +\end_layout +\begin_layout Description +Params : if this is equal to "partial", then the default word starts at cursor position (emacs-style). Otherwise, the whole word is considered. \end_layout \begin_layout Subsection* @@ -4524,7 +4533,7 @@ Export buffers to PDF (pdflatex): \end_layout \begin_layout Description -Origin scottkostyshak, 20 Jul 2012 +Origin skostysh, 20 Jul 2012 \end_layout \begin_layout Subsection* @@ -4559,6 +4568,32 @@ Params : language name. See lib/languages for list. Origin leeming, 30 Mar 2004 \end_layout +\begin_layout Subsection* +buffer-move-next +\end_layout +\begin_layout Description +Action Moves the current tab one spot to the right. +\end_layout +\begin_layout Description +Syntax buffer-move-next +\end_layout +\begin_layout Description +Origin skostysh, 7 Apr 2015 +\end_layout + +\begin_layout Subsection* +buffer-move-previous +\end_layout +\begin_layout Description +Action Moves the current tab one spot to the left. +\end_layout +\begin_layout Description +Syntax buffer-move-previous +\end_layout +\begin_layout Description +Origin skostysh, 7 Apr 2015 +\end_layout + \begin_layout Subsection* buffer-new \end_layout @@ -4630,36 +4665,6 @@ Action Switch to the previous opened document. Syntax buffer-previous \end_layout -\begin_layout Subsection* -buffer-print -\end_layout -\begin_layout Description -Action Prints the current document. -\end_layout -\begin_layout Description -Notion Many settings can be given via the preferences dialog. -\end_layout -\begin_layout Description -Syntax buffer-print -\end_layout -\begin_layout Description -Params is either "printer" or "file". -\begin_inset Newline newline -\end_inset - - is either "default" or file name or printer name. -\begin_inset Newline newline -\end_inset - - command ensuring the printing job. -\end_layout -\begin_layout Description -Sample buffer-print file "/trash/newfile1.ps" "dvips" -\end_layout -\begin_layout Description -Origin leeming, 28 Mar 2004 -\end_layout - \begin_layout Subsection* buffer-reload \end_layout @@ -4769,6 +4774,19 @@ Syntax buffer-view [] Params : The format to display, where this is one of the formats defined (in the current GUI) in the Tools>Preferences>File Formats dialog. If no format is given, the default format as specified in the same dialog is used. \end_layout +\begin_layout Subsection* +buffer-view-cache +\end_layout +\begin_layout Description +Action Opens the file that was created from last preview of this buffer. +\end_layout +\begin_layout Description +Notion This LFUN is called by the "Show Output Anyway" button in the LaTeX Errors dialog. It can also be called by the user, which is useful if the document takes a long time to compile, and you just want to see the last previewed version. +\end_layout +\begin_layout Description +Syntax buffer-view-cache +\end_layout + \begin_layout Subsection* buffer-write \end_layout diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index de0e0e8081..fd90f3e55a 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1000,24 +1000,33 @@ void LyXAction::init() /*! * \var lyx::FuncCode lyx::LFUN_WORD_CAPITALIZE * \li Action: Capitalizes the words in the selection (i.e. the first letters) - or the letter on the cursor position. - * \li Syntax: word-capitalize + or the first letter of word at cursor position. + * \li Syntax: word-capitalize [] + * \li Params: : if this is equal to "partial", then the + * default word starts at cursor position (emacs-style). + * Otherwise, the whole word is considered. * \endvar */ { LFUN_WORD_CAPITALIZE, "word-capitalize", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_WORD_UPCASE - * \li Action: Change the words in the selection or from the cursor position - to the end of word to the upper case. - * \li Syntax: word-upcase + * \li Action: Change the words in the selection or word at cursor position + to upper case. + * \li Syntax: word-upcase [] + * \li Params: : if this is equal to "partial", then the + * default word starts at cursor position (emacs-style). + * Otherwise, the whole word is considered. * \endvar */ { LFUN_WORD_UPCASE, "word-upcase", Noop, Edit }, /*! * \var lyx::FuncCode lyx::LFUN_WORD_LOWCASE - * \li Action: Change the words in the selection or from the cursor position - to the end of word to the lower case. - * \li Syntax: word-lowcase + * \li Action: Change the words in the selection or word at cursor position + to lower case. + * \li Syntax: word-lowcase [] + * \li Params: : if this is equal to "partial", then the + * default word starts at cursor position (emacs-style). + * Otherwise, the whole word is considered. * \endvar */ { LFUN_WORD_LOWCASE, "word-lowcase", Noop, Edit }, diff --git a/src/Text.cpp b/src/Text.cpp index 889c21b7f4..e30cd7446d 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -1489,20 +1489,19 @@ void Text::deleteWordBackward(Cursor & cur) // Kill to end of line. -void Text::changeCase(Cursor & cur, TextCase action) +void Text::changeCase(Cursor & cur, TextCase action, bool partial) { LBUFERR(this == cur.text()); CursorSlice from; CursorSlice to; - bool gotsel = false; - if (cur.selection()) { + bool const gotsel = cur.selection(); + if (gotsel) { from = cur.selBegin(); to = cur.selEnd(); - gotsel = true; } else { from = cur.top(); - getWord(from, to, PARTIAL_WORD); + getWord(from, to, partial ? PARTIAL_WORD : WHOLE_WORD); cursorForwardOneWord(cur); } diff --git a/src/Text.h b/src/Text.h index 7aed1655f0..d7777e3ac3 100644 --- a/src/Text.h +++ b/src/Text.h @@ -242,7 +242,7 @@ public: /// bool selectWordWhenUnderCursor(Cursor & cur, word_location); /// Change the case of the word at cursor position. - void changeCase(Cursor & cur, TextCase action); + void changeCase(Cursor & cur, TextCase action, bool partial); /// Transposes the character at the cursor with the one before it void charsTranspose(Cursor & cur); diff --git a/src/Text3.cpp b/src/Text3.cpp index 4261ab8201..6dbd4d5a15 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1291,15 +1291,15 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) } case LFUN_WORD_UPCASE: - changeCase(cur, text_uppercase); + changeCase(cur, text_uppercase, cmd.getArg(0) == "partial"); break; case LFUN_WORD_LOWCASE: - changeCase(cur, text_lowercase); + changeCase(cur, text_lowercase, cmd.getArg(0) == "partial"); break; case LFUN_WORD_CAPITALIZE: - changeCase(cur, text_capitalization); + changeCase(cur, text_capitalization, cmd.getArg(0) == "partial"); break; case LFUN_CHARS_TRANSPOSE: