Procrastiblog

November 25, 2007

Style Guidelines for People

Filed under: LaTeX — Chris @ 8:03 pm

In the midst of some unrelated Googling, I came across Luca de Alfaro’s style guidelines for student co-authors. This is good stuff. I particularly like “one sentence per line” b/w “fill-sentence macro”. It’s an elegant solution to a frequently annoying deficiency of diff, which is unfortunately the baseline for anyone collaborating via CVS or SVN. I tweaked his macro to get nice indentation in AucTeX:

(defun fill-sentence ()
  (interactive)
  (save-excursion
    (or (eq (point) (point-max)) (forward-char))
    (forward-sentence -1)
    (indent-relative)
    (let ((beg (point)))
      (forward-sentence)
      (if (equal "LaTeX" (substring mode-name (string-match "LaTeX" mode-name)))
          (LaTeX-fill-region-as-paragraph beg (point))
        (fill-region-as-paragraph beg (point))))))
(global-set-key "\ej" 'fill-sentence)

[UPDATE 1/20/08] Fixed an off-by-one error when the cursor is on the first character of the sentence by adding (forward-char).
[UPDATE 9/19/08] Fixed an error when the cursor is at the end of the buffer by changing (forward-char) to (or (eq (point) (point-max)) (forward-char))

2 Comments

  1. […] existing solutions are summarized in here. The  most promising Emacs Lisp macro is provided by Chris Conway, which was cribbed from Luca de Alfaro. Their method does the job well. However, suppose I have a […]

    Pingback by Better Sentence Filling in Emacs » Chi-kwan Chan's Website at Nordita — May 23, 2011 @ 3:47 pm

  2. […] existing solutions are summarized here. The  most promising lisp macro is provided by Chris Conway, which was cribbed from Luca de Alfaro. Their method does the job well. However, suppose I have a […]

    Pingback by Better Sentence Filling in Emacs » Chi-kwan Chan's Website at Nordita — May 23, 2011 @ 3:52 pm


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Blog at WordPress.com.