Loading ...
Sorry, an error occurred while loading the content.

reread-file -- correction

Expand Messages
  • Thomas Hundt
    A correction to the reread-file routine on the contrib page (http://www.jasspa.com/subs/sub3.txt). This macro has a bug whereby, if you have two files open at
    Message 1 of 1 , Aug 23, 2001
    • 0 Attachment
      A correction to the reread-file routine on the contrib page (http://www.jasspa.com/subs/sub3.txt).

      This macro has a bug whereby, if you have two files open at the same time (and visible on-screen), the one you aren't re-reading gets closed. The reason is that the 'read-file' command replaces the current buffer's contents -- I should have used 'find-file'. Sorry for the flakey code.

      The corrected version reads as follows:

      ;------------------------------------------------------------
      ; reread-file: reload the current file (w/ safety prompt)
      ;------------------------------------------------------------
      define-macro reread-file
      set-variable #l1 $window-aline
      set-variable #l2 $buffer-fname
      !if &bmod "edit"
      !if &iseq @mc1 "Buffer has been changed; reread anyway [y/n]? " "yYnN" "n"
      !abort
      !endif
      !endif
      0 delete-buffer $buffer-bname ; force destroy (prompting user doesn't work in macro)
      ml-write &spr "[Rereading %s]" #l2
      find-file #l2
      #l1 goto-line
      !emacro
      !force global-bind-key reread-file "C-x f"



      -Th

      __________
      Thomas Hundt <thundt@...> +1-415-643-3595
    Your message has been successfully submitted and would be delivered to recipients shortly.