[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: w3m-end-of-line, kill-line should stop at whitespace
- From: Katsumi Yamaoka <yamaoka@xxxxxxx>
- Date: Tue, 27 May 2008 19:14:51 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 10173
- References: <87od6zyz5m.fsf@xxxxxxxxxxx>
>>>>> In [emacs-w3m : No.10152] jidanni@xxxxxxxxxxx wrote:
> On the Location: line at the top of a page do C-e (w3m-end-of-line),
> it should stop at the last character. Not the end of the screen.
> Do C-k and then paste later with C-y, you'll see all these blanks appended:
> "Location: http://en.wikipedia.org/wiki/Who_Let_the_Dogs_Out%3F "
> ^^^^^^^^^^^^^
> I notice the same problem with any text in HTML <div align="center"> too.
> emacs-w3m-version "1.4.263"
I have two ideas, though I think each of them is not good enough.
1. Remove those trailing whitespaces.
(add-hook
'w3m-fontify-after-hook
(lambda nil
(let ((inhibit-read-only t))
(goto-char (point-min))
(while (re-search-forward " +$" nil t)
(delete-region (match-beginning 0) (match-end 0))))))
2. Modify `w3m-end-of-line' so that it moves the point to the end
of non-whitespace characters first and moves the point to the
real end of the line at the second time. For `C-k', bind the
key to the new function `w3m-kill-line'.
--8<---------------cut here---------------start------------->8---
(defun w3m-end-of-line (&optional arg)
"Move the point to the end of the line and scroll the window left.
It makes the ends of upper and lower three lines visible. If
`truncate-lines' is nil, it works identically as `end-of-line'."
(interactive "P")
(w3m-keep-region-active)
(if truncate-lines
(progn
(when (listp arg)
(setq arg (car arg)))
(when arg
(next-line (1- arg)))
(let ((inhibit-point-motion-hooks t)
home)
(unless (prog1
(looking-at " *$")
(end-of-line))
(skip-chars-backward " "))
(setq home (point)
arg (current-column))
(dolist (n '(-3 -2 -1 1 2 3))
(forward-line n)
(end-of-line)
(setq arg (max (current-column) arg))
(goto-char home)))
(setq temporary-goal-column arg
this-command 'next-line)
(w3m-set-window-hscroll (selected-window)
(max (- arg (window-width) -2) 0)))
(set-window-hscroll (selected-window) 0)
(end-of-line arg)))
(defun w3m-kill-line ()
"Add the rest of the current line to the `kill-ring'.
Whitespace around the text is ignored."
(interactive)
(let ((deactivate-mark nil))
(kill-new (if (looking-at " *\\([^\n ]+\\(?: *[^\n ]+\\)*\\)")
(match-string 1)
""))))
(define-key w3m-mode-map "\C-k" 'w3m-kill-line)
--8<---------------cut here---------------end--------------->8---