From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.help Subject: Re: show tabs and white space Date: Mon, 18 Apr 2005 08:47:20 +0900 Message-ID: <878y3hc6ev.fsf@tc-1-100.kawasaki.gol.ne.jp> References: Reply-To: Miles Bader NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1113782267 6359 80.91.229.2 (17 Apr 2005 23:57:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 17 Apr 2005 23:57:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 18 01:57:43 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DNJdw-0007y3-PJ for geh-help-gnu-emacs@m.gmane.org; Mon, 18 Apr 2005 01:57:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNJhw-0003OC-Q8 for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Apr 2005 20:01:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DNJff-00021P-90 for help-gnu-emacs@gnu.org; Sun, 17 Apr 2005 19:59:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DNJfb-0001zq-EO for help-gnu-emacs@gnu.org; Sun, 17 Apr 2005 19:59:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DNJex-0001Vc-3s for help-gnu-emacs@gnu.org; Sun, 17 Apr 2005 19:58:39 -0400 Original-Received: from [203.216.5.72] (helo=smtp02.dentaku.gol.com) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DNJVT-0000Ai-JK; Sun, 17 Apr 2005 19:48:52 -0400 Original-Received: from localhost ([127.0.0.1]) by smtp02.dentaku.gol.com with esmtp (Dentaku) id 1DNJU3-0004zr-DA; Mon, 18 Apr 2005 08:47:23 +0900 Original-Received: from yokohama2-61-203-152-195.ap.0038.net ([61.203.152.195] helo=tc-1-100.kawasaki.gol.ne.jp) by smtp02.dentaku.gol.com with esmtpa (Dentaku) id 1DNJU2-0004zd-2r; Mon, 18 Apr 2005 08:47:23 +0900 Original-Received: by tc-1-100.kawasaki.gol.ne.jp (Postfix, from userid 1000) id B717A2F7C; Mon, 18 Apr 2005 08:47:20 +0900 (JST) Original-To: help-gnu-emacs@gnu.org System-Type: i686-pc-linux-gnu In-Reply-To: (mgrd@gmx.net's message of "Thu, 14 Apr 2005 21:26:44 +0200") Original-Lines: 18 X-Virus-Scanned: by AMaViS GOL X-Abuse-Complaints: abuse@gol.com X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25761 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25761 --=-=-= Try the attached mode, `visible-whitespace-mode'. It is intended for the latest CVS Emacs, but may work ok for Emacs 21. It's somewhat different from typical "highlight whitespace" packages in that each whitespace character is indicated individually, even when they're adjacent to each other, which makes it easy to see otherwise hard to find whitespace problems. -Miles --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=visws.el Content-Transfer-Encoding: quoted-printable Content-Description: Emacs mode to indicate individual whitespace characters ;;; visws.el --- Make whitespace visible -*- coding: latin-1 -*- ;; ;; Copyright (C) 2001,2005 Free Software Foundation, Inc. ;; ;; Author: Miles Bader ;; Keywords: convenience ;; GNU Emacs 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 2, or (at your option) ;; any later version. ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; ;; Defines the mode `visible-whitespace-mode'. ;; ;; When active, normally invisible whitespace characters are made ;; visible. ;; ;; This is different from typical "highlight whitespace" packages in ;; that each whitespace character is indicated individually, even when ;; they're adjacent to each other, which makes it easy to see otherwise ;; hard to find whitespace problems. ;;; Code: ;; `char-displayable-p' was renamed from `latin1-char-displayable-p' in ;; Emacs 22 (if (fboundp 'char-displayable-p) (defalias 'visws-char-displayable-p 'char-displayable-p) (require 'latin1-disp) (defalias 'visws-char-displayable-p 'latin1-char-displayable-p)) (defface visible-whitespace '((t :foreground "blue" :bold t)) "Face for control-characters revealed by `visible-whitespace-mode'.") (defcustom visible-whitespace-mappings '((?\n [?$ ?\n]) ;; Note that TAB still tabs, but with a graphic indicator before the ;; tab; we only use single-character graphic indicator to reduce the ;; number of cases where the indicator causes the tabbing to be ;; screwed up. (?\t [?=BB ?\t] [?\\ ?\t]) (? [?=B7] [?.])) "An alist of mappings for displaying whitespace in `visible-whitespace-mo= de'. The car of each mapping is a whitespace character, and the cdr is a list of display vectors (a vector of characters). The first display vector the list that can be displayed is used; if no display vector for a mapping can be displayed, then that character is displayed unmodified. The characters in are displayed using the `visible-whitespace' face." :type 'list) (defun visws-legal-display-vector-p (vec) "Return true if every character in the display vector VEC can be displaye= d." (let ((i 0) (len (length vec))) (while (and (< i len) (visws-char-displayable-p (aref vec i))) (setq i (1+ i))) (=3D i len))) ;; Buffer local variable used to remember whether a buffer initially had ;; a local display table or not. (defvar visws-display-table-was-local nil) (define-minor-mode visible-whitespace-mode "Toggle Visible Whitespace mode When active, normally invisible whitespace characters are made visible. With prefix argument ARG, turn on if positive, otherwise off. Returns non-nil if the new state is enabled." nil " VisWS" nil (if visible-whitespace-mode (let ((face-bits (ash (face-id 'visible-whitespace) 19))) (set (make-local-variable 'visws-display-table-was-local) buffer-display-table) (unless buffer-display-table (setq buffer-display-table (make-display-table))) (dolist (entry visible-whitespace-mappings) (let ((vecs (cdr entry))) (while (and vecs (not (visws-legal-display-vector-p (car vecs)))) (setq vecs (cdr vecs))) (when vecs (let ((vec (copy-sequence (car vecs)))) (dotimes (i (length vec)) (when (not (eq (aref vec i) (car entry))) (aset vec i (logior (aref vec i) face-bits)))) (aset buffer-display-table (car entry) vec)))))) (if visws-display-table-was-local (dolist (entry visible-whitespace-mappings) (aset buffer-display-table (car entry) nil)) (setq buffer-display-table nil)))) ;;; visws.el ends here --=-=-= -- A zen-buddhist walked into a pizza shop and said, "Make me one with everything." --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --=-=-=--