-
Notifications
You must be signed in to change notification settings - Fork 24
Bb history display #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
+ New boolean defcustom w3m-history-in-new-buffer, default to current
behavior: nil. Applied to global and buffer-local history displays.
+ BUGFIX: Function w3m-db-history was not allowing an interactive user
to set its options.
+ BUGFIX: Function w3m-about-db-history was not properly handling its
START and SIZE arguments.
+ Cosmetic changes to global history listing
+ Extend width of title string to maximum.
+ Center heading
+ Page navigation links aligned to page edges
+ Remove extraneous ';' after url's
+ Unicode ellipsis sign used instead of three ascii dots (buys two
characters for long titles).
+ Add ellipsis when truncating url's
+ All dates display full timestamp, with today's entries labeled
"Today".
+ Modified docstrings to explain the functions' options.
|
Sorry for the delay. I'm reviewing your #4 changes now. |
|
Pushed to master by two steps (yours and mine). I've replaced this kind of form (w3m-goto-url URL :save-pos t) with (w3m-goto-url URL nil nil nil nil nil nil nil t) in two places. Is it right? Otherwise, is there a means |
|
@yamaoka : I don't think I can get to this today; I've spent too much time already today working on other parts of the project. |
|
@yamaoka : Diff'ing against 7fa00f9, I like much of what your changes accomplish. Here are the points that I have questions about (all line numbers are in file w3m.el):
2.1) There exists a variable 2.2) It seems that you're checking for an X11 version of emacs, and in that case you are performing an extra check, and possibly prompting the user. If you really do all that, it should also be done for non-X11 emacs also? 2.3) The check seems to have a bug because it is being performed based upon START, but that argument will always be zero at that point. It should be performed after the user is prompted for START. 2.4) The check is based upon a size comparison, and seems to be in order to avoid something being to long or too large, but it isn't taking into account SIZE, or the ability of the user to begin at any START point and click on the 'prev' link to go back in the list. I don't see how this check will ever be useful. If the purpose is to avoid a long wait while a single page is being processed, then the check should be after prompting for SIZE, only if the user accepted the default of 0, and be based upon some MAX-PAGE-DISPLAY-SIZE (not max database size), and the message should be a warning to the effect "That would be a very long page (n lines). Proceed anyway?", and upon a no, exit. 2.5) What happens when the user answers no to the prompt? In that case, the use has told us not to continue, but then the function does continue! It proceeds to prompt for START and SIZE.
|
|
I have a follow-up: When viewing all history on a single page, your version doesn't fit an entire time-stamp in the viewable page. The problem is only noticeable if your history includes entries prior to 'today' |
For mainly non-ASCII characters of which the width is interpreted variously as the case may be. (with-temp-buffer
Because of the above reason, the indentation for Time/Date portions vary line by line. To be continued |
|
@Boruch-Baum |
Nah. There is no interactive spec in the (t ; called interactively; possibly indirectly I imagined that the indirect case would probably be to call this function from a custom ELisp To be continued |
I came to think I should withdraw the GUI stuff. The reason I added it is because I felt funny To be continued |
|
@Boruch-Baum |
|
So, as summary, using my original point numbering as reference: [line 10821] (width (- (w3m-display-width) 21)): @yamaoka says that this is because how 'wide' characters appear differently in different environments. If so, is this really the correct solution? It doesn't properly handle the character in my utf-8 environment, and what about any number of wide characters that could be present in the URL title? Shouldn't there be some kind of environment check and count of all the wide characters, instead of just adding '2' in all cases, even if its not needed? 2.1) There exists a variable w3m-db-history-display-size @yamaoka : The most common way to use function 2.2) It seems that you're checking for an X11 version There is value in performing some form of size test, but not the test that the code performs, and not only in the GUI/X11 case. @yamaoka : As I'm writing I see that you've pushed another commit about this, removing some GUI stuff, and adding an interactive list. The idea for the interactive list had been made by Filipp Gunbin on the mailing list ~13096. |
|
@yamaoka : I just checked your update in commit 0c956f8. When called directly interactively it does seem to work; however, the default design case of being called using |
* Properly handle indirect interactive call to the function * Add sanity check to prevent long waits for creation of very long history pages. * Add programming note. * Set sane default for variable w3m-db-history-display-size
* It turns out to be useless in all cases, because it only becomes an issue when the user has explicitly changed the defcustom default value of w3m-db-history-page-size
|
I just posted two commits: 169a3f6 restores the functionality, and adds a sanity check for long pages, in a way that I think was the original intent for the check that I criticized above. However, I then proceeded to remove that in the next commit 6fdff93 because I don't see that the check ever makes any sense, because it would only be invoked when the user explicitly changes the defcustom value I also did sneakily change the default for that value to make it more a sane 100 instead of based upon 500 entries. Also, I fast-forward'ed this PR branch so that it can be merged in the standard way again. |
+ Apply (string-width) to the ellipsis and enclosure characters so that they are properly accounted for in all coding systems and fonts. + Change enclosure characters from "&foo;" to prettier, single unicode ones.
|
My recent commit 57ca0ef should account properly for the ellipsis and bracket characters, no matter how they may be changed in the future, and for all encodings and fonts, I hope. |
w3m-db-history-fix-indentation and tweaking the width (-21) are no more than workarounds.
That is a w3m problem, not that of Emacs or emacs-w3m, I think (though Emacs on TTY makes a mysterious behavior). Emacs (at least the ones I have) says that the string width of "…" is 2 no matter what display (X or TTY) or font is used. Please try the attached ELisp snippet and Eval: (and (search-forward "bar" nil t) (goto-char (match-beginning 0))) in the beginning of each "foo" line. |
What does |
|
On 2019-02-24 17:50, yamaoka wrote:
***@***.***
[line 10821] (width (- (w3m-display-width) 21)): ***@***.*** says
that this is because how 'wide' characters appear differently in
different environments. If so, is this really the correct solution?
w3m-db-history-fix-indentation' and tweaking the width' (-21) are no
more than a workarounds.
It doesn't properly handle the character in my utf-8 environment,
and what about any number of wide characters that could be present
in the URL title? Shouldn't there be some kind of environment check
and count of all the wide characters, instead of just adding '2' in
all cases, even if its not needed?
That is a w3m problem, not that of Emacs or emacs-w3m, I think (though
Emacs on TTY makes a mysterious behavior). Emacs (at least the ones I
have) says that the string width of "…" is 2 no matter what display (X
or TTY) or font is used. Please try the attached ELisp snippet and
Eval: (and (search-forward "bar" nil t) (goto-char (match-beginning
0)))
in the beginning of each "foo" line.
[3]ELisp2.gz
I did. What I get is:
foo… bar
`bar' starts at the column 48
foo** bar
`bar' starts at the column 48
But I don't understand why or how that's relevant. For (string-width
"…"), I get an answer of '1'...
I also tried the following, which also gives me values of one for everything:
(let ((ellipsis "…"))
(dolist (enc
'((us_ascii . raw-text)
(us-ascii . raw-text)
(gb2312 . cn-gb-2312)
(cn-gb . cn-gb-2312)
(iso-2022-jp-2 . iso-2022-7bit-ss2)
(iso-2022-jp-3 . iso-2022-7bit-ss2)
(tis-620 . tis620)
(windows-874 . tis-620)
(cp874 . tis-620)
(x-ctext . ctext)
(unknown . undecided)
(x-unknown . undecided)
(windows-1250 . cp1250)
(windows-1251 . cp1251)
(windows-1252 . cp1252)
(windows-1253 . cp1253)
(windows-1254 . cp1254)
(windows-1255 . cp1255)
(windows-1256 . cp1256)
(windows-1257 . cp1257)
(windows-1258 . cp1258)
(euc-jp . euc-japan)
(shift-jis . shift_jis)
(shift_jis . shift_jis)
(sjis . shift_jis)
(x-euc-jp . euc-japan)
(x-shift-jis . shift_jis)
(x-shift_jis . shift_jis)
(x-sjis . shift_jis)))
; test #1
(with-coding-priority (list (cdr enc))
(message "%d: %s"
(string-width ellipsis)
(car enc)))
; test #2
(message "%d: %s"
(string-width (decode-coding-string ellipsis (cdr enc)))
(car enc))))
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
|
On 2019-02-24 18:31, yamaoka wrote:
***@***.***
***@***.*** : [...]Try C-u h and see.
What does C-u h mean? Is it C-u NUMBER M-x w3m-db-history RET, i.e.,
passing the prefix argument to the function?
Sorry that I wasn't clear. I thought that 'h' should by default be bound
to `w3m-history', so I was asking to try the equivalent of:
C-u M-x w3m-history
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
|
On 2019-02-24 18:47, Boruch Baum wrote:
On 2019-02-24 17:50, yamaoka wrote:
I also tried the following, which also gives me values of one for
everything:
Well, that didn't indent at all the way I sent it...
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
[3]ELisp2.gz
foo… bar
`bar' starts at the column 48
foo** bar
`bar' starts at the column 48
Oh, I get '2' in every version of Emacsen (currently 26.1, 26.1.92, 27.0.50). However w3m seems to recognize it '1'. This is the cause of our disagreement! In the 80 column width Emacs window, ELisp2 shows: foo… bar
`bar' starts at the column 41
foo** bar
`bar' starts at the column 40
I also realized that this is due to the value of 'current-language-environment' of Emacs. If I change it from Japanese to English, (string-width "…") gets 1, even if "…" is displayed as a wide character. So, a possible solution might be to bind language-environment to English locally in emacs-w3m buffers. I don't know if it can be and is halmless, though. |
So, is what you want to do something like this? (defun xxx-w3m-db-history (&optional start size prefix-arg)
"docstring"
(interactive (list nil nil current-prefix-arg))
(if prefix-arg
(setq start (read-number
"How far back in the history to start displaying: "
0)
size (read-number
"How many entries per page (0 for all on one page): "
(or w3m-db-history-display-size 0)))
(or start (setq start 0))
(or size (setq size (or w3m-db-history-display-size 0))))
(message "START=%s, SIZE=%s" start size))
|
The width of "…" is ambiguous. w3m recognizes its width is 1 by default (east_asian_width=0).
As you realized, when non-CJK environment such as LANG=en_US.UTF-8, |
|
tldr; Maybe just drop the use of the fancy ellipsis character? But if we
do, this problem will come back to haunt us in many other ways, so
better we should solve it now.
On 2019-02-24 22:13, yamaoka wrote:
foo… bar
I also realized that this is due to the value of
'current-language-environment' of Emacs. If I change it from
Japanese to English, (string-width "…") gets 1, even if "…" is
displayed as a wide character. So, a possible solution might be
to bind language-environment to English locally in emacs-w3m
buffers. I don't know if it can be and is halmless, though.
I've been playing with a few settings and functions based upon the
internals of function `set-language-environment' in file mule-cmds.el
(see there). I've also tried fiddling with M-x prefer-coding-system and
M-x set-terminal-coding-system and haven't seen a way to have Japanese
as the 'language' and at the same time having unicode characters show
their actual width.
Within emacs-w3m, I've been doing some searching and see files
w3m-ccl.el and w3m-ucs.el which look like they play a part in this.
File w3m.el includes a snippet:
(w3m-make-ccl-coding-system
'w3m-euc-japan ?E
"ISO 2022 based EUC encoding for Japanese with w3m internal characters.
(generated by `w3m')"
'w3m-euc-japan-decoder
'w3m-euc-japan-encoder)
(w3m-make-ccl-coding-system
'w3m-iso-latin-1 ?1
"ISO 2022 based 8-bit encoding for Latin-1 with w3m internal characters.
(generated by `w3m')"
'w3m-iso-latin-1-decoder
'w3m-iso-latin-1-encoder)
File w3m-ucs.el includes:
(w3m-make-ccl-coding-system
'w3m-euc-japan-mule-ucs ?E
"ISO 2022 based EUC encoding for Japanese with w3m internal characters.
A character that can not be encoded with `euc-japan' is converted to a
UCS codepoint with Mule-UCS, and the codepoint is represented as a
string which represents the character in Numeric Character
References (NCR).
(generated by `w3m')"
'w3m-euc-japan-decoder
'w3m-euc-japan-mule-ucs-encoder)
(w3m-make-ccl-coding-system
'w3m-iso-latin-1-mule-ucs ?1
"ISO 2022 based 8-bit encoding for Latin-1 with w3m internal characters.
A character that can not be encoded with `iso-latin-1' is converted to
a UCS codepoint with Mule-UCS, and the codepoint is represented as a
string which represents the character in Numeric Character
References (NCR).
(generated by `w3m')"
'w3m-iso-latin-1-decoder
'w3m-iso-latin-1-mule-ucs-encoder)
Are these part of an internal emacs-w3m procedure that is messing with
native unicode and forcing single-character-width unicode characters to
be represented in some pre-unicode method, or as a multi-byte? See there
in file w3m-ccl.el for references to what may be a macro called
`write-multibyte-character'.
So there may be two parallel issues: 1) How emacs itself is dealing with
Japanese by default, as a non-unicode compliant environment, and; 2) How
emacs-w3m does so.
What is further curious to me is that this is only happening in the case
of the ellipsis "…", but I also snuck in two other unique unicode
characters, to replace the use of "<" and ">" which require encoding and
decoding to/from </>. Maybe it wasn't obvious, but if you look
carefully, you should see a difference between the ascii >< and ❭❬. So,
why is the ellipsis character causing so much trouble but not the
others?
As the internet develops, sites are going to be using these and other
unicode characters, so this is something that the project should be able
to handle generically.
On 2019-02-25 02:04, Tatsuya Kinoshita wrote:
As you realized, when non-CJK environment such as LANG=en_US.UTF-8,
Emacs prefers charset unicode, and (string-width "…") is 1.
When LANG=ja_JP.UTF-8, Emacs prefers charset japanese-jisx0208,
and (string-width "…") is 2. Type C-u C-x = at "…" to show
charset/display information in Emacs.
When I use M-x set-language-environment to set the language to Japanese,
I do get the string width as 2; however, I wasn't able to used
(set-charset-priority (read-charset "?"))
to find a charset to restore the string width return value to 1 (eg.
unicode, latin-iso8859-1). If it is just a charset issue, wouldn't that
be sufficient?
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
|
On 2019-02-25 06:55, yamaoka wrote:
So, is what you want to do something like this?
What's wrong with the way that I actually did it? Your suggestion seems
ok, but it doesn't work when I actually evaluate it. Furthermore, your
idea seems to want to set up two parallel ways of doing the same thing,
either directly interactively call xxx-w3m-db-history or indirectly via
w3m-history. What happens when I called the function called directly
interactively without a prefix argument was what it didn't prompt for
START or SIZE because the interactive spec is (list nil nil ..) and
prefix-arg was be nil.
Don't get me wrong; it's great to have the potential flexibility to
allow a user to bind to this function directly. In the past, when we
discussed this, we decided that there were too many keybindings already,
and that since the two forms of history display were similar, that one
would be 'h' and the other 'C-u h'. The discussion is probably on the
mailing list somewhere. What I did here wasn't to change any of that.
All I did was to make the function actually work the way it was supposed
to, because it had been documented and coded to handle START and SIZE,
but wasn't prompting for it, and not properly doing it when it did
receive those values.
… (defun xxx-w3m-db-history (&optional start size prefix-arg)
"docstring"
(interactive (list nil nil current-prefix-arg))
(if prefix-arg
(setq start (read-number
"How far back in the history to start displaying: "
0)
size (read-number
"How many entries per page (0 for all on one page): "
(or w3m-db-history-display-size 0)))
(or start (setq start 0))
(or size (setq size (or w3m-db-history-display-size 0))))
(message "START=%s, SIZE=%s" start size))
—
You are receiving this because you were mentioned.
Reply to this email directly, [2]view it on GitHub, or [3]mute the
thread.
References
1. https://github.com/Boruch-Baum
2. #4 (comment)
3. https://github.com/notifications/unsubscribe-auth/ABxNqEGAHcaqcei1zbJOf_1wvMN4nBAxks5vQ4jpgaJpZM4adk8f
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
|
I recognized what was w3m-db-history for me. That is: ・When I used (very rarely) it, I was using the tool bar button If anything, it is annoying if it always prompts me for the arguments, and perhaps I might not understand the necessity to improve the function. But does't it (troublesomeness of requiring to enter the arguments) go for almost users? That is why I brought up the example (xxx-w3m-db-history) that requires user's inputs only if the prefix argument is given and called interactively. |
Thanks. So, instead of using <table>...</table>, it might possibly be better to generate the whole db-history contents by Emacs with the well aligned indentation, surround it with <pre>...</pre>, and pass to "w3m -halfdump". Furthermore, a way something like the following might be able to use in order to re-indent the Time/Date column after rendering the contents (as w3m-db-history-fix-indentation does it now). (let ((buffer (get-buffer-create "*testing*"))
(cur (selected-window)))
(switch-to-buffer-other-window buffer)
(erase-buffer)
(insert "foo..."
(propertize " " 'display `(space :align-to 40))
"bar\n"
"寿限無寿限無五劫の擦り切れ…"
(propertize " " 'display `(space :align-to 40))
"長久命の長助\n")
(select-window cur))
|
|
On 2019-02-26 22:19, yamaoka wrote:
I recognized what was w3m-db-history for me. That is:
・When I used (very rarely) it, I was using the tool bar button
because no key is bound to the command by default (lynx-like map).
There's a few differences right there. I use it a lot, with no gui or
toolbar, and it can accumulate a huge amount of space if I don't
occasionally scrub the history (emacs-w3m is my main browser, and my
current emacs-uptime on that machine is (emacs-uptime)"25 days, 17
hours, 50 minutes, 14 seconds",
・Not specifying start and size caused no inconvenience because
the arrived-db size is not so large if it is the default (500).
I find that even with a page size of just 100 the rendering is slow, and
that its worthwhile for me to set page sizes of 50.
If anything, it is annoying if it always prompts me for the arguments,
I also dislike that. Better it should read my mind. I just quickly press
return through the prompts if I don't want anything special.
and perhaps I might not understand the necessity to improve the
function.
It wasn't really an improvement. It was getting the function to operate
as documented, and as indicated was the original intent. The function
already had the START and SIZE args, and some form HTML for navigating
to previous and next pages - they just weren't working.
But does't it (troublesomeness of requiring to enter the
arguments) go for almost users?
Yes.
That is why I brought up the example
(xxx-w3m-db-history) that requires user's inputs only if the prefix
argument is given and called interactively.
But then we need another keybinding, or to change another keybinding.
Currently, 'h' is display's a buffer's history, and 'H' navigates to a
user's home page. I never use 'H' (I use my bookmark page instead), but
others might use it a lot.
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
So, how about the new implementation (already pushed to master)? (defun w3m-db-history (&optional start size) "[...] If this function is called interactively with the prefix argument, prompt a user for START and SIZE if the prefix argument is not a number (i.e., `C-u'). Otherwise if the prefix argument is a number (i.e., `C-u NUM'), use it as START and leave SIZE nil, that will be overridden by `w3m-db-history-display-size' or 0." (interactive "P")
I think the keys "h", "j", "k", "l", "J", and "K" in the default keymap 'w3m-lynx-like-map' are unnecessary for Emacs users. So, I think we can occupy "h" and "H" (or "H" and "h"?) for 'w3m-history' and 'w3m-db-history' respectively. How about bringing up such a proposal to the list? |
|
On 2019-02-28 17:33, yamaoka wrote:
So, how about the new implementation (already pushed to master)?
1] I like it, especially how you decided to use the prefix argument in
conjunction with a default size; however, you're using variable
w3m-db-history-display-size, whose docstring describes itself as a
maximum, so maybe just change that docstring.
2] At this point, is there any sense in using the prefix-argument in
function w3m-history to call function w3m-db-history?
"If called with the prefix argument, display a flat chronological
list of ALL buffers' browsing history."
If you still want that, it isn't handling START or SIZE. Since you
want to directly bind a key to w3m-db-history, maybe that feature and
its documentation should be dropped.
But then we need another keybinding, or to change another
keybinding. Currently, 'h' is display's a buffer's history, and 'H'
navigates to a user's home page. I never use 'H' (I use my bookmark
page instead), but others might use it a lot.
I think the keys "h", "j", "k", "l", "J", and "K" in the default keymap
'w3m-lynx-like-map' are unnecessary for Emacs users. So, I think we
can occupy "h" and "H" (or "H" and "h"?) for 'w3m-history' and
'w3m-db-history' respectively. How about bringing up such a proposal
to the list?
3] Agreed.
…--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
+ Also update documentation
This PR was originally shared on the mailing list ~[13091]. It fixes the handling of the START and SIZE args for the global history display, applies cosmetic changes to that display, and adds an option for all forms of history display to be done in a new buffer.