 
 ;;----------------------------------------------------------------------
 ;;
-;; Custom Behavior
-;;
-;; Activate behaviors not used regularly, but used nonetheless.
-;;
-
-
-(defun jpw-read-info-dir(file)
-  "Invoke Info on the named file, which should be a .info file or info
-top-level directory file."
-  (interactive "fInfo file to open: ")
-  (find-file file)
-  (Info-on-current-buffer)
-  )
-
-
-(defun set8tab ()
-  "Sets tab width to 8
-{jpw: 7/2000}."
-  (interactive)
-  (setq tab-width 8)
-  (recenter))
-
-
-(defun set4tab ()
-  "Sets tab width to 4
-{jpw: 7/2000}."
-  (interactive)
-  (setq tab-width 4)
-  (recenter))
-
-
-(defun c-no-comment-stars ()
-  (interactive)
-  ;; For Emacs 20.* or earlier
-;  (setq c-comment-continuation-stars "")
-  (setq c-block-comment-prefix "")
-)
-
-
-(defun do-comment-line-break ()
-  "Calls the function that the variable `comment-line-break-function'
-is set to
-{jpw: 3/2002}."
-  (interactive)
-  (funcall comment-line-break-function))
-
-
-(defvar jpw-utf-in-use nil
-  "Used internally.  Do not modify.  {jpw; 03/2007}")
-(defun jpw-load-utf()
-  "Force use of Mule UTF encodings. {jpw; 11/2005}"
-  (interactive)
-  (if (boundp 'mule-version)
-      (setq jpw-utf-in-use t)
-    )
-  (if (not jpw-utf-in-use)
-      (progn
-        ;; Taken from `loadup.el'
-        (load "international/mule")
-        (load "international/mule-conf.el") ; Don't get confused if someone
-                                            ; compiled this by mistake.
-        (load "international/mule-cmds")
-        (load "case-table")
-        (load "international/utf-8")
-        (load "international/utf-16")
-        (load "international/characters")
-        (load "international/ucs-tables")
-        (setq jpw-utf-in-use t)
-        )
-    )
-  )
-
-
-(defun decode-utf16 ()
-  "Decode a buffer in utf-16
-{jpw: 11/2005}."
-  (interactive)
-  (jpw-load-utf)
-  (decode-coding-region (point-min) (point-max)
-                        'mule-utf-16-le-with-signature))
-(defalias 'decode-xml 'decode-utf16)
-
-
-(defun decode-entire-buffer-utf8 ()
-  "Decode a buffer in utf-8
-Unfortunately, it doesn't work too well.
-
-{jpw: 03/2007}."
-  (interactive)
-  (jpw-load-utf)
-  (decode-coding-region (point-min) (point-max) 'mule-utf-8))
-
-
-(defun revert-to-utf8 ()
-  "Reread the current buffer, using utf-8 encoding this time.
-Unfortunately, it doesn't work too well.
-
-{jpw: 03/2007}."
-  (interactive)
-  (jpw-load-utf)
-  (revert-buffer-with-coding-system 'mule-utf-8)
-  ;;(let ((my-file-name (buffer-file-name (current-buffer)))
-  ;;      ;; Set this only for the duration of the scope of the (let ...).
-  ;;      (coding-system-for-read 'mule-utf-8)
-  ;;      (coding-system-for-write 'mule-utf-8)
-  ;;      );; end varbindings
-  ;;  (find-alternate-file my-file-name)
-  ;;  )
-  ;;(setq buffer-file-coding-system 'mule-utf-8)
-  )
-
-
-(defun use-utf8 ()
-  "Use the utf-8 encoding system in this buffer.  Does so by performing a
-`revert-to-utf8'.
-
-{jpw: 05/2008}."
-  (interactive)
-  (jpw-load-utf)
-  (revert-buffer-with-coding-system 'mule-utf-8)
-  (setq buffer-file-coding-system 'mule-utf-8)
-  )
-
-
-(defun jpw-sh-mode-font-lock-enhance ()
-  "Modify the variable `sh-font-lock-keywords-var' to correctly highlight
-function definitions in bash and ksh.
-
-{jpw:  08/2010}"
-  (let ((font-lock-sh-fn-name-keywords
-         ;; Function names.  Taken from sh-script.el
-         (list
-          '("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
-          '("\\<\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
-            (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
-          ))
-        (modified-keywords-var (list))
-        shell-specific-keywords
-        shell-type
-        new-keyword-regex
-        ) ;; end varbindings
-
-    (dolist (shell-specific-keywords sh-font-lock-keywords-var)
-      (setq shell-type (car shell-specific-keywords))
-      (if (or (equal shell-type 'bash)
-              (equal shell-type 'ksh)
-              (equal shell-type 'ksh88))
-          (dolist (new-keyword-regex font-lock-sh-fn-name-keywords)
-            (add-to-list 'shell-specific-keywords new-keyword-regex 't)
-            )
-        ) ;;end if
-      (add-to-list 'modified-keywords-var shell-specific-keywords 't)
-      )
-     (setq sh-font-lock-keywords-var modified-keywords-var)
-    ) ;; end let
-  )
-
-
-;;----------------------------------------------------------------------
-;;
 ;; Autohook-specific functions.
 ;;
 

  )


(defun reverse-indent-line ()
  "Remove a level of indentation from the current line.
{jpw: 10/2001}"
  (interactive)
  (save-excursion
    (beginning-of-line)
    (let ((bolp (point)))
      (back-to-indentation)
      (indent-rigidly bolp (point) (- 0 tab-width))
      ); end let
    ); end excursion
  )


(defun unindent-line ()
  "Remove all indentation from the current line.
{jpw: 12/1999}"
  (interactive)
  (save-excursion
    (beginning-of-line)
    (let ((bolp (point)))
      (back-to-indentation)
      (delete-region bolp (point))
      ); end let
    ); end excursion
  )


(defun untabify-buffer ()
  "Untabify the current buffer.
{jpw: 12/1998}"
  (interactive)
  (untabify (point-min) (point-max))
  )


(defun tabify-buffer ()
  "Untabify the current buffer.
{jpw: 09/2008}"
  (interactive)
  (tabify (point-min) (point-max))
  )


(defvar jpw-correct-tabs-on-save t
  "If set non-nil, causes `save-buffer-tab-consistent' and
`kill-buffer-tab-consistent' to convert all leading whitespace to
space-characters or tabs.  Which it converts to depends on the value of
`indent-tabs-mode'.
{jpw; 09/2008}")


(defun save-buffer-tab-consistent ()
  "Saves the current buffer, (un)tabifying it beforehand.

If `indent-tabs-mode' is true, calls `tabify-buffer' before saving.
Otherwise, it calls `untabify-buffer'.
{jpw: 9/1998}"
  (interactive)
  (if jpw-correct-tabs-on-save
      (if indent-tabs-mode
          (tabify-buffer)
        ;; else
        (untabify-buffer)
        )
    )
  (save-buffer)
  )


(defun server-quit-l ()
  "Saves the server-buffer, does a (server-edit), then kills the
buffer.
{jpw: 11/2004}"
  (interactive)
  (save-buffer)
  (if (not (or is-winblows is-cygwin))
      (progn
        (rename-buffer "oldserv")
        (server-edit)
        (switch-to-buffer "oldserv")
        ));; end if...progn
  (kill-this-buffer)
  )


(defun kill-buffer-other-window ()
  "Kill the buffer in the next open window.
{jpw: 12/2004}"
  (interactive)
  (other-window 1)
  (kill-this-buffer)
  (other-window -1)
  )


(defun kill-next-buffer-and-close-other-windows ()
  "Kill the buffer in the next open window, then close all of the other
windows.
{jpw: 2/2005}"
  (interactive)
  (other-window 1)
  (kill-this-buffer)
  (other-window -1)
  (delete-other-windows)
  )


(defun bury-buffer-other-window ()
  "Bury the buffer in the next open window.
{jpw: 12/2004}"
  (interactive)
  (other-window 1)
  (bury-buffer)
  (other-window -1)
  )


(defun switch-to-buffer-using-other-window (buffer)
  "Custom version of `switch-to-buffer-other-window' that remains in the
current window instead of switching.
{jpw: 12/2004}"
  (interactive "BOpen buffer in other window: ")
  (switch-to-buffer-other-window buffer)
  (other-window -1)
  )


(defun find-file-using-other-window (buffer)
  "Custom version of `find-file-other-window' that remains in the
current window instead of switching.
{jpw: 12/2004}"
  (interactive "FFind file in other window: ")
  (find-file-other-window buffer)
  (other-window -1)
  )


(defun kill-buffer-then-find-file (nubuffer)
  "Open the specified file in the current active window, first killing
whatever buffer is presently open.
{jpw: 2/2005}"
  (interactive "FKill this buffer, then find file: ")
  (kill-this-buffer)
  (find-file nubuffer)
  )


(defun switch-to-self-other-window ()
  "As the name implies.  Useful when working on a long piece of sourcecode.
{jpw: 12/2004}"
  (interactive)
  (let ((mybufname (current-buffer))
        );;end let-varlist
    (switch-to-buffer-using-other-window mybufname)
    );;end let
  )


(defun save-all-buffers ()
  "{jpw: 12/2004}"
  (interactive)
  (save-some-buffers t)
  )


(defun dos2unix-buffer ()
  "Convert a DOS buffer to raw unix text
{jpw: 5/2000}."
  (interactive)
  (set-buffer-file-coding-system 'raw-text-unix nil))


(defun unix2dos-buffer ()
  "Convert a DOS buffer to raw unix text
{jpw: 11/2000}."
  (interactive)
  (set-buffer-file-coding-system 'raw-text-dos nil))


(defun jpw-insert-doc-unitag (tagname)

    (delete-region oldeolpos (point))
    )
  )


(defun reverse-indent-line ()
  "Remove a level of indentation from the current line.
{jpw: 10/2001}"
  (interactive)
  (save-excursion
    (beginning-of-line)
    (let ((bolp (point)))
      (back-to-indentation)
      (indent-rigidly bolp (point) (- 0 tab-width))
      ); end let
    ); end excursion
  )


(defun unindent-line ()
  "Remove all indentation from the current line.
{jpw: 12/1999}"
  (interactive)
  (save-excursion
    (beginning-of-line)
    (let ((bolp (point)))
      (back-to-indentation)
      (delete-region bolp (point))
      ); end let
    ); end excursion
  )


(defun untabify-buffer ()
  "Untabify the current buffer.
{jpw: 12/1998}"
  (interactive)
  (untabify (point-min) (point-max))
  )


(defun tabify-buffer ()
  "Untabify the current buffer.
{jpw: 09/2008}"
  (interactive)
  (tabify (point-min) (point-max))
  )


(defvar jpw-correct-tabs-on-save t
  "If set non-nil, causes `save-buffer-tab-consistent' and
`kill-buffer-tab-consistent' to convert all leading whitespace to
space-characters or tabs.  Which it converts to depends on the value of
`indent-tabs-mode'.
{jpw; 09/2008}")


(defun save-buffer-tab-consistent ()
  "Saves the current buffer, (un)tabifying it beforehand.

If `indent-tabs-mode' is true, calls `tabify-buffer' before saving.
Otherwise, it calls `untabify-buffer'.
{jpw: 9/1998}"
  (interactive)
  (if jpw-correct-tabs-on-save
      (if indent-tabs-mode
          (tabify-buffer)
        ;; else
        (untabify-buffer)
        )
    )
  (save-buffer)
  )


(defun server-quit-l ()
  "Saves the server-buffer, does a (server-edit), then kills the
buffer.
{jpw: 11/2004}"
  (interactive)
  (save-buffer)
  (if (not (or is-winblows is-cygwin))
      (progn
        (rename-buffer "oldserv")
        (server-edit)
        (switch-to-buffer "oldserv")
        ));; end if...progn
  (kill-this-buffer)
  )


(defun kill-buffer-other-window ()
  "Kill the buffer in the next open window.
{jpw: 12/2004}"
  (interactive)
  (other-window 1)
  (kill-this-buffer)
  (other-window -1)
  )


(defun kill-next-buffer-and-close-other-windows ()
  "Kill the buffer in the next open window, then close all of the other
windows.
{jpw: 2/2005}"
  (interactive)
  (other-window 1)
  (kill-this-buffer)
  (other-window -1)
  (delete-other-windows)
  )


(defun bury-buffer-other-window ()
  "Bury the buffer in the next open window.
{jpw: 12/2004}"
  (interactive)
  (other-window 1)
  (bury-buffer)
  (other-window -1)
  )


(defun switch-to-buffer-using-other-window (buffer)
  "Custom version of `switch-to-buffer-other-window' that remains in the
current window instead of switching.
{jpw: 12/2004}"
  (interactive "BOpen buffer in other window: ")
  (switch-to-buffer-other-window buffer)
  (other-window -1)
  )


(defun find-file-using-other-window (buffer)
  "Custom version of `find-file-other-window' that remains in the
current window instead of switching.
{jpw: 12/2004}"
  (interactive "FFind file in other window: ")
  (find-file-other-window buffer)
  (other-window -1)
  )


(defun kill-buffer-then-find-file (nubuffer)
  "Open the specified file in the current active window, first killing
whatever buffer is presently open.
{jpw: 2/2005}"
  (interactive "FKill this buffer, then find file: ")
  (kill-this-buffer)
  (find-file nubuffer)
  )


(defun switch-to-self-other-window ()
  "As the name implies.  Useful when working on a long piece of sourcecode.
{jpw: 12/2004}"
  (interactive)
  (let ((mybufname (current-buffer))
        );;end let-varlist
    (switch-to-buffer-using-other-window mybufname)
    );;end let
  )


(defun save-all-buffers ()
  "{jpw: 12/2004}"
  (interactive)
  (save-some-buffers t)
  )


(defun dos2unix-buffer ()
  "Convert a DOS buffer to raw unix text
{jpw: 5/2000}."
  (interactive)
  (set-buffer-file-coding-system 'raw-text-unix nil))


(defun unix2dos-buffer ()
  "Convert a DOS buffer to raw unix text
{jpw: 11/2000}."
  (interactive)
  (set-buffer-file-coding-system 'raw-text-dos nil))


(defun jpw-session-reload ()
  "Reload the files from a previous session.  Will invoke `session-initialize'
if not done already.
{jpw:  8/2010}"
  (interactive)
  (if (not (boundp 'session-file-alist))
      ;; Ensure that we proceed only if we load and init the session pkg.
      (and
       (require 'session)
       (session-initialize)
       (let ((jpw-session-file))
         (dolist (jpw-session-file session-file-alist)
           (and
            (find-file (car jpw-session-file))
            (goto-char (cadr jpw-session-file))
            (if (caddr jpw-session-file)
                (push-mark (caddr jpw-session-file))
              t);; ensure that the 'if' always evals to true
            );; end inner-and
           );; end dolist
         );; end let
       );; end outer-and
    );; end if
  )


;;----------------------------------------------------------------------
;;
;; Custom Behavior
;;
;; Activate behaviors not used regularly, but used nonetheless.
;;


(defun jpw-read-info-dir(file)
  "Invoke Info on the named file, which should be a .info file or info
top-level directory file."
  (interactive "fInfo file to open: ")
  (find-file file)
  (Info-on-current-buffer)
  )


(defun set8tab ()
  "Sets tab width to 8
{jpw: 7/2000}."
  (interactive)
  (setq tab-width 8)
  (recenter))


(defun set4tab ()
  "Sets tab width to 4
{jpw: 7/2000}."
  (interactive)
  (setq tab-width 4)
  (recenter))


(defun c-no-comment-stars ()
  (interactive)
  ;; For Emacs 20.* or earlier
;  (setq c-comment-continuation-stars "")
  (setq c-block-comment-prefix "")
)


(defun do-comment-line-break ()
  "Calls the function that the variable `comment-line-break-function'
is set to
{jpw: 3/2002}."
  (interactive)
  (funcall comment-line-break-function))


(defvar jpw-utf-in-use nil
  "Used internally.  Do not modify.  {jpw; 03/2007}")
(defun jpw-load-utf()
  "Force use of Mule UTF encodings. {jpw; 11/2005}"
  (interactive)
  (if (boundp 'mule-version)
      (setq jpw-utf-in-use t)
    )
  (if (not jpw-utf-in-use)
      (progn
        ;; Taken from `loadup.el'
        (load "international/mule")
        (load "international/mule-conf.el") ; Don't get confused if someone
                                            ; compiled this by mistake.
        (load "international/mule-cmds")
        (load "case-table")
        (load "international/utf-8")
        (load "international/utf-16")
        (load "international/characters")
        (load "international/ucs-tables")
        (setq jpw-utf-in-use t)
        )
    )
  )


(defun decode-utf16 ()
  "Decode a buffer in utf-16
{jpw: 11/2005}."
  (interactive)
  (jpw-load-utf)
  (decode-coding-region (point-min) (point-max)
                        'mule-utf-16-le-with-signature))
(defalias 'decode-xml 'decode-utf16)


(defun decode-entire-buffer-utf8 ()
  "Decode a buffer in utf-8
Unfortunately, it doesn't work too well.

{jpw: 03/2007}."
  (interactive)
  (jpw-load-utf)
  (decode-coding-region (point-min) (point-max) 'mule-utf-8))


(defun revert-to-utf8 ()
  "Reread the current buffer, using utf-8 encoding this time.
Unfortunately, it doesn't work too well.

{jpw: 03/2007}."
  (interactive)
  (jpw-load-utf)
  (revert-buffer-with-coding-system 'mule-utf-8)
  ;;(let ((my-file-name (buffer-file-name (current-buffer)))
  ;;      ;; Set this only for the duration of the scope of the (let ...).
  ;;      (coding-system-for-read 'mule-utf-8)
  ;;      (coding-system-for-write 'mule-utf-8)
  ;;      );; end varbindings
  ;;  (find-alternate-file my-file-name)
  ;;  )
  ;;(setq buffer-file-coding-system 'mule-utf-8)
  )


(defun use-utf8 ()
  "Use the utf-8 encoding system in this buffer.  Does so by performing a
`revert-to-utf8'.

{jpw: 05/2008}."
  (interactive)
  (jpw-load-utf)
  (revert-buffer-with-coding-system 'mule-utf-8)
  (setq buffer-file-coding-system 'mule-utf-8)
  )


(defun jpw-sh-mode-font-lock-enhance ()
  "Modify the variable `sh-font-lock-keywords-var' to correctly highlight
function definitions in bash and ksh.

{jpw:  08/2010}"
  (let ((font-lock-sh-fn-name-keywords
         ;; Function names.  Taken from sh-script.el
         (list
          '("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face)
          '("\\<\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
            (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
          ))
        (modified-keywords-var (list))
        shell-specific-keywords
        shell-type
        new-keyword-regex
        ) ;; end varbindings

    (dolist (shell-specific-keywords sh-font-lock-keywords-var)
      (setq shell-type (car shell-specific-keywords))
      (if (or (equal shell-type 'bash)
              (equal shell-type 'ksh)
              (equal shell-type 'ksh88))
          (dolist (new-keyword-regex font-lock-sh-fn-name-keywords)
            (add-to-list 'shell-specific-keywords new-keyword-regex 't)
            )
        ) ;;end if
      (add-to-list 'modified-keywords-var shell-specific-keywords 't)
      )
     (setq sh-font-lock-keywords-var modified-keywords-var)
    ) ;; end let
  )


;;----------------------------------------------------------------------
;;
;; Unfill Paragraph Functions
;;


(defsubst jpw-unfill-paragraph-engine (remove-blank-lines
