From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?B?6Lev5a6i?= Newsgroups: gmane.emacs.devel Subject: [ELPA] New package "brief" editor emulator is now officially released Date: Mon, 13 Aug 2018 23:12:17 +0800 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001445690573528775" X-Trace: blaine.gmane.org 1534173103 28102 195.159.176.226 (13 Aug 2018 15:11:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 13 Aug 2018 15:11:43 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 13 17:11:39 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fpEVO-0007Bm-No for ged-emacs-devel@m.gmane.org; Mon, 13 Aug 2018 17:11:39 +0200 Original-Received: from localhost ([::1]:39980 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpEXT-0005qA-LD for ged-emacs-devel@m.gmane.org; Mon, 13 Aug 2018 11:13:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpEWi-0005po-Uq for emacs-devel@gnu.org; Mon, 13 Aug 2018 11:13:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpEWe-0005tz-GW for emacs-devel@gnu.org; Mon, 13 Aug 2018 11:13:00 -0400 Original-Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:33234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fpEWd-0005tH-Ve for emacs-devel@gnu.org; Mon, 13 Aug 2018 11:12:56 -0400 Original-Received: by mail-ed1-x52f.google.com with SMTP id x5-v6so8463916edr.0 for ; Mon, 13 Aug 2018 08:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=XFkris+tu9/9Fzpxl9xwkQH7OJzZDF92fSD+mwHNeLI=; b=qs7F+1osO04wI1meGGCquGZFHkC5PcoVP4ArZYlWVfurkIVRhjzV7mgJ1VOxR8dQNw LGVmX2EkaYx3c+7T/nbUEpM/fUhJGkDJ5x2dlRj5q9PG0kwCOk8tB00TmC9aBNIl+CpV n7gzSg7yOlmD/patlZMNmbAcUzohY8oHpMkxVpoErLZCX58cEUV/Kg5cn9Enqqzn5eUP cNxUdpGLyhGRaY69uCfW7Zmwgf2U3aIfgxWs0O7lTVNDpV6yxPDS30csYP53a1Esvlwu kOI8UsyOlnw6tF18AGF3aKH6OYOK1o/xQ0wSJbl1F2FFonLGZgwiPwajSHt4bUhnWPtI +KLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XFkris+tu9/9Fzpxl9xwkQH7OJzZDF92fSD+mwHNeLI=; b=IRMIzhLyBk89qqjctE5SDqhwdw4YisnjgFV9uni75hH8rpZO4SSjnVi7ApSSD1OrBQ 7KnF8Jt0SFoxgkZYFOQDkUyGymzQl3L7ZSnrxXZ3DA6qETr3JwIm6+SYTcw6yilAT9v2 y16PD6VoI1+bBP1Afqrf4WdLzqLCfriqS4sOCxVHnmlToUwEHTMueuUOiVYr9WXC32o+ R3khFr8+YPgmxoPJkjKcN71e0h5VpCXX7QI1Eq+VDlsOeIyuwTTQ8u7Fn8OtvO4Cq+ld cjKRSj6kAwyHRbozVs1OzSQjlRqc11UuFSJ1JZ9ma1VR+04r/MMSuC6c/eAvSn9+yJYY 1x7Q== X-Gm-Message-State: AOUpUlEQRRB7FzSy4DTafK4piTEM5F0FhT0RwK9Dcw7rLWeSyEaYrelC Ue56L9RSsB51yUNxQKtwKIhW56HijZInhmrn5drkepQA X-Google-Smtp-Source: AA+uWPzttYoVP/maZzMw7cTHeRE1COZWWi3D/Swh3oW5FiCRkQigad6b2QM2tChshlGdiC+ncDb94THYrOfWwoGBdQs= X-Received: by 2002:a50:ac65:: with SMTP id w34-v6mr23174033edc.211.1534173174314; Mon, 13 Aug 2018 08:12:54 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228484 Archived-At: --0000000000001445690573528775 Content-Type: text/plain; charset="UTF-8" New package "brief" is now officially released in master packages/brief. The temporary branch scratch/brief is deleted. Hope you enjoy it! ----- the following duplicates yesterday's post ----- Brief editor is back! New package Brief editor mode, for emulating the Brief editor, is added inELPA master branch. Actually, it already reached v5.80, but it never reached a stage that I consider releasable till now, after 17+ years. History: ------------- Starting from 31 May 2001 I started modifying XEmacs CRiSP mode emulator for my own use on Linux, in order to get a similar finger-feel like the MS-DOS-based Brief editor which I had been using for ~10 years at that time. Those days around 2001 the MS-DOS backward compatibility was getting worse and worse for every MS-Windows release and which forced me to find a free replacement for Brief. Then I found the XEmacs+CRiSP mode that seems to be the best candidate at that moment. It implemented at least the basic Brief editor functionality but far from a complete emulator. Therefore I started doing modifications and adding missing Brief features on a per-need basis. After 17+ years of intermittent development (as the release of version 5.80), the code is almost completely rewritten compare to the original XEmacs CRiSP mode code. A lot of editor behaviors were also adapted to Emacs. One example is that Brief mode emulator could respect `visual-line-mode', `toggle-truncate-lines' and hidden/abbreviated mode texts (which usually shown as "..." in Emacs) such as org-mode, hideshow mode and hideif (hide "#ifdef", conditional compilation units, another package that I had rewritten). When texts are hidden at cursor line, Brief line-oriented commands like line-cut, line-copy, line-deletion ... will operate on all hidden lines. Brief Extension: ------------------------ This Brief mode extends a lot of functionalities that the original Brief editor don't have. For example, the original Brief -<-> (C--) kills current buffer; however, when prefixed with - (C-u) the -<-> (C--) command will restore the just killed buffer. This is convenient as sometimes user accidentally hit C-- for some reason and lost the buffer. Another simple example is the original Brief command - (M-f) which shows the file name of the current buffer; while prefixed with C-u it will also copy the file name into the clipboard. The following sections list some of the major extensions of this extended Brief mode. * Visual mode, line truncation and hidden texts: (config option: `brief-linecmd-respect-visual') In the original DOS Brief editor, press [home] key once brings the cursor to the beginning of the current line; a second [home] key to the top of the window and the third [home] to the beginning of the file. In Emacs it's a bit different; it has `toggle-truncate-lines' to wrap long lines and `visual-line-mode' to do smart word-warp. This Brief mode emulator thus adapted to Emacs accordingly: if long lines are wrapped, the first [home] keystroke brings the cursor to the beginning of the "visual line"; a second [home] then brings the cursor to the beginning of the "physical line". The third [home] to the top of the window and finally the fourth [home] to the beginning of the file. When `toggle-truncate-lines' is enabled and `visual-line-mode' is off, Brief mode then behaves the same as DOS Brief. Similar behavior applies to the [end] key, as well as many other keyboard commands like clipboard copy/paste functions. This further leads to an user-customizable option: `brief-linecmd-respect-visual'. This customized variable determines if a user would like to have line commands (like line-copy, line-cut, line-deletion...) by default respect visual mode or not. That variable is by default nil and thus line commands will by default operate on "physical" line(s) instead of "visual" lines. They can be overridden by a common prefix C-u or a negative prefix number. See the comments of the function `brief-is-visual-operation' for more detail. Basically, the rules are: 1. `brief-linecmd-respect-visual' determines the current default mode, either visual or physical line mode. 2. Either a common prefix C-u (\\[universal-argument]) or negative prefix reverse the current mode; aka, (not `brief-linecmd-respect-visual'). Example: Try editing a text using line deletion command [M-d] on some very long lines a few times longer than the window width (or shrink window size), or an org-mode document with long lines. Now either turn on `visual-line-mode' or enable line wrapping using `toggle-truncate-lines'. Assuming `brief-linecmd-respect-visual' is kept default value 'nil' which means physical line operations are expected by default, now try the following key combinations: 1. [M-d] : delete one "physical" line. 2. [C-u] [M-d] : delete one "visual" line. 3. [C-4] [M-d] : delete four "physical" lines as it's prefixed with integer '4'. 4. [C-u] [-] [4] [M-d] : delete four "visual" lines as it's prefixed with integer '-4'. On the other hand, cursor movement always respects visual mode unless prefixed with C-u or negative prefix number. * Fast line number computation cache: (config option: `brief-replace-emacs-func:line-number-at-pos') Brief editor window operation relies heavily on cursor position to determine which window is going to be operated. As the original Emacs line number computation is too slow (especially when a lot of texts are hidden within a window) so a line counting caching mechanism is implemented. By default, the original Emacs function `line-number-at-pos' is replaced by `brief-fast-line-number-at-pos' if Emacs version is older than 27 where native line numbering is not yet supported. There is actually a custom variable named `brief-replace-emacs-func:line-number-at-pos' defined near the end of this file. It controls if the `line-number-at-pos' is going to be replaced or not, regardless of the Brief mode is on or off. It is recommended to keep the default value for fast line number calculation which helps Linum mode as well, otherwise, you might experience big slow down when switching windows using Brief window commands (i.e. [F1-] key). * Huge clipboard/Xselection texts: (config option: `brief-enable-postpone-selection') In the following context and code the term Xselection and clipboard are used interchangeably and refer to the same thing - the XWindow selection (mainly "primary" and "clipboard", "secondary" is not used) or the Windows clipboard. This emulator tries to sync kill- ring with Xselection even in terminal mode (Xterm). This Brief mode also implements an asynchronous mechanism to prevent the selected texts from immediately going into the Xselection, as all (most) *NIX GUI program currently do -- any marked/selected text got copied into Xselection with no delay. This helps to boost performance a lot especially when huge texts (say, 500Mb texts) are being selected. There is no point to keep copying texts into clipboard before user completed the text selection. When the user tries to enlarge the huge selection area, copying texts into clipboard could take very long and the system seems to stop responding. The auto-repeated cursor movement key commands are then accumulated into the key queue and make things worse. Our Brief mode does not immediately copy texts into Xselection until the cursor movement key is released, which usually means a user has completed (say, at least temporarily) the selection. Unfortunately, this key-releasing event cannot be seen within Emacs Lisp so we workaround this by detecting if the keyboard is idle or not. Functions are called asynchronously by the idle timer. There is also another important reason for doing so, on Xservers running on MS Windows with MS office running in the background, this problem is fatal and usually caused a system crash in the end. With this selection postponement, we prevented that. For more detail description about the MS problem, please search the comments in the following source code containing "Xselection Postponement:". The solution is not perfect but works for most cases. A custom option `brief-enable-postpone-selection' is defined to control if the selection postponement is enabled or not. By default, it's turned on. * External Xselection helper programs `xsel' and `xclip': (config option: `brief-use-external-clipboard-when-possible') In order to further boost the performance when a user selects huge texts, external Xselection helper programs are used, although it increased the complexity of the asynchronous event handling. The main reason is that the internal Emacs Xselection code is un-interruptible and not quit-able. When Emacs tries to get/set Xselection, the operation is blocking and Emacs is not responding to any key before the operation completes. For example, when a user selects some huge texts using arrow keys and paused a short period of time then try to continue enlarging/ shrinking the selection area using arrow keys, the previous Emacs Xselection get/set operation is usually not completed yet (due to the size of huge text). Therefore the attempt to continue enlarging/shrinking texts will be blocked and user will experience no response until Emacs completed the Xselection operation. What's more, those continued arrow keys then in turn queued in the Xwindow system. When Emacs eventually resume responding, the selection area will be changed accordingly to some earlier keys in the queue that the user typed a few seconds ago. This kind of non-real-time response usually confuse the user and sometimes cause problems. To workaround this we implemented our own non-blocking and quit-able Xselection get/set functions, with the help of external X utilities like `xsel' or `xclip'. Therefore user needs to install `xsel' or `xclip' in the *NIX system to get the benefit. If neither xsel nor xclip is installed, it will fall back using the Emacs internal blocking Xselection code. With our non-blocking implementation, when a user tries to enlarge/shrink/quit a huge text selection while the Xselection gets/sets operation is in-progress, the unfinished operation will be interrupted immediately. A user gets an immediate response. A custom variable `brief-use-external-clipboard-when-possible' (by default 't) controls if this Brief mode would invoke external helper or not. For further detail consult the help message for function `brief-external-set-selection' and `brief-external-get-selection'. There are also a few other configuration options controlling if the progress is showing in the message area or not: `brief-show-external-clipboard-recv-progress' `brief-show-external-clipboard-send-progress' ... With these two options, the user can see the progress when big clipboard data are transferring. Also, notice that for terminal mode Emacs under X running Brief mode the external helpers are always invoked in order to copy/paste texts with any other windowed mode applications. * Fast cursor movement: What I like most about the old DOS Brief editor is its super fast cursor movement. On a lot of occasions, I didn't even need to do page-up or page-down. Once you get used to the cursor speed you really don't want to return to the normal speed. Unfortunately, this cannot be done in Emacs. However, there is an alternative way to achieve similar effect -- setting X keyboard autorepeat rate using the command line `xset' X utility: # xset r rate 255 100 Although it's still not as fast as DOS Brief editor, it's at least closer. Also, notice that this will affect the global X window environment. Key Binding Compatibility Note: --------------------------------------------- Notice that the original brief commands keypad-'+' (copy line) and keypad-'-' (cut line) are now duplicated into - (copy line) and - (cut line). This is mainly for keyboards and notebooks without a keypad. As both - (M-n) and -

(M-p) are so widely used in various Emacs modes so in the Brief mode M-n and M-p are assigned "weakly". This means any major mode can override the assignment of M-n and M-p. In Brief mode, M-n is used for switching to next buffer while M-- for the previous buffer. Both of them are frequently used commands, therefore, we also weakly assigned M-+ and M-= for M-n and M-_ for M--. However, for M-p (brief-print) we do not provide other key combinations for the same key. For line marking commands, as Emacs regions always start/end at cursor so the Brief mode region commands - (M-L prefixed arrow keys) behave a bit differently from the original Brief ones (unless I implemented it using the secondary Xselection, which could lead to more issues). This Brief mode does not immediately mark the current line until the followed arrow key user typed. Also, the 'paste' command key also insert keys starting from the cursor position instead of the beginning of current line. On the other hand, 'copy line', 'cut line' and 'delete line' commands work on the beginning of current line like the original Brief editor did. For a complete keybinding list, check the following source code commented with "Brief mode key bindings". Platform Compatibility Notes: ----------------------------------------- This brief mode is mainly tested for X window system, as there are too many combinations of versions (EmacsVers x {OSes} x {XServers}) need to be tested but I don't have all environments (and time). Therefore, I mainly tested recent Emacs versions on Linux machines on a daily use basis. For other combinations listed below they are not heavily tested; usually tested when they are been used. Test Matrix (note: all 64-bit systems): On Linux: (including native X11 Emacs, terminal mode Emacs on xterm and Linux X11 Emacs running on VcXsrv (1.19.3.4+) under Win10): Emacs 23.3.1, 24.4.50.2, 25.2.2, 26.0.50, 26.1 and 27.0.50. Mainly focusing on Emacs 25 ~ 27. For Emacs23 and 24, not all the functionality behaves the same as in Emacs 25 ~ 27 (ex. search/replace in region/rectangle). On Cygwin: Emacs 25.3.1, 26.1. On Win10: Emacs 25.1.1 (x86_64-w64-mingw32). On WSL (Windows Subsystem for Linux): Emacs 24.5.1, terminal mode and on VcXsrv (1.19.3.4+). Enabling Brief Mode: ------------------------------ Enable this package by putting "(require 'brief)" in your .emacs and "(brief-mode 1)" to enable it. If you want to toggle it later interactively just use "M-x brief-mode" to toggle it on or off. Notice that "M-x" may be overridden if `brief-override-meta-x' is set to non-nil (default value) when you enable brief mode. In this case use function key #10 "F10 brief-mode" to toggle it off. The default keybindings for Brief mode override the M-x key to exit the editor. If you don't like this functionality, you can prevent this behavior (or redefine it dynamically) by customizing the value of `brief-override-meta-x' either in your .emacs or interactively. The default setting is t, which means that M-x will by default by default run `save-buffers-kill-emacs' instead of the command `execute-extended-command'. It is recommended to load the Ibuffer package "(require 'ibuffer)" before or after loading Brief mode. "M-b" will invoke ibuffer to show buffer menu if ibuffer package presents, otherwise it by default runs `buffer-menu'. This package will automatically load the "scroll-lock.el" package if you put "(setq brief-load-scroll-lock t)" in your .emacs before loading this package. If this feature is enabled, it will bind "" to the scroll-lock mode toggle. The scroll-lock package provides the scroll-locking feature in Brief. Finally, if you want to change the string displayed in the modeline when this mode is in effect, override the definition of `brief-mode-mode-line-string' in your .emacs. The default value is " Brief" which may be a bit lengthy if you have a lot of things being displayed there. All these overrides should go *before* the (require 'brief) statement. Cygwin 2.x Users: ------------------------- When the default "mintty" application is used to lunch Cygwin, if you would like to run Emacs with Brief mode enabled in mintty's special terminal mode, some mintty window settings need to be changed: 1. Right-click in the Cygwin "mintty" window on the title bar 2. Choose "Options" 3. At the left sided pane choose "Keys" category 4. Disable (uncheck) the following shortcuts: Copy and Paste (Ctrl/Shift+Ins) Switch window (Ctrl+[Shift+]Tab) Zoom (Ctrl+plus/minus/zero) Alt+Fn shortcuts Ctrl+Shift+letter shortcuts 5. Click 'Apply' and 'Save' -- Best regards, Luke Lee --0000000000001445690573528775 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

New package "brief" is now officially relea= sed in master packages/brief.
The temporary branch scratch/brief = is deleted.
Hope you enjoy it!

-----= the following duplicates yesterday's post -----

Brief editor is back!

New package Brief ed= itor mode, for emulating the Brief editor, is added
inELPA m= aster branch.=C2=A0 Actually, it already reached v5.80, but it
never reached a stage that I consider releasable till now, after 17+
years.

=C2=A0History:
------------= -

Starting from 31 May 2001 I started modifying XE= macs CRiSP mode
emulator for my own use on Linux, in order to get a simi= lar
finger-feel like the MS-DOS-based Brief editor which I had been
u= sing for ~10 years at that time.=C2=A0 Those days around 2001 the
MS-DOS= backward compatibility was getting worse and worse for
every MS-Windows= release and which forced me to find a free
replacement for Brief.=C2=A0= Then I found the XEmacs+CRiSP mode that
seems to be the best candidate = at that moment.=C2=A0 It implemented at
least the basic Brief editor fun= ctionality but far from a complete
emulator.=C2=A0 Therefore I started d= oing modifications and adding
missing Brief features on a per-need basis= .

After 17+ years of intermittent development (as the release of
= version 5.80), the code is almost completely rewritten compare to
the or= iginal XEmacs CRiSP mode code.

A lot of editor behaviors were also a= dapted to Emacs.=C2=A0 One example
is that Brief mode emulator could res= pect `visual-line-mode',
`toggle-truncate-lines' and hidden/abbr= eviated mode texts (which
usually shown as "..." in Emacs) suc= h as org-mode, hideshow mode
and hideif (hide "#ifdef", condit= ional compilation units, another
package that I had rewritten).=C2=A0 Wh= en texts are hidden at cursor
line, Brief line-oriented commands like li= ne-cut, line-copy,
line-deletion ... will operate on all hidden lines.

=C2=A0Brief Extension:
------------------------

This Br= ief mode extends a lot of functionalities that the original
Brief editor= don't have.=C2=A0 For example, the original Brief <ctrl>-<-&g= t;
(C--) kills current buffer; however, when prefixed with <ctrl>-= <u>
(C-u) the <ctrl>-<-> (C--) command will restore th= e just killed
buffer.=C2=A0 This is convenient as sometimes user acciden= tally hit C--
for some reason and lost the buffer.=C2=A0 Another simple = example is the
original Brief command <alt>-<f> (M-f) which = shows the file name of
the current buffer; while prefixed with C-u it wi= ll also copy the
file name into the clipboard.=C2=A0 The following secti= ons list some of
the major extensions of this extended Brief mode.
* Visual mode, line truncation and hidden texts:
=C2=A0 (config option= : `brief-linecmd-respect-visual')

In the original DOS Brief edit= or, press [home] key once brings the
cursor to the beginning of the curr= ent line; a second [home] key to
the top of the window and the third [ho= me] to the beginning of the
file.=C2=A0 In Emacs it's a bit differen= t; it has `toggle-truncate-lines'
to wrap long lines and `visual-lin= e-mode' to do smart word-warp.
This Brief mode emulator thus adapted= to Emacs accordingly: if long
lines are wrapped, the first [home] keyst= roke brings the cursor to
the beginning of the "visual line"; = a second [home] then brings the
cursor to the beginning of the "phy= sical line".=C2=A0 The third [home] to
the top of the window and fi= nally the fourth [home] to the beginning
of the file.=C2=A0 When `toggle= -truncate-lines' is enabled and
`visual-line-mode' is off, Brief= mode then behaves the same as DOS
Brief.=C2=A0 Similar behavior applies= to the [end] key, as well as many
other keyboard commands like clipboar= d copy/paste functions.

This further leads to an user-customizable o= ption:
`brief-linecmd-respect-visual'.=C2=A0 This customized variabl= e determines
if a user would like to have line commands (like line-copy,= line-cut,
line-deletion...) by default respect visual mode or not.=C2= =A0 That
variable is by default nil and thus line commands will by defau= lt
operate on "physical" line(s) instead of "visual"= lines.=C2=A0 They
can be overridden by a common prefix C-u or a negativ= e prefix
number.

See the comments of the function `brief-is-visua= l-operation' for
more detail.

=C2=A0Basically, the rules are:=

=C2=A0 1. `brief-linecmd-respect-visual' determines the current= default
=C2=A0=C2=A0=C2=A0=C2=A0 mode, either visual or physical line m= ode.
=C2=A0 2. Either a common prefix C-u (\\[universal-argument]) or ne= gative
=C2=A0=C2=A0=C2=A0=C2=A0 prefix reverse the current mode; aka,=C2=A0=C2=A0=C2=A0=C2=A0 (not `brief-linecmd-respect-visual').

= =C2=A0Example:

Try editing a text using line deletion command [M-d] = on some very
long lines a few times longer than the window width (or shr= ink
window size), or an org-mode document with long lines. Now eitherturn on `visual-line-mode' or enable line wrapping using
`toggle-tr= uncate-lines'.=C2=A0 Assuming `brief-linecmd-respect-visual'
is = kept default value 'nil' which means physical line operations
ar= e expected by default, now try the following key combinations:

=C2= =A0 1. [M-d]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 : delete one "physical" line.
=C2=A0 2. = [C-u] [M-d]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : delete one &q= uot;visual" line.
=C2=A0 3. [C-4] [M-d]=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 : delete four "physical" lines as it's<= br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 prefixed with integer '4'.
=C2=A0 4. [C-u] [-] [4] [M-= d] : delete four "visual" lines as it's
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 prefixed wi= th integer '-4'.

On the other hand, cursor movement always r= espects visual mode
unless prefixed with C-u or negative prefix number.<= br>
* Fast line number computation cache:
=C2=A0 (config option: `bri= ef-replace-emacs-func:line-number-at-pos')

Brief editor window o= peration relies heavily on cursor position to
determine which window is = going to be operated.=C2=A0 As the original
Emacs line number computatio= n is too slow (especially when a lot
of texts are hidden within a window= ) so a line counting caching
mechanism is implemented.=C2=A0 By default,= the original Emacs function
`line-number-at-pos' is replaced by `br= ief-fast-line-number-at-pos'
if Emacs version is older than 27 where= native line numbering is
not yet supported.=C2=A0 There is actually a c= ustom variable named
`brief-replace-emacs-func:line-number-at-pos' d= efined near the end
of this file.=C2=A0 It controls if the `line-number-= at-pos' is going
to be replaced or not, regardless of the Brief mode= is on or off.

It is recommended to keep the default value for fast = line number
calculation which helps Linum mode as well, otherwise, you m= ight
experience big slow down when switching windows using Brief window<= br>commands (i.e. [F1-<arrow>] key).

* Huge clipboard/Xselecti= on texts:
=C2=A0 (config option: `brief-enable-postpone-selection')<= br>
In the following context and code the term Xselection and clipboard<= br>are used interchangeably and refer to the same thing - the XWindow
se= lection (mainly "primary" and "clipboard", "second= ary" is not
used) or the Windows clipboard.=C2=A0 This emulator tri= es to sync kill-
ring with Xselection even in terminal mode (Xterm).
=
This Brief mode also implements an asynchronous mechanism to
prevent= the selected texts from immediately going into the
Xselection, as all (= most) *NIX GUI program currently do -- any
marked/selected text got copi= ed into Xselection with no delay.

This helps to boost performance a = lot especially when huge texts
(say, 500Mb texts) are being selected.=C2= =A0 There is no point to keep
copying texts into clipboard before user c= ompleted the text
selection.=C2=A0 When the user tries to enlarge the hu= ge selection area,
copying texts into clipboard could take very long and= the system
seems to stop responding.=C2=A0 The auto-repeated cursor mov= ement key
commands are then accumulated into the key queue and make thin= gs
worse.=C2=A0 Our Brief mode does not immediately copy texts into
X= selection until the cursor movement key is released, which usually
means= a user has completed (say, at least temporarily) the
selection.=C2=A0 U= nfortunately, this key-releasing event cannot be seen
within Emacs Lisp = so we workaround this by detecting if the keyboard
is idle or not. Funct= ions are called asynchronously by the idle
timer.

There is also a= nother important reason for doing so, on Xservers
running on MS Windows = with MS office running in the background,
this problem is fatal and usua= lly caused a system crash in the end.
With this selection postponement, = we prevented that.=C2=A0 For more
detail description about the MS proble= m, please search the comments
in the following source code containing &q= uot;Xselection Postponement:".
The solution is not perfect but work= s for most cases.

A custom option `brief-enable-postpone-selection&#= 39; is defined to
control if the selection postponement is enabled or no= t.=C2=A0 By
default, it's turned on.

* External Xselection he= lper programs `xsel' and `xclip':
=C2=A0 (config option: `brief-= use-external-clipboard-when-possible')

In order to further boost= the performance when a user selects huge
texts, external Xselection hel= per programs are used, although it
increased the complexity of the async= hronous event handling.=C2=A0 The
main reason is that the internal Emacs= Xselection code is
un-interruptible and not quit-able.=C2=A0 When Emacs= tries to get/set
Xselection, the operation is blocking and Emacs is not= responding
to any key before the operation completes.

For exampl= e, when a user selects some huge texts using arrow keys
and paused a sho= rt period of time then try to continue enlarging/
shrinking the selectio= n area using arrow keys, the previous Emacs
Xselection get/set operation= is usually not completed yet (due to
the size of huge text).=C2=A0 Ther= efore the attempt to continue
enlarging/shrinking texts will be blocked = and user will experience
no response until Emacs completed the Xselectio= n operation.=C2=A0 What's
more, those continued arrow keys then in t= urn queued in the Xwindow
system.=C2=A0 When Emacs eventually resume res= ponding, the selection
area will be changed accordingly to some earlier = keys in the queue
that the user typed a few seconds ago.=C2=A0 This kind= of non-real-time
response usually confuse the user and sometimes cause = problems.

To workaround this we implemented our own non-blocking and= quit-able
Xselection get/set functions, with the help of external X uti= lities
like `xsel' or `xclip'.=C2=A0 Therefore user needs to ins= tall `xsel' or
`xclip' in the *NIX system to get the benefit.=C2= =A0 If neither xsel nor
xclip is installed, it will fall back using the = Emacs internal
blocking Xselection code.=C2=A0 With our non-blocking imp= lementation,
when a user tries to enlarge/shrink/quit a huge text select= ion
while the Xselection gets/sets operation is in-progress, the
unfi= nished operation will be interrupted immediately.=C2=A0 A user gets
an i= mmediate response.

A custom variable `brief-use-external-clipboard-w= hen-possible' (by
default 't) controls if this Brief mode would = invoke external helper
or not.=C2=A0 For further detail consult the help= message for function
`brief-external-set-selection' and `brief-exte= rnal-get-selection'.
There are also a few other configuration option= s controlling if
the progress is showing in the message area or not:
= =C2=A0=C2=A0 `brief-show-external-clipboard-recv-progress'
=C2=A0=C2= =A0 `brief-show-external-clipboard-send-progress' ...
With these two= options, the user can see the progress when big
clipboard data are tran= sferring.

Also, notice that for terminal mode Emacs under X running = Brief mode
the external helpers are always invoked in order to copy/past= e texts
with any other windowed mode applications.

* Fast cursor = movement:

What I like most about the old DOS Brief editor is its sup= er fast
cursor movement.=C2=A0 On a lot of occasions, I didn't even = need to do
page-up or page-down.=C2=A0 Once you get used to the cursor s= peed you
really don't want to return to the normal speed.=C2=A0 Unfo= rtunately,
this cannot be done in Emacs.=C2=A0 However, there is an alte= rnative way
to achieve similar effect -- setting X keyboard autorepeat r= ate
using the command line `xset' X utility:

=C2=A0# xset r r= ate 255 100

Although it's still not as fast as DOS Brief editor,= it's at least
closer.=C2=A0 Also, notice that this will affect the = global X window
environment.


=C2=A0Key Binding Compatibility = Note:
---------------------------------------------
Notice that the original brief commands keypad-'+' (cop= y line) and
keypad-'-' (cut line) are now duplicated into <co= ntrol>-<insert>
(copy line) and <shift>-<delete> (c= ut line).=C2=A0 This is mainly for
keyboards and notebooks without a key= pad.

As both <Alt>-<n> (M-n) and <Alt>-<p> (= M-p) are so widely used in
various Emacs modes so in the Brief mode M-n = and M-p are assigned
"weakly". This means any major mode can o= verride the assignment of
M-n and M-p.=C2=A0 In Brief mode, M-n is used = for switching to next
buffer while M-- for the previous buffer.=C2=A0 Bo= th of them are
frequently used commands, therefore, we also weakly assig= ned M-+
and M-=3D for M-n and M-_ for M--.=C2=A0 However, for M-p (brief= -print)
we do not provide other key combinations for the same key.
For line marking commands, as Emacs regions always start/end at
cursor= so the Brief mode region commands <Alt>-<L> <arrow> (M-L=
prefixed arrow keys) behave a bit differently from the original
Brie= f ones (unless I implemented it using the secondary Xselection,
which co= uld lead to more issues).=C2=A0 This Brief mode does not
immediately mar= k the current line until the followed arrow key user
typed.=C2=A0 Also, = the 'paste' command key <insert> also insert keys
starting= from the cursor position instead of the beginning of
current line.=C2= =A0 On the other hand, 'copy line', 'cut line' and
'= delete line' commands work on the beginning of current line like
the= original Brief editor did.

For a complete keybinding list, check th= e following source code
commented with "Brief mode key bindings&quo= t;.

=C2=A0Platform Compatibility Notes:
------------------= -----------------------

This brief mode is mainly = tested for X window system, as there are
too many combinations of versio= ns (EmacsVers x {OSes} x {XServers})
need to be tested but I don't h= ave all environments (and time).
Therefore, I mainly tested recent Emacs= versions on Linux machines
on a daily use basis.=C2=A0 For other combin= ations listed below they
are not heavily tested; usually tested when the= y are been used.

Test Matrix (note: all 64-bit systems):

On L= inux: (including native X11 Emacs, terminal mode Emacs on xterm
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 and Linux X11 Emacs = running on VcXsrv (1.19.3.4+) under
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 Win10):
=C2=A0=C2=A0=C2=A0=C2=A0 Emacs 23.3.1, = 24.4.50.2, 25.2.2, 26.0.50, 26.1 and 27.0.50.
=C2=A0=C2=A0=C2=A0=C2=A0 M= ainly focusing on Emacs 25 ~ 27.
=C2=A0=C2=A0=C2=A0=C2=A0 For Emacs23 an= d 24, not all the functionality behaves the same
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 as in Emacs 25 ~ 27 (ex. search/replace in region/rectangle= ).
On Cygwin:
=C2=A0=C2=A0=C2=A0=C2=A0 Emacs 25.3.1, 26.1.
On Win1= 0:
=C2=A0=C2=A0=C2=A0=C2=A0 Emacs 25.1.1 (x86_64-w64-mingw32).
On WSL= (Windows Subsystem for Linux):
=C2=A0=C2=A0=C2=A0=C2=A0 Emacs 24.5.1, t= erminal mode and on VcXsrv (1.19.3.4+).


=C2=A0Enabling Brief Mod= e:
------------------------------

Enable= this package by putting "(require 'brief)" in your .emacsand "(brief-mode 1)" to enable it.=C2=A0 If you want to toggle i= t later
interactively just use "M-x brief-mode" to toggle it o= n or off.
Notice that "M-x" may be overridden if `brief-overri= de-meta-x' is
set to non-nil (default value) when you enable brief m= ode.=C2=A0 In this
case use function key #10 "F10 brief-mode" = to toggle it off.

The default keybindings for Brief mode override th= e M-x key to exit
the editor.=C2=A0 If you don't like this functiona= lity, you can prevent
this behavior (or redefine it dynamically) by cust= omizing the value
of `brief-override-meta-x' either in your .emacs o= r interactively.
The default setting is t, which means that M-x will by = default
by default run `save-buffers-kill-emacs' instead of the comm= and
`execute-extended-command'.

It is recommended to load the= Ibuffer package "(require 'ibuffer)"
before or after load= ing Brief mode.=C2=A0 "M-b" will invoke ibuffer
to show buffer= menu if ibuffer package presents, otherwise it by
default runs `buffer-= menu'.

This package will automatically load the "scroll-loc= k.el" package if
you put "(setq brief-load-scroll-lock t)"= ; in your .emacs before
loading this package.=C2=A0 If this feature is e= nabled, it will bind
"<Scroll_Lock>" to the scroll-lock = mode toggle.=C2=A0 The scroll-lock
package provides the scroll-locking f= eature in Brief.

Finally, if you want to change the string displayed= in the modeline
when this mode is in effect, override the definition of=
`brief-mode-mode-line-string' in your .emacs.=C2=A0 The default val= ue is
" Brief" which may be a bit lengthy if you have a lot of= things
being displayed there.

All these overrides should go *bef= ore* the (require 'brief)
statement.

=C2=A0Cygwin 2.x Users:<= br>-------------------------

When the default &quo= t;mintty" application is used to lunch Cygwin, if
you would like to= run Emacs with Brief mode enabled in mintty's
special terminal mode= , some mintty window settings need to be
changed:

1. Right-click = in the Cygwin "mintty" window on the title bar
2. Choose "= ;Options"
3. At the left sided pane choose "Keys" categor= y
4. Disable (uncheck) the following shortcuts:

=C2=A0=C2=A0=C2= =A0=C2=A0 Copy and Paste (Ctrl/Shift+Ins)
=C2=A0=C2=A0=C2=A0=C2=A0 Switc= h window (Ctrl+[Shift+]Tab)
=C2=A0=C2=A0=C2=A0=C2=A0 Zoom (Ctrl+plus/min= us/zero)
=C2=A0=C2=A0=C2=A0=C2=A0 Alt+Fn shortcuts
=C2=A0=C2=A0=C2=A0= =C2=A0 Ctrl+Shift+letter shortcuts

5. Click 'Apply' and '= ;Save'



--
Best regards,
Luke Lee
--0000000000001445690573528775--