Skip to content

Conversation

@Boruch-Baum
Copy link
Contributor

  • w3m parses HTML tags to try to intelligently guess the 'next' and
    'previous' pages for a URL so it proceed there when a page beginning
    or end is reached. However, some/many website software don't embed
    that information within HTML tags, and they rely solely on the
    plain-text between the opening and closing HTML 'A' tag. An example
    of this is the sofwtare for the emacs mailing list archive! This
    commit adds logic to find and use that information.

  • This commit does introduce new behavior in the patched functions
    that change the meaning of the prefix-arg!

    • The most convenient way to give the user flexibility to change
      his/her mind about which text labels to use for navigation was to
      use the prefix-arg for two of the scroll commands. However, those
      functions were already using the prefix-arg for an option to
      scroll n lines instead of a screen-full. After giving the matter
      thought, it seemed to me that someone wanting finely-tuned
      scrolling could/should/was probably using two other functions
      anyway (w3m-scroll-up and w3m-scroll-down) which default to one
      line and have the optional prefix-arg for n lines.
  • Minimizing the effect of the behavior change

    • The commit adds a defcustom for number of default lines to scroll
      when not performing fine-tune scrolling (ie. when not using
      functions w3m-scroll-up and w3m-scroll-down). When that variable
      is NON-NIL, functions w3m-scroll-up-or-next-url and
      w3m-scroll-down-or-previous-url use that number instead of a
      screen-full.

    • The commit adds a function w3m-set-scroll-interval to conveniently
      change the default scroll amount of the defcustom, but only for
      the current session.

  • The result is that scrolling is more convenient because if you want
    someone who wants to scroll n lines instead of a screen-full will
    probably want to do that repeatedly. Without the patch, that user
    would need to use the prefix-arg and numeric entry for each scroll.
    With this commit, the user only needs to set the value once, and can
    do so as a command, without having to manually evaluate a variable.
    The use does need to remember or guess that in order to "set the w3m
    scroll interval" you perform M-x w3m-set-scroll-interval.

  • Benefit of logic at point-of-use. The logic is not performed during
    page parsing (all pages), only when the feature is needed (very
    rarely).

+ w3m parses HTML tags to try to intelligently guess the 'next' and
  'previous' pages for a URL so it proceed there when a page beginning
  or end is reached. However, some/many website software don't embed
  that information within HTML tags, and they rely solely on the
  plain-text between the opening and closing HTML 'A' tag. An example
  of this is the sofwtare for the emacs mailing list archive! This
  commit adds logic to find and use that information.

+ This commit does introduce new behavior in the patched functions
  that change the meaning of the prefix-arg!

  + The most convenient way to give the user flexibility to change
    his/her mind about which text labels to use for navigation was to
    use the prefix-arg for two of the scroll commands. However, those
    functions were already using the prefix-arg for an option to
    scroll n lines instead of a screen-full. After giving the matter
    thought, it seemed to me that someone wanting finely-tuned
    scrolling could/should/was probably using two other functions
    anyway (w3m-scroll-up and w3m-scroll-down) which default to one
    line and have the optional prefix-arg for n lines.

+ Minimizing the effect of the behavior change

  + The commit adds a defcustom for number of default lines to scroll
    when not performing fine-tune scrolling (ie. when not using
    functions w3m-scroll-up and w3m-scroll-down). When that variable
    is NON-NIL, functions w3m-scroll-up-or-next-url and
    w3m-scroll-down-or-previous-url use that number instead of a
    screen-full.

  + The commit adds a function w3m-set-scroll-interval to conveniently
    change the default scroll amount of the defcustom, but only for
    the current session.

+ The result is that scrolling is more convenient because if you want
  someone who wants to scroll n lines instead of a screen-full will
  probably want to do that repeatedly. Without the patch, that user
  would need to use the prefix-arg and numeric entry for each scroll.
  With this commit, the user only needs to set the value once, and can
  do so as a command, without having to manually evaluate a variable.
  The use does need to remember or guess that in order to "set the w3m
  scroll interval" you perform M-x w3m-set-scroll-interval.

+ Benefit of logic at point-of-use. The logic is not performed during
  page parsing (all pages), only when the feature is needed (very
  rarely).
@Boruch-Baum
Copy link
Contributor Author

An improvement would be to replace the hard-coded regexes with a defcustom list of CONS. That way it could support other languages and other pairs of keywords.

+ Use a defcustom to support multiple navigation labels in multiple
  languages.

+ BUGFIX: When choosing a label such as 'next in thread' or 'previous
  in thread', one will reach an endpoint page that isn't the end of
  the entire series of pages, so prompt the user for a new choice
  without forcing the user to run the command a second time, but with
  a prefix arg.
@yamaoka
Copy link
Contributor

yamaoka commented Sep 8, 2020

;; I'm not sure how to make a reply sent in the GitHub page so to CC'd
;; to the emacs-w3m list as well (some of my past replies weren't CC'd).
;; This is a copy of what I sent to the list.

Thank you for the great feature (if works). But have you tried
byte-compile it with the git master? It complained as follows:
,----
| In w3m-scroll-up-or-next-url:
| w3m.el:9141:30: Error: ‘add-to-list’ can’t use lexical var ‘options’; use
| ‘push’ or ‘cl-pushnew’
| w3m.el:9162:1: Warning: Unused lexical variable ‘cur’
|
| In w3m-scroll-down-or-previous-url:
| w3m.el:9197:30: Error: ‘add-to-list’ can’t use lexical var ‘options’; use
| ‘push’ or ‘cl-pushnew’
|
| In end of data:
| w3m.el:12087:1: Warning: the function ‘w3m-goto-next-anchor’ is not known to
| be defined.
`----

Though add-to-list currently works as expected even in the
lexbound world as far as I tested, I think we should replace

(while ... (add-to-list (quote VAR) VAL t) ...)

with:

(while ... (cl-pushnew VAL VAR) ...)
(setq VAR (nreverse VAR))

The unused cur is in w3m-scroll-down-or-previous-url.
The w3m-goto-next-anchor function was deleted by me a year ago
in the git master, sorry.

Regards,

+ scrolling to top of page was occassionally was sometimes cycling
  back to bottom

+ The English regex '.*back' was improperly catching strings like
  "background" "back-and-forth".
@Boruch-Baum Boruch-Baum force-pushed the bb_ambiguous_navigation branch from 2e81154 to e77ed12 Compare September 10, 2020 00:08
@Boruch-Baum
Copy link
Contributor Author

Boruch-Baum commented Sep 10, 2020 via email

+ Introduces a defcustom data structure w3m-page-navigation-sites to
  collect website urls and functions to be used to navigate their
  pages forward/backward.

+ Includes the pair of functions for the google-search style of page
  design.
+ simplify the algorithm to only look inside the url

+ now the algorithm becomes language-agnostic
+ simplify the algorithm to only look inside the url

+ now the algorithm becomes language-agnostic
+ the duckduckgo hadling has a bug in that POINT of new pages is not
  set to POINT-MIN.
In theory, this commit should have been a separate PR from "ambiguous
navigation", but the code is too interwoven, and the commit is so
small.

The issue is that prior code allows scrolling to continue even
when (poinnt-max) is already visible. This makes it different than the
behavior of other emacs buffers. In practice, I found this behavior
especially annoying because it messed up the behavior of a third-party
package 'ya-scroll' that I've started using in emacs-nox. Even without
that, the behavior makes no sense.

One anomaly and inconsistency remains. The prior code calculates
scrolling extent based upon (skip-chars-backward "\t\n\r ") from
POINT-MAX instead of from POINT-MAX alone. In praactice, I see that
pages do routinely present several blank lines at their end, and I'm
not commited either way how to handle the case. For the line function,
I used POINT-MAX, and for the paging function I retained the existing
idiom, so paging down present the 'sensible' end, and a persistent
user can see the extra blank lines by manually scrolling line by line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants