On Oct 27, 2011, at 2:38 AM, Keshav Kini wrote:
> Would it be possible to configure emacs to pretend there is space there, or 
> something like that? I imagine it should be easy to add something to ~/.emacs 
> which upon loading a .py or .pyx file searches for blocks of empty lines, 
> checks previous and following lines' indentation, and if it's the same both 
> above and below, apply the same indentation to all the empty lines in 
> between. Then another hook would, upon save-to-disk, just delete all trailing 
> whitespace again. This would transparently make the cursor movement nicer 
> within the open buffer for people who like it that way. Jason, what do you 
> think? (I CC'd Jason).

That's kind of a silly question.  Of course it's possible, that's why it's 
emacs. ;-)

I was playing around with something like this yesterday.  The following advice 
for next-line (and the same for previous-line) gets at least part of the way 
there, but I found I don't really like it personally.

(defadvice next-line (around empty-line-fix
                             (&optional arg try-vscroll)
                             activate)
  (let ((goal (or goal-column
                  (if (< (current-column) (current-indentation))
                      (current-column)
                    (current-indentation)))))

    ;; Delete trailing whitespace from the current line before moving
    (delete-trailing-whitespace (line-beginning-position)
                                (line-end-position))

    ;; Move the lines
    ad-do-it

    ;; Insert spaces as needed
    (when (and (> (- goal (current-column)) 0)
               (not (string-match "\\S "
                                  (buffer-substring-no-properties
                                   (line-beginning-position)
                                   (line-end-position)))))
      (insert-char ?\  (- goal (current-column))))))


-Ivan

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to