Uwe,
This is not a modeline indicator that you asked about,
but I have to convert line ends frequently enough
that Byrel and I made a menu item to convert line end
styles a couple of years ago.
As an improvement. I was thinking of figuring out how to
display the current line-end style in
the title of the sub menu, which, while not on the modeline,
would be an indicator of the current style on a submenu.
That would at least save me from editing it as a hex file to see
which line ends style were being used in a file.
It also does not do anything with end of file
(control-Z?)--it just changes line ends, but that could probably
be added.
Hopefully someone who knows more about different encodings
can suggest improvements.
Posted inline, since I am not sure if we can post attachments.
;;; change-line-ends-menu.el
;;; Copyright (C) 2013 Steve Mitchell and Byrel Mitchell
;;; email: smitchel(a)bnin.net
;;; email: byrel.mitchell(a)gmail.com
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3, or (at your option)
;;; any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;;
;;;
;;; This adds a sub-menu item, Change Line Ends which offers choices
;;; to quickly change all line ends in a selection or a whole buffer
;;; to styles used by different OS's.
;;;
;;; The menu items have two components to their string names:
;;; - a character representation, i.e. CR-LF --> LF
;;; - an OS representation, i.e. DOS to Linux
;;; together, these representations help you quickly understand
;;; the choice to make in converting line ends.
;;;
;;; Note, Fanuc is the output of of GE's fanuc cnc machine controls
;;; this can be left off if this is not germane to your situation.
;;;
;;; Note: Windows is not left off to slight that Operating System.
;;; some programs in Windows still output DOS's line ends (CR LF)
;;; and some output just LF as line ends (like Linux generally does)
;;; so I am not sure how to implement that correctly.
(add-submenu '("Cmds") '("Change Line Ends"
["CR-LF --> LF (DOS to Linux)"
( change-line-ends "\^M\^J" "\^J")]
["CR-LF --> CR (DOS to Mac)"
( change-line-ends "\^M\^J" "\^M")]
["LF --> CR-LF (Linux to DOS)"
( change-line-ends "\^J" "\^M\^J")]
["LF --> CR (Linux to Mac)"
( change-line-ends "\^J" "\^M")]
["CR --> CR-LF (Mac to DOS)"
( change-line-ends "\^M" "\^J")]
["CR --> LF (Mac to Linux)"
( change-line-ends "\^M" "\^J")]
["LF-CR-CR --> LF (fanuc to Linux)"
( change-line-ends "\^J\^M\^M" "\^J")]) nil)
( defun change-line-ends (from to)
"Change line ends in whole buffor or marked block.
FROM is the line end to search for,
TO is the line end to replace it with."
(if (not (region-exists-p)) (goto-char (point-min)) ;if no selection,
do whole buffer
( goto-char point)) ;if a selection, go to
beginning. maybe not needed?
(while (search-forward-regexp from nil t ) ; do the requested
search/replace
(replace-match to)))
;--- end of change-line-ends-menu.el
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta