From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "CarlC" Newsgroups: gmane.emacs.help Subject: Return to Marker Date: Thu, 30 Jan 2003 17:38:39 GMT Organization: Road Runner - Texas Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1043948520 20562 80.91.224.249 (30 Jan 2003 17:42:00 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 30 Jan 2003 17:42:00 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18eIgH-0005I4-00 for ; Thu, 30 Jan 2003 18:40:53 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18eIgS-00021F-01 for gnu-help-gnu-emacs@m.gmane.org; Thu, 30 Jan 2003 12:41:04 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!news-west.rr.com!cyclone.austin.rr.com!twister.austin.rr.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 97 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Original-NNTP-Posting-Host: 24.153.208.137 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.austin.rr.com 1043948319 24.153.208.137 (Thu, 30 Jan 2003 11:38:39 CST) Original-NNTP-Posting-Date: Thu, 30 Jan 2003 11:38:39 CST Original-Xref: shelby.stanford.edu gnu.emacs.help:109589 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6106 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6106 I have a function that inserts some strings of text. Under normal circumstances, I want point to be back at the original position. My problem is that it only works part of the time, depending on where the original point was. When it fails, it puts me at a point towards the end of the buffer. I can't figure out why it works in some places and not in others. I have tried save-excusion and get the same results. The real clincher, is that it always works when I am debugging. I can press "c" as soon as I enter the debugger, and it still works. The line of code is "(goto-char custom-marker))" near the bottom of the function. It always seems to make it to this code with the correct value of custom-marker. I am running GNU Emacs 21.2.1. Everything else in the function works great. Thanks for any help on this. (defun insert-cobol-file (file-id) "Insert COBOL file into source." (interactive "sFile id: ") (let ((searches (list "DATA DIVISION." "WORKING-STORAGE SECTION." "SCREEN SECTION." "PROCEDURE DIVISION" "MAS-ERR SECTION." "END.DC" "PERFORM FILE-INIT")) (custom-marker (point-marker)) (initwarn nil)) (unwind-protect (progn (beginning-of-buffer) (let (err) (dolist (search searches err) (if (not (search-forward search nil t)) (error "Search failed: %s" search)))) (beginning-of-buffer) (search-forward (pop searches)) (previous-line 1) (beginning-of-line) (insert (format "\tCOPY \"UCOPY:%sFILE.SL\".\n" file-id)) (search-forward (pop searches)) (previous-line 1) (beginning-of-line) (insert (format "\tCOPY \"UCOPY:%sFILE.FD\".\n" file-id)) (search-forward (pop searches)) (previous-line 2) (beginning-of-line) (search-backward ".WS") (next-line 1) (beginning-of-line) (insert (format "\tCOPY \"UCOPY:%sFILE.WS\".\n" file-id)) (search-forward (pop searches)) (previous-line 1) (beginning-of-line) (insert (format "\tCOPY \"UCOPY:%sFILE.SS\".\n" file-id)) (search-forward (pop searches)) (search-forward ".") (backward-char) (insert (format ", %sFILE" file-id)) (if (> (current-column) 79) (progn (backward-word 1) (delete-backward-char 1) (insert "\n\t\t"))) (search-forward (pop searches)) (previous-line 1) (beginning-of-line) (insert (format "\tCOPY \"UCOPY:%sFILE.DC\".\n" file-id)) (search-forward (pop searches)) (if (not (char-equal (following-char) ?\.)) (setq initwarn (point))) (beginning-of-line) (if (char-equal (following-char) ?\*) (progn (setq initwarn (point)) (forward-char 1))) (let ((temp (point))) (next-line 1) (beginning-of-line) (copy-region-as-kill temp (point)) (yank) (previous-line 1) (search-forward "FILE") (delete-backward-char 4) (insert file-id)) (end-of-buffer) (previous-line 1) (beginning-of-line) ;(debug) (insert (format "\tCOPY \"UCOPY:%sFILE.OP\".\n" file-id))) (goto-char custom-marker)) (if initwarn (progn (set-mark custom-marker) (goto-char initwarn) (message "** WARNING ** FILE-INIT is not standard")))))