Andrey Kotlarski | 3 Jul 23:37 2010
Picon

[emacs-w3m:11251] [PATCH] w3m-lnum add highlight

The following message is a courtesy copy of an article
that has been posted to gmane.emacs.w3m as well.

Hello,
I enjoy both Conkeror and emacs-w3m and was quite happy to discover
w3m-lnum which gives emacs-w3m one of the nicest features of Conkeror.
One thing seems to be missing though, highlighting of the to be selected
numbered anchor, so here's what I've come up with (don't use XEmacs so
feel free to add what's needed to properly set overlay face).

diff -u /home/andrey2/.emacs.d/extras/w3m/w3m-lnum-cvs.el /home/andrey2/.emacs.d/extras/w3m/w3m-lnum.el
--- /home/andrey2/.emacs.d/extras/w3m/w3m-lnum-cvs.el	2010-04-27 15:46:24.000000000 +0300
+++ /home/andrey2/.emacs.d/extras/w3m/w3m-lnum.el	2010-07-04 00:34:41.274261764 +0300
 <at>  <at>  -34,6 +34,7  <at>  <at> 
 ;; expressions to your ~/.emacs-w3m.

 ;;      (autoload 'w3m-link-numbering-mode "w3m-lnum" nil t)
+;;      (autoload 'w3m-view-linknum "w3m-lnum" nil t)
 ;;	(add-hook 'w3m-mode-hook 'w3m-link-numbering-mode)

 ;;; Code:
 <at>  <at>  -67,9 +68,9  <at>  <at> 
 (defvar w3m-link-numbering-mode nil
   "Non-nil if w3m operations using link numbers are enabled.")
 (make-variable-buffer-local 'w3m-link-numbering-mode)
-(unless (assq 'w3m-link-numbering-mode minor-mode-map-alist)
-  (push (cons 'w3m-link-numbering-mode w3m-link-numbering-mode-map)
-	minor-mode-map-alist))
+(or (assq 'w3m-link-numbering-mode minor-mode-map-alist)
+    (push (cons 'w3m-link-numbering-mode w3m-link-numbering-mode-map)
(Continue reading)

Katsumi Yamaoka | 5 Jul 01:14 2010
X-Face

[emacs-w3m:11252] Re: [PATCH] w3m-lnum add highlight

In [emacs-w3m : No.11251] Andrey Kotlarski wrote:
> I enjoy both Conkeror and emacs-w3m and was quite happy to discover
> w3m-lnum which gives emacs-w3m one of the nicest features of Conkeror.
> One thing seems to be missing though, highlighting of the to be selected
> numbered anchor, so here's what I've come up with (don't use XEmacs so
> feel free to add what's needed to properly set overlay face).

Thank you for the patch.  I tried it (ignoring spurious diffs, and
renaming read-int-interactive into w3m-read-int-interactive; see
the new diff attached below).  However, there is one problem that
stops it working.  What is `right-char'?  That can be found in
w3m-highlight-numbered-anchor.

2010-07-04  Andrey Kotlarski  <m00naticus <at> gmail.com>

	* w3m-lnum.el: Update usage comment.
	(w3m-link-numbering-mode): Delete w3m-current-linknum overlay as well.
	(w3m-move-numbered-anchor): Fix grammar in error message.
	(w3m-go-to-linknum): Add autoload cookie.
	(w3m-read-int-interactive, w3m-highlight-numbered-anchor)
	(w3m-view-linknum): New functions.

Attachment: text/x-patch, 3848 bytes
Andrey Kotlarski | 6 Jul 00:31 2010
Picon

[emacs-w3m:11253] Re: [PATCH] w3m-lnum add highlight

Hello, Katsumi-san,
thanks for feedback and sorry for slight delay.  I decided to go a step
further in emulating Conkeror's behavior.  There's a function
`w3m-linknum-follow' which follows urls, activates form fields or pushes
buttons depending on what's selected (not sure whether done correctly
but works where tested).  It might be heretic but I changed behavior
(along highlighting matches) of `w3m-go-to-linknum' allowing it to go to
form fields and buttons as well, which seems more natural to me as
these elements are normally more difficult to "isearch".  Added a macro
`w3m-with-linknum' which can ease this type of functions (and bring old
behavior of `w3m-go-to-linknum' with a single digit change).  Made
`w3m-link-numbering-mode' more flexible allowing it 2 types of
enumeration - only url links (old behaviour and default) and urls along
with form fields and buttons for conveniences pointed above.  Also added
`w3m-linknum-read-url' for comfortable grabbing of urls and allowing for
such sort of actions:
(let ((url (w3m-linknum-read-url "Curl on link: ")))
  (if url (async-shell-command (concat "curl -O " url))))
A glitch that haven't yet overcome is changing faces of buttons on match.
Here's the diff against same current cvs w3m-lnum.el and hopefully this
time will work closer to advertised.

--- /home/andrey2/.emacs.d/extras/w3m/w3m-lnum-cvs.el	2010-04-27 15:46:24.000000000 +0300
+++ /home/andrey2/.emacs.d/extras/w3m/w3m-lnum.el	2010-07-06 01:27:28.681678592 +0300
 <at>  <at>  -1,6 +1,6  <at>  <at> 
 ;;; w3m-lnum.el --- Operations using link numbers

-;; Copyright (C) 2004, 2005, 2006, 2007, 2009
+;; Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010
 ;; TSUCHIYA Masatoshi <tsuchiya <at> namazu.org>
(Continue reading)

Kazuhiro NISHIYAMA | 6 Jul 04:11 2010

[emacs-w3m:11254] Re: (wrong-type-argument arrayp nil) in w3m-ems

西山和広です。

At Thu, 24 Jun 2010 19:25:38 +0900 (JST),
Hideyuki SHIRAI (白井秀行) wrote:
> 
> Emacs 22 未満でバイトコンパイルした *.elc を Emacs 23 でロードし
> ているような感じがします。*.elc を直接開いてみると、先頭の方にバ
> イトコンパイルした Emacs のバージョンが書いてあるので確かめてみ
> たらいかがでしょうか。

その通りだったようです。
EMACS を指定するようにして解決しました。

--

-- 
|ZnZ(ゼット エヌ ゼット)
|西山和広(Kazuhiro NISHIYAMA)

Katsumi Yamaoka | 6 Jul 05:40 2010
X-Face

[emacs-w3m:11255] Re: [PATCH] w3m-lnum add highlight

In [emacs-w3m : No.11253] Andrey Kotlarski wrote:
> Hello, Katsumi-san,

> Thanks for feedback and sorry for slight delay.

> I decided to go a step further in emulating Conkeror's behavior.
> There's a function `w3m-linknum-follow' which follows urls, activates
> form fields or pushes buttons depending on what's selected (not sure
> whether done correctly but works where tested).

Excellent!  It's easy to use, so you who love the w3m-lnum feature
should try the new behaviors soon.  I've already installed your
changes to CVS[1].  `C-c C-l' is what those who have never used
it do first.

> It might be heretic but I changed behavior (along highlighting matches)
> of `w3m-go-to-linknum' allowing it to go to form fields and buttons as
> well, which seems more natural to me as these elements are normally more
> difficult to "isearch".

Agreed.  I also agree to make the `C-c C-l' key be bound to
`w3m-linknum-follow' by default.  I.e., abolish `w3m-go-to-linknum'
and make indexing of forms the default.  Furthermore, I think it's
convenient if `w3m-read-int-interactive' turns off the
`w3m-link-numbering-mode' mode by the `C-c C-l' key input.  IOW,
making the `C-c C-l' key the toggle switch.  WDYT?

> Added a macro `w3m-with-linknum' which can ease this type of functions
> (and bring old behavior of `w3m-go-to-linknum' with a single digit change).

(Continue reading)

Andrey | 6 Jul 23:12 2010
Picon

[emacs-w3m:11256] Re: [PATCH] w3m-lnum add highlight

Hello,
thanks for enthusiastic reception :)

Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
> Agreed.  I also agree to make the `C-c C-l' key be bound to
> `w3m-linknum-follow' by default.  I.e., abolish `w3m-go-to-linknum'
> and make indexing of forms the default.

I find `w3m-go-to-linknum' handy when I want to navigate within
uncomfortable to reach with search areas or just peek url
behind link.  I think it must stay (and maybe at a single letter).  We
are spoiled with so many ways of navigating within Emacs.  I have
`w3m-linknum-follow' bound to "f", it's free within both lynx and info
keymaps and guess what, it's same in Conkeror.  Which makes me think of
"F" for `w3m-go-to-linknum'.

> [1] I've slightly changed your code.  Let me know if there's any
> oddity.

No problems detected.  Meanwhile, I've made some refinement/mess and
added things.  Having O(1) access over links, form fields and buttons is
great, just one thing left (?), images.  So added support for enumerating
images as well and an obvious example action over them - toggling.

> Furthermore, I think it's convenient if `w3m-read-int-interactive'
> turns off the `w3m-link-numbering-mode' mode by the `C-c C-l' key
> input.  IOW, making the `C-c C-l' key the toggle switch.  WDYT?

I think `w3m-read-int-interactive' is ok as is (didn't prepend w3m- in
the first try as it seems nicely decoupled general way to input an
(Continue reading)

Katsumi Yamaoka | 7 Jul 04:00 2010
X-Face

[emacs-w3m:11257] Re: [PATCH] w3m-lnum add highlight

In [emacs-w3m : No.11256] Andrey wrote:
> Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
>> Agreed.  I also agree to make the `C-c C-l' key be bound to
>> `w3m-linknum-follow' by default.  I.e., abolish `w3m-go-to-linknum'
>> and make indexing of forms the default.

> I find `w3m-go-to-linknum' handy when I want to navigate within
> uncomfortable to reach with search areas or just peek url
> behind link.  I think it must stay (and maybe at a single
> letter).

I see.

> We are spoiled with so many ways of navigating within Emacs.  I have
> `w3m-linknum-follow' bound to "f", it's free within both lynx and info
> keymaps and guess what, it's same in Conkeror.  Which makes me think of
> "F" for `w3m-go-to-linknum'.

Hm, at least I have no reason to object to the use of `f' and `F'.
However, I hesitate to use such precious single keystrokes.  Has
anyone reserved those keys for the future use?  Alternatively,
how about `C-c l' and `C-c C-l'?   In short in Japanese:

`f' キーを `w3m-linknum-follow' に、`F' キーを `w3m-go-to-linknum'
に、それぞれ割り当てることについてどう思いますか?
代わりに `C-c l' と `C-c C-l' では?

>> [1] I've slightly changed your code.  Let me know if there's any
>> oddity.

(Continue reading)

Andrey Kotlarski | 7 Jul 13:27 2010
Picon

[emacs-w3m:11258] Re: [PATCH] w3m-lnum add highlight

Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> Hm, at least I have no reason to object to the use of `f' and `F'.
> However, I hesitate to use such precious single keystrokes.  Has
> anyone reserved those keys for the future use?  Alternatively,
> how about `C-c l' and `C-c C-l'?

I've no objections, it's all Emacs, it's all good, rebinding is a
breeze.  For me it's that useful and as a bonus would be consistent for
Conkeror users.  Also as a sort of suggestion, I've
`w3m-linknum-toggle-image' on `C-c t' which also seems available in both
keymaps (don't know if this is that useful despite my frequent use).

> I just tried the new w3m-lnum.el.  Very good!!  Maybe the usage
> comment at the beginning of w3m-lnum.el is needless.  Instead,
> we will have to mention the features in the Info document.

Yep, if needed I can write some description.  But lets have at least a
week pass in case of more changes.

> Thanks.  Er, shouldn't `w3m-linknum-read-url' be as follows?
>
> (defun w3m-linknum-read-url (&optional prompt)
>   "docstring"
>   (let ((link (w3m-linknum-get-action (or prompt "Link number: ") 1)))

Thanks for spotting.

> And more, could you provide the ChangeLog entries by yourself?

(Continue reading)

Štěpán Němec | 7 Jul 15:18 2010
Picon

[emacs-w3m:11259] Re: [PATCH] w3m-lnum add highlight

Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
>> We are spoiled with so many ways of navigating within Emacs.  I have
>> `w3m-linknum-follow' bound to "f", it's free within both lynx and info
>> keymaps and guess what, it's same in Conkeror.  Which makes me think of
>> "F" for `w3m-go-to-linknum'.
>
> Hm, at least I have no reason to object to the use of `f' and `F'.
> However, I hesitate to use such precious single keystrokes.  Has
> anyone reserved those keys for the future use?  Alternatively,
> how about `C-c l' and `C-c C-l'?   In short in Japanese:
>
> `f' キーを `w3m-linknum-follow' に、`F' キーを `w3m-go-to-linknum'
> に、それぞれ割り当てることについてどう思いますか?
> 代わりに `C-c l' と `C-c C-l' では?

C-c l is out of the question. By an Emacs convention, C-c <alphabetic>
are reserved for users.

Štěpán

Katsumi Yamaoka | 8 Jul 09:54 2010
X-Face

[emacs-w3m:11260] Re: [PATCH] w3m-lnum add highlight

In [emacs-w3m : No.11258] Andrey Kotlarski wrote:
> Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

>> Hm, at least I have no reason to object to the use of `f' and `F'.
>> However, I hesitate to use such precious single keystrokes.  Has
>> anyone reserved those keys for the future use?  Alternatively,
>> how about `C-c l' and `C-c C-l'?

> I've no objections, it's all Emacs, it's all good, rebinding is a
> breeze.  For me it's that useful and as a bonus would be consistent for
> Conkeror users.  Also as a sort of suggestion, I've
> `w3m-linknum-toggle-image' on `C-c t' which also seems available in both
> keymaps (don't know if this is that useful despite my frequent use).

But Štěpán Němec wrote in http://article.gmane.org/gmane.emacs.w3m/8618 :
(Thanks Štěpán for pointing it out.)
> C-c l is out of the question. By an Emacs convention, C-c <alphabetic>
> are reserved for users.

So, we have no choice but to respect the rule.  Again, does anyone
object to the use of `f' and `F'?  I'll make those keys the default
bindings if no one brings another idea.

In Japanese: だれも代案を出さなければ、`f' と `F' を使っちゃうぞ。

[...]

>> And more, could you provide the ChangeLog entries by yourself?

> 2010-07-07  Andrey Kotlarski  <m00naticus <at> gmail.com>
(Continue reading)