X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fcoolj.el;h=d820525b3f0240a3afe0e41a5faa82b85cd16cd2;hp=77550602e5e1c08132b43a456b4d229fc40b2a1b;hb=fc4cda07a9afbbb545dcc6cd835ca697f6ef2a1b;hpb=0cf457b73b4b666314d1a09ac3e31bd0fa2346a6 diff --git a/emacs/coolj.el b/emacs/coolj.el index 77550602..d820525b 100644 --- a/emacs/coolj.el +++ b/emacs/coolj.el @@ -1,6 +1,6 @@ -;;; coolj.el --- automatically wrap long lines -*- coding:utf-8 -*- +;;; coolj.el --- automatically wrap long lines -*- lexical-binding: t; coding: utf-8 -*- -;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 2000, 2001, 2004-2009 Free Software Foundation, Inc. ;; Authors: Kai Grossjohann ;; Alex Schroeder @@ -21,17 +21,17 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . +;; along with GNU Emacs. If not, see . ;;; Commentary: -;;; This is a simple derivative of some functionality from -;;; `longlines.el'. The key difference is that this version will -;;; insert a prefix at the head of each wrapped line. The prefix is -;;; calculated from the originating long line. +;; This is a simple derivative of some functionality from +;; `longlines.el'. The key difference is that this version will +;; insert a prefix at the head of each wrapped line. The prefix is +;; calculated from the originating long line. -;;; No minor-mode is provided, the caller is expected to call -;;; `coolj-wrap-region' to wrap the region of interest. +;; No minor-mode is provided, the caller is expected to call +;; `coolj-wrap-region' to wrap the region of interest. ;;; Code: @@ -50,9 +50,7 @@ Otherwise respect `fill-column'." :group 'coolj :type 'regexp) -(defvar coolj-wrap-point nil) - -(make-variable-buffer-local 'coolj-wrap-point) +(defvar-local coolj-wrap-point nil) (defun coolj-determine-prefix () "Determine the prefix for the current line." @@ -107,12 +105,12 @@ not need to be wrapped, move point to the next line and return t." If the line should not be broken, return nil; point remains on the line." (move-to-column fill-column) - (if (and (re-search-forward "[^ ]" (line-end-position) 1) - (> (current-column) fill-column)) - ;; This line is too long. Can we break it? - (or (coolj-find-break-backward prefix) - (progn (move-to-column fill-column) - (coolj-find-break-forward))))) + (and (re-search-forward "[^ ]" (line-end-position) 1) + (> (current-column) fill-column) + ;; This line is too long. Can we break it? + (or (coolj-find-break-backward prefix) + (progn (move-to-column fill-column) + (coolj-find-break-forward))))) (defun coolj-find-break-backward (prefix) "Move point backward to the first available breakpoint and return t. @@ -135,12 +133,12 @@ If no breakpoint is found, return nil." If no break point is found, return nil." (and (search-forward " " (line-end-position) 1) (progn (skip-chars-forward " " (line-end-position)) - (null (eolp))) + (null (eolp))) (if (and fill-nobreak-predicate - (run-hook-with-args-until-success - 'fill-nobreak-predicate)) - (coolj-find-break-forward) - t))) + (run-hook-with-args-until-success + 'fill-nobreak-predicate)) + (coolj-find-break-forward) + t))) (provide 'coolj)