[vim/vim] Remove backslashes in man pages using Vim script (PR #12557)

30 views
Skip to first unread message

lifecrisis

unread,
Jun 17, 2023, 11:15:36 AM6/17/23
to vim/vim, Subscribed

Closes: #12301


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/12557

Commit Summary

  • 7fc6fd3 Remove backslashes in man pages using Vim script

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557@github.com>

Aliaksei Budavei

unread,
Jun 17, 2023, 4:49:04 PM6/17/23
to vim/vim, Subscribed

Depending on Col's provenance, tabs may be substituted for
runs of spaces, with or without its -h or -x flags.
The emulation comment should admit that there is no such
translation before or after :substitute.

Compare output:

{ man col | col -bx; } > /tmp/col.1.x
{ man col | col -bh; } > /tmp/col.1.h
{ man col | col -b; } > /tmp/col.1
diff -q /tmp/col.1.h /tmp/col.1
vimdiff -o /tmp/col.1.x /tmp/col.1


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1595858206@github.com>

lifecrisis

unread,
Jun 17, 2023, 5:21:25 PM6/17/23
to vim/vim, Subscribed

The emulation comment should admit that there is no such translation before or after :substitute.

I think referring to the issue is sufficient. There are other details left out of the comment that are equally relevant. Brevity requires that a number of details be omitted, which is why the link to the issue was added.

Personally, I would much rather remove any attempt to reformat the output of man at all since man makes use of col to reformat its text when output is not a terminal. All of this seems redundant now.

If man does the same thing on MacOS, I think we can get rid of it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1595863411@github.com>

codecov[bot]

unread,
Jun 17, 2023, 10:32:33 PM6/17/23
to vim/vim, Subscribed

Codecov Report

Merging #12557 (7fc6fd3) into master (bc385a1) will decrease coverage by 5.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #12557      +/-   ##
==========================================
- Coverage   82.09%   77.07%   -5.02%     
==========================================
  Files         160      150      -10     
  Lines      193650   151269   -42381     
  Branches    43481    38978    -4503     
==========================================
- Hits       158978   116592   -42386     
- Misses      21826    22511     +685     
+ Partials    12846    12166     -680     
Flag Coverage Δ
huge-clang-none ?
linux ?
mingw-x64-HUGE ?
mingw-x86-HUGE 77.07% <ø> (-0.01%) ⬇️
windows 77.07% <ø> (-1.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 154 files with indirect coverage changes


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1595929179@github.com>

Christian Brabandt

unread,
Aug 9, 2023, 3:25:04 PM8/9/23
to vim/vim, Subscribed

should be okay to include. One question however:
@lifecrisis @goweol are you both co-maintaining the plugin?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1672017684@github.com>

Christian Brabandt

unread,
Aug 20, 2023, 2:42:00 PM8/20/23
to vim/vim, Subscribed

Merged #12557 into master.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/issue_event/10138749428@github.com>

Christian Brabandt

unread,
Aug 20, 2023, 2:42:04 PM8/20/23
to vim/vim, Subscribed

thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1685362749@github.com>

Yee Cheng Chin

unread,
Sep 15, 2023, 8:11:14 PM9/15/23
to vim/vim, Subscribed

Hi, this change seems to have broken this plugin on Mac. This is the before:

Before

Now it looks like this (only when you invoke :Man ls from Vim, not when you are using it as a MANPAGER):

After

I haven't taken a closer look yet but can we revert the change while someone works on a fix?

Additionally, can we add some unit tests to prevent regressions in the future in the supported platforms? I think right now the bundled plugins are mostly untested which have from time to time result in regressions like this and basic regression tests on the main platforms would help catch the issues before they get merged.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1722071315@github.com>

Yee Cheng Chin

unread,
Sep 15, 2023, 8:54:27 PM9/15/23
to vim/vim, Subscribed

Actually, I found the issue. It's because I have set gdefault in my vimrc, and the substitute command uses the g flag, which gets inverted under this. Which to be fair, even if we have regression tests, this may not have been tested as it's an edge case.

I think we can fix it like so (I will open PR):

diff --git a/runtime/autoload/dist/man.vim b/runtime/autoload/dist/man.vim
index 315636a2ef..e517714f58 100644
--- a/runtime/autoload/dist/man.vim
+++ b/runtime/autoload/dist/man.vim
@@ -196,7 +196,11 @@ func dist#man#GetPage(cmdmods, ...)
 
   " Emulate piping the buffer through the "col -b" command.
   " Ref: https://github.com/vim/vim/issues/12301
-  silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//ge
+  if &gdefault
+    silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//e
+  else
+    silent! keepjumps keeppatterns %s/\v(.)\b\ze\1?//ge
+  endif
 
   if unsetwidth
     let $MANWIDTH = ''

The docs for gdefault does say that it's deprecated because of this reason, but I find it a little unsatisfactory:

				   *'gdefault'* *'gd'* *'nogdefault'* *'nogd'*
'gdefault' 'gd'		boolean	(default off)
			global
...
	DEPRECATED: Setting this option may break plugins that are not aware
	of this option.  Also, many users get confused that adding the /g flag
	has the opposite effect of that it normally does.
	This option is not used in |Vim9| script.

Feels to me we should just expose a way to do substitution that can ignore gdefault instead (like how ignorecase is ignored if \c or \C is used).


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/12557/c1722085806@github.com>

Reply all
Reply to author
Forward
0 new messages