all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "CarlC" <carlc@snowbd.com>
Subject: Return to Marker
Date: Thu, 30 Jan 2003 17:38:39 GMT	[thread overview]
Message-ID: <zqd_9.2228$2y.74207@twister.austin.rr.com> (raw)

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")))))

             reply	other threads:[~2003-01-30 17:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-30 17:38 CarlC [this message]
2003-01-30 18:23 ` Return to Marker Jesper Harder
2003-01-30 19:48   ` CarlC
2003-01-30 20:44     ` Jesper Harder
  -- strict thread matches above, loose matches on Subject: below --
2003-01-30 20:35 Bingham, Jay

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='zqd_9.2228$2y.74207@twister.austin.rr.com' \
    --to=carlc@snowbd.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.