3

I'm on Linux Mint 21 (Ubuntu based). Just noted man pages internal search (/) does not find a word if split between two lines (the word is whole in the source of the page, displayed with a hyphen and indentation). I was very surprised. Any remedies?

Web search did not find this issue in top results, maybe it is rare, even a glitch on my system?

Could I disable word splitting as a workaround? Completely? If not, for specific lines in roff code?

E.g. man mpv.1 (sup‐ ported.)

DESCRIPTION mpv is a media player based on MPlayer and mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. Special input URL types are available to read input from a variety of sources other than disk files. Depending on platform, a variety of different video and audio output methods are sup‐ ported.

Source:

\fBmpv\fP is a media player based on MPlayer and mplayer2. It supports a wide variety of video file formats, audio and video codecs, and subtitle types. Special input URL types are available to read input from a variety of sources other than disk files. Depending on platform, a variety of different video and audio output methods are supported.

Edit: edited /etc/groff/man.local

.\" -*- nroff -*-
.\"
.\" This file is loaded after an-old.tmac.
.\" Put any local modifications to an-old.tmac here.
.
.  \" Disable hyphenation.
.nr HY 0
.
.if n \{\

etc...

1 Answer 1

5

I'm on Linux Mint 21 (Ubuntu based). Just noted man pages internal search (/) does not find a word if split between two lines (the word is whole in the source of the page, displayed with a hyphen and indentation). I was very surprised. Any remedies?

Yes; you anticipated the main one.

Web search did not find this issue in top results, maybe it is rare, even a glitch on my system?

Not at all. Your pager knows only the contents of the buffer or stream that it has read. It has no understanding of hyphenation or word breaking, nor could it, on any reasonable (and general) basis. Put differently, it has no way of knowing what the man page source document looked like before it was formatted.

Could I disable word splitting as a workaround? Completely?

Yes.

EDIT: As Stephen Kitt notes in a comment to this answer, man-db man supports an --nh option (and a longer synonym) to do this (up to a point). A shell function may be as much as you need.

manh () {
  man --nh "$@"
}

Alternatively:

Arrange to pass the -rHY=0 (or -r HY=0) option to groff. This is documented in the groff_man(7) page.

 -rHY=0   Disable automatic hyphenation.  Normally, it is
          enabled (1).  The hyphenation mode is determined by the
          groff locale; see section “Localization“ of groff(7).

On Debian systems, for example, you can get this option to groff via the MANROFFOPT environment variable.

MANROFFOPT=-rHY=0

If you want automatic hyphenation (see below) off all the time for all man pages, you can edit the /etc/groff/man.local file to do the equivalent as a roff request.

.nr HY 0

The "Files" section of groff_man(7) tells where that configuration file is stored in your installation. Different vendors put it in different places.

Technically, that's only almost a complete solution--like the raw roff request that it controls, this option shuts off only automatic hyphenation of words. The formatter will still (generally) break at explicit hyphens, as in the word "user-defined".

If not, for specific lines in roff code?

The \% escape sequence in roff source suppresses hyphenation of a word when it appears at the very beginning of that word. ("Words" in roff are delimited by whitespace; for most purposes, this means spaces and newlines.) For instance, we could do this.

The remainder of these macros are \%user-defined.

And the formatter won't break after the hyphen as it normally would.

What happens if you use \% again within a word is unfortunately not well defined, and different formatters behave differently. But this is an extreme corner case.

Finally I'll note this feature of man-db man(1) that somewhat mitigates the entire issue.

     -K, --global-apropos
            Search for text in all manual pages.  This is a brute‐force
            search, and is likely to take some time; if you can, you
            should specify a section to reduce the number of pages that
            need to be searched.  Search terms may be simple strings
            (the default), or regular expressions if the --regex option
            is used.

            Note that this searches the sources of the manual pages, not
            the rendered text, and so may include false positives due to
            things like comments in source files.  Searching the
            rendered text would be much slower.

I hope this helps.

6
  • 1
    man-db man itself has a --no-hyphenation (--nh) option to disable hyphenation ;-). Commented Jul 2 at 5:13
  • Thanks, Stephen. I always forget that because I spend too much time running groff directly, or passing it unlikely and obscure flags via $MANROFFOPT to torture man pages, or the formatter itself. 3:) Commented Jul 2 at 5:18
  • Indeed, that’s what I imagined — we know what the G stands for now! Commented Jul 2 at 7:24
  • Thanks. export MANROFFOPT=-rHY=0,man --nh works. However, editing /etc/groff/man.local had not (contents of the file in edited question). Any idea why? No need to restart the system I assumed, correct? Commented Jul 2 at 10:46
  • Interesting: man groff_man has "/usr/share/groff/site-tmac/man.local Local changes and customizations should be put into this file." And the files contents already are as /etc/groff/man.local with same mod time, even as there are both no links. Some daemon syncs them? Commented Jul 2 at 10:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .