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

453Bug in narrow-buffer? (selecting <1 line)

Expand Messages
  • Thomas Hundt
    Aug 28, 2001
    • 0 Attachment
      This might be a bug (I can reproduce it under NT/Solaris/Linux), version 01/08/01:

      Select some portion of a line (say, by double-clicking on a word or dragging over a few words).
      ^X-<    (does: 3 narrow-buffer, narrows buffer)
      Now the screen is blank (narrowing only works on a line-by-line basis?)
      ^X->  (does: 1 narrow-buffer -- un-narrows it)
      At this point it crashes on me.

      Also: while it's narrowed (blank window) if you do list-variables it will un-narrow the buffer before displaying them.

      Also, while we're on the subject, I think it would be nice if un-narrowing left you on the same line (in the overall file) that you were on initially.  I thought it used to do this, but maybe I'm just not remembering.  So I wrote the following, which does approximately that.  (It also leaves the narrowed area as the current region, so one can re-narrow to it immediately.)  It also is only really useful when using "normal" narrowing, i.e., narrowing to region (3 narrow-buffer).

      ; unnarrow-buffer: leave user at previously-narrowed area
      define-macro unnarrow-buffer
          set-variable #l3 $window-aline  ; save in case of failure
          ; Save narrowed area's start/end
          set-variable #l1 $window-aline
          backward-line ; otherwise $window-aline = EOF
          set-variable #l2 $window-aline
          !force 1 narrow-buffer
          !if $status  ; 1=succeed
              ; Set region to previously-narrowed area
              #l1 goto-line
              #l2 goto-line
              3 show-region
              show-region ;; doesn't work for some reason
              ; if narrow-buffer fails, now at EOF
              #l3 goto-line ; take us back to current line
              ml-write "[Buffer is not narrowed]"
      !force global-bind-key unnarrow-buffer "C-x >"


      Thomas Hundt <thundt@...> +1-415-643-3595