From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Will Monroe Newsgroups: gmane.emacs.help Subject: Advice on troubleshooting function to "unscroll" Date: Sun, 25 Jan 2015 14:52:13 -0600 Message-ID: <54C5577D.4030700@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1422219407 9574 80.91.229.3 (25 Jan 2015 20:56:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 25 Jan 2015 20:56:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 25 21:56:46 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YFUEg-0000Ol-0I for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Jan 2015 21:56:46 +0100 Original-Received: from localhost ([::1]:38864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFUEf-0005Vs-Cu for geh-help-gnu-emacs@m.gmane.org; Sun, 25 Jan 2015 15:56:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFUAN-0008Vk-A0 for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 15:52:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFUAJ-0006Qi-RC for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 15:52:19 -0500 Original-Received: from mail-ob0-x22b.google.com ([2607:f8b0:4003:c01::22b]:38344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFUAJ-0006QX-Ld for help-gnu-emacs@gnu.org; Sun, 25 Jan 2015 15:52:15 -0500 Original-Received: by mail-ob0-f171.google.com with SMTP id va2so5050721obc.2 for ; Sun, 25 Jan 2015 12:52:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=j1AiSAUQnr/QVxalCDYfQQ87qpWYXbavXSw61mGn2es=; b=LwfKg5x31DbpjwsIl2BsS+w3GMcEurMCakwR8QU12j1pLu/pEN/2Kz0SM7gAuOjz7O 7zz7HWuU55+m/MvDWnOUmvPgXMQei+O8dsH40dREELtrre+vvzcQ96zxoauNKCT57jfC UdIwZKzbr6B+Xj+dwMH5Y3lOasrMEhCoqbc85u61Z14LkbgIdpwg1jfFcK4a2znNFjhw 9ClojpgLlKvmyaAjyn5uqsXRFD386ULL8dp2P0ojbeqYz3AVq7NXvxro+Nl2C3lkmbNo KQEnNo2FSrB4fEcVyp2KQ8/jdYUTqJ/XTbtdrpWKgFePfKA8ozJuvqysWtU0Nt/tvueT A7rQ== X-Received: by 10.202.102.21 with SMTP id a21mr6770236oic.118.1422219134787; Sun, 25 Jan 2015 12:52:14 -0800 (PST) Original-Received: from [10.70.17.167] (wsip-66-210-63-210.br.no.cox.net. [66.210.63.210]) by mx.google.com with ESMTPSA id k9sm4274117obh.0.2015.01.25.12.52.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Jan 2015 12:52:14 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::22b X-Mailman-Approved-At: Sun, 25 Jan 2015 15:56:36 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102250 Archived-At: Hello, I'm studying Emacs Lisp so that I can become more proficient at customizing GNU Emacs for purposes, mainly using org-mode. I'm studying alone using Bob Glickstein's *Writing GNU Emacs Extensions*. So far, the book has been a terrific guide to basic concepts. But I've run into a problem that I can't seem to troubleshoot any further and I'd appreciate advice on: 1) the best way to troubleshoot this problem (e.g., other forums, listservs, or IRC channels that might be more appropriate) and 2) troubleshooting the problem itself. I apologize in advance if this query has failed to take into account any basics or if it would be better posed elsewhere. I welcome your on the best way to proceed. So, following Glickstein's advice in Chapter 3, I'm trying to create a function that will allow me to create an "unscroll" function that will allow me to return to a prior buffer position after (inadvertently) pressing C-v a few times. The code to do this defines three new variables, defines advice for an extant Emacs function, scroll-up, and then defines a new function, unscroll. The code is below. #+BEGIN_SRC emacs-lisp (defvar unscroll-point nil "Cursor position for next call to 'unscroll'.") (defvar unscroll-window-start nil "Window start for next call to 'unscroll'.") (defvar unscroll-hscroll nil "Hscroll start for next call to 'unscroll'.") (defadvice scroll-up (before remember-for-unscroll activate compile) "Remember where we started from, for 'unscroll'." (if (not (eq last-command 'scroll-up)) (setq unscroll-point (point) unscroll-window-start (window-start) unscroll-hscroll (window-hscroll)))) (defun unscroll () "Revert to 'unscroll-point' and 'unscroll-window-start'." (interactive) (goto-char unscroll-point) (set-window-start nil unscroll-window-start) (set-window-hscroll nil unscroll-hscroll)) #+END_SRC I've loaded this code in Emacs under two different conditions: 1) by firing up a vanilla Emacs instance without any configuration file, and evaluating the code in scratch and 2) by saving the above code as the sole contents in a configuration file (~/.emacs.d/init.el) and then starting up Emacs. I've done this on two different machines both running versions of Emacs 24. The test was just opening a lengthy file, usually an info page or an existing org-mode file, pressing C-v a few times, and then using M-x unscroll. In all cases, I found that M-x unscroll would return to the position just before the last C-v but not to the original position. In other words, if I pressed C-v two times and then pressed M-x unscroll, in would only go back one C-v. My intent, and that of the example in the book, is to return the point the position before any C-v key sequences were pressed. I could move one but I suspect that the mistake I've made will come up again. I'd really welcome your (gentle) feedback! All the best, Will