smartquotes.el -- Insertion of unicode quotes in text documents

2007-08-25 Thread Martin Blais
;;; Commentary

;; The functions provided by xmlunicode.el for the insertion of the fancy
;; unicode quotes (double and single) take into account the context of the
;; document for XML documents. Those quotes are more useful, in my experience,
;; in text files written in UTF-8 encoding, such as ReST syntax. The XML
;; functions from xmlunicode often do not work properly in text files, due to
;; the presence of the occasional < or > symbol.

;; Therefore, the smart insertion functions are difficult to use, because their
;; behavior is unpredictable. In accordance with The Humane Interface principles
;; (see J.Raskins' book), we provide context-independent versions of these
;; functions that are much easier to learn and use quickly, since their
;; behaviour is unambigous.

;;; Usage

;; To use the suggested bindings, insert this in your .emacs:

;;(require 'smartquotes)
;;(add-hook 'text-mode-hook 'text-mode-unicode-hook)

;; This does the following for text-mode bindings:

;; - C-" inserts then cycles through the fancier double quotes;

;; - C-' inserts then cycles through the fancier single quotes;

;; - Inserting four dots inserts an ellipsis character. Inserting an additional
;;   fourth dot resumes with a string of dots;

;; - Inserting four hyphens inserts an mdash (a long dash character), then an
;;   ndash (an inter-word dash character), and then resumes with a string of
;;   normal hyphens.
;;; smartquotes.el --- Insertion of unicode quotes in text documents -*- coding: utf-8 -*-

;; Copyright (C) 2007 Martin Blais
;; Inspired by xmlunicode.el, Copyright (C) 2003 Norman Walsh

;; Author: Martin Blais <[EMAIL PROTECTED]>
;; Maintainer: Martin Blais <[EMAIL PROTECTED]>
;; Created: 2007-08-26
;; Version: 1.0
;; Keywords: utf-8 unicode characters

;; This file is NOT part of GNU emacs.

;; This 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.

;; This software 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

;; The functions provided by xmlunicode.el for the insertion of the fancy
;; unicode quotes (double and single) take into account the context of the
;; document for XML documents. Those quotes are more useful, in my experience,
;; in text files written in UTF-8 encoding, such as ReST syntax. The XML
;; functions from xmlunicode often do not work properly in text files, due to
;; the presence of the occasional < or > symbol.

;; Therefore, the smart insertion functions are difficult to use, because their
;; behavior is unpredictable. In accordance with The Humane Interface principles
;; (see J.Raskins' book), we provide context-independent versions of these
;; functions that are much easier to learn and use quickly, since their
;; behaviour is unambigous.

;;; Usage

;; To use the suggested bindings, insert this in your .emacs:

;;(require 'smartquotes)
;;(add-hook 'text-mode-hook 'text-mode-unicode-hook)

;; This does the following for text-mode bindings:

;; - C-" inserts then cycles through the fancier double quotes;

;; - C-' inserts then cycles through the fancier single quotes;

;; - Inserting four dots inserts an ellipsis character. Inserting an additional
;;   fourth dot resumes with a string of dots;

;; - Inserting four hyphens inserts an mdash (a long dash character), then an
;;   ndash (an inter-word dash character), and then resumes with a string of
;;   normal hyphens.

;;; Changes

;;; Code:

(defvar smartq-ldquo  (decode-char 'ucs #x00201c))
(defvar smartq-rdquo  (decode-char 'ucs #x00201d))
(defvar smartq-lsquo  (decode-char 'ucs #x002018))
(defvar smartq-rsquo  (decode-char 'ucs #x002019))
(defvar smartq-quot   (decode-char 'ucs #x22))
(defvar smartq-apos   (decode-char 'ucs #x27))
(defvar smartq-capos  (decode-char 'ucs #x0002bc))
(defvar smartq-ndash  (decode-char 'ucs #x002013))
(defvar smartq-mdash  (decode-char 'ucs #x002014))
(defvar smartq-hellip (decode-char 'ucs #x002026))

(defun smartq-cycle-chars (charlist)
  "Given that the last character is the given list, cycle the
  last char between the available characters in the list."
;;   (let ((ch (char-before)))
  (let ((newch (cadr (memq (char-before) 
			   (append charlist (list (car charlist)))
(if newch
	(progn 
	  (delete-backward-char 1)
	  (insert new

[Announce] haddoc and haddoc.el

2006-06-20 Thread Martin Blais

Description
===

Haddoc is a simple tool that allows an emacs user to search the Python HTML
documentation indexes and to bring a web browser to an index term page.

Motivation
--

Even though I have the Python TexInfo documentation installed from my Emacs,
somehow I always end up browsing the documentation from a web browser.  Most of
the time I start from either the Python Library Reference or from the index.  I
wanted to be able to bring up the documentation from within Emacs.   This does
it.

With haddoc, you invoke the elisp function ``haddoc-lookup`` (I type ``C-c .``),
enter some search terms, and the matches from the Python indexes are shown in a
buffer, from which you can select to direct your external web browser to.  I
like to drive an external Firefox with it.


Design
--

I took the simple approach and wrote a combination of Emacs-LISP and Python code
to implement this:

* ``haddoc-update``: a Python script that will parse the HTML documentation
 indexes and generate a mapping of the index entries to the HTML pages in a DBM
 database (in ``/var/lib/haddoc/haddoc.db`` by default)

* ``haddoc-lookup``: a Python script that does a lookup of search terms
 (potentially incomplete) on the index keys and returns the page references for
 each of the search terms on stdout

* ``haddoc.el``: an Emacs-LISP package that can query the results of
 ``haddoc-lookup`` and spawn a webbrowser to the appropriate pages.



Download at:
http://furius.ca/downloads/haddoc/releases/


Cheers,


___
gnu-emacs-sources mailing list
gnu-emacs-sources@gnu.org
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources


Re: other-window-or-buffer

2006-05-16 Thread Martin Blais
John Sturdy  ul.ie> writes:

> 
> Here's one of those "commands I wouldn't be without", to avoid all that
> typing of buffer names (and all that hurried mistyping of buffer
> names).
> 
> (defun other-window-or-buffer ()

I've got something different but similar in spirit, which cycles 
between all the windows of all the frames (all my emacs frames live 
in a single winmgr workspace):

(defun other-window-all-frames ()
  (interactive)
  (let* ((w (next-window nil nil 'visible))
 (f (window-frame w)))
(select-frame-set-input-focus f)
(select-window w)))

(substitute-key-definition
 'other-window (repeatable-command-def 'other-window-all-frames)
  (current-global-map))





___
gnu-emacs-sources mailing list
gnu-emacs-sources@gnu.org
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources