From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: window-line and window-column Date: 10 Oct 2005 20:34:17 -0700 Organization: http://groups.google.com Message-ID: <1129001657.347176.35190@g47g2000cwa.googlegroups.com> References: <1128725063.828807.151870@f14g2000cwb.googlegroups.com> <87br1w3l6x.fsf@scholes.stanford.edu> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1129001843 14764 80.91.229.2 (11 Oct 2005 03:37:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Oct 2005 03:37:23 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 11 05:37:19 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EPAvx-0008JG-Tt for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Oct 2005 05:36:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EPAvw-0002lA-Ur for geh-help-gnu-emacs@m.gmane.org; Mon, 10 Oct 2005 23:36:08 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.uchicago.edu!newsread.com!news-xfer.newsread.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 41 Original-NNTP-Posting-Host: 71.34.3.210 Original-X-Trace: posting.google.com 1129001662 7552 127.0.0.1 (11 Oct 2005 03:34:22 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 11 Oct 2005 03:34:22 +0000 (UTC) In-Reply-To: <87br1w3l6x.fsf@scholes.stanford.edu> User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=71.34.3.210; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:134546 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:30126 Archived-At: Hovav Shacham wrote: > "rgb" 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))))))