From: "rgb" <rbielaws@i1.net>
Subject: Re: window-line and window-column
Date: 10 Oct 2005 20:34:17 -0700 [thread overview]
Message-ID: <1129001657.347176.35190@g47g2000cwa.googlegroups.com> (raw)
In-Reply-To: <87br1w3l6x.fsf@scholes.stanford.edu>
Hovav Shacham wrote:
> "rgb" <rbielaws@i1.net> writes:
>
> > How can I tell where, within the current window, I am.
>
> Does any of the functions in windmove.el help? In particular,
> `windmove-coordinates-of-position'?
>
Apparently that's not part of CVS Emacs.
I did find a copy elsewhere and yes it does give me exactly
what I was looking for. Thanks.
Saddly, several hours after finishing my own version :(
Oh well. I've got a better understanding of compute-motion.
I think I'll be suggesting some wording changes to it's
doc string ... as soon as I think of something that might
have helped me <:'
(defun window-position (&optional visible)
"Returns the cons (screen-line . screen-column) of point.
When VISIBLE is non-nil a screen-column of 0 is returned when a
negative
value would otherwise be returned such as after (scroll-left).
nil is returned if current-buffer is not in the current window."
(if (eq (current-buffer) (window-buffer))
(if (or truncate-lines (/= 0 (window-hscroll)))
;; Lines never wrap when horizontal scrolling is in effect.
(let ((window-column (- (current-column)(window-hscroll)))
(window-line (count-lines (window-start)(point))))
(cond
((= 0 (current-column))
(cons window-line (if visible 0 window-column)))
((<= (current-column) (window-hscroll))
(cons (1- window-line) (if visible 0 window-column)))
(t (cons (1- window-line) window-column))))
;; When lines are not being truncated we deal with wrapping
(let ((window-column (% (current-column)(window-width)))
(window-line (count-screen-lines (window-start)(point))))
(if (= 0 window-column)
(cons window-line window-column)
(cons (1- window-line) window-column))))))
prev parent reply other threads:[~2005-10-11 3:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-07 22:44 window-line and window-column rgb
2005-10-07 23:08 ` Neon Absentius
2005-10-07 23:09 ` Lennart Borgman
2005-10-07 23:27 ` Johan Bockgård
2005-10-08 0:49 ` rgb
2005-10-11 4:05 ` Stefan Monnier
2005-10-11 4:38 ` rgb
2005-10-11 5:02 ` Stefan Monnier
2005-10-11 5:09 ` rgb
2005-10-13 18:02 ` rgb
2005-10-14 15:06 ` rgb
[not found] ` <mailman.10338.1128726582.20277.help-gnu-emacs@gnu.org>
2005-10-08 0:20 ` rgb
2005-10-08 2:29 ` Neon Absentius
2005-10-11 1:18 ` Hovav Shacham
2005-10-11 3:34 ` rgb [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1129001657.347176.35190@g47g2000cwa.googlegroups.com \
--to=rbielaws@i1.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).