unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Florian von Savigny <florian265@uboot.com>
Subject: Re: "Smart" quotes and dashes in PSGML
Date: 28 Jul 2003 18:14:08 +0200	[thread overview]
Message-ID: <m3he56bpdb.fsf@russel.teuto37> (raw)
In-Reply-To: pan.2003.07.19.16.31.24.555973@dzr-web.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3045 bytes --]



Here's another solution that appears crude rather then sophisticated
to me, as does Kevin's, but it is tested and works.

It's for the characters äöüÄÖÜß (which may not be what you precisely
need), but it only has to be changed like a template to cover other
characters / keys. Of course you don't have to do it as one compact
set either. I have, for instance, independently bound ~ to insert the
entity &shy; (soft hyphen, which I frequently need), M-Space to &nbsp;
(nobreak space), and so on.

Incidentally, it's a pity something like the following doesn't work:

  (define-key sgml-mode-map [?ä] '(lambda (insert "\&auml\;")))

since that would save writing all those stupid little function
definitions (real elisp programmers will moan about my poor grasp of
it, though -- I keep forgetting even the difference between progn and
lambda).


(defun sgml-insert-auml ()
  (interactive)
  (insert "\&auml\;"))

(defun sgml-insert-ouml ()
  (interactive)
  (insert "\&ouml\;"))

; and so on ...

; the following works only because I have (set-keyboard-coding-system
; 'iso-latin-1) in .emacs. Otherwise, I'd have to use the unibyte
; representations like [223] for ß, for instance

(defun sgml-iso-ent-no-direct-insert ()
  (define-key sgml-mode-map [?ä] 'self-insert-command)	
  (define-key sgml-mode-map [?ö] 'self-insert-command)
  (define-key sgml-mode-map [?ü] 'self-insert-command)
  (define-key sgml-mode-map [?Ä] 'self-insert-command)
  (define-key sgml-mode-map [?Ö] 'self-insert-command)
  (define-key sgml-mode-map [?Ü] 'self-insert-command)
  (define-key sgml-mode-map [?ß] 'self-insert-command)
  (message "Direct ISO entity input for äöüÄÖÜß switched OFF"))

(defun sgml-iso-ent-direct-insert ()
  (define-key sgml-mode-map [?ä] 'sgml-insert-auml)  ; [228]
  (define-key sgml-mode-map [?ö] 'sgml-insert-ouml)  ; [246]
  (define-key sgml-mode-map [?ü] 'sgml-insert-uuml)  ; [252]
  (define-key sgml-mode-map [?Ä] 'sgml-insert-Auml)  ; [196]
  (define-key sgml-mode-map [?Ö] 'sgml-insert-Ouml)  ; [214]
  (define-key sgml-mode-map [?Ü] 'sgml-insert-Uuml)  ; [220]
  (define-key sgml-mode-map [?ß] 'sgml-insert-szlig) ; [223]
  (message "Direct ISO entity input for äöüÄÖÜß switched ON"))



(defun sgml-toggle-iso-ent-direct-insert ()
  "For äöüÄÖÜß, toggle between inserting character or ISO entity"
  (interactive)
  (if (where-is-internal 'sgml-insert-auml sgml-mode-map)
                         ; in other words: if that is bound to a key,
                         ; all the others will be, too
	(sgml-iso-ent-no-direct-insert)
    (sgml-iso-ent-direct-insert)))


; finally, maybe more comfortable:

(add-hook 'sgml-mode-hook 
	  '(lambda ()
             (sgml-iso-ent-direct-insert)
	     (define-key sgml-mode-map "\C-c&" 
			 'sgml-toggle-iso-ent-direct-insert)))


-- 


Florian v. Savigny

If you are going to reply in private, please be patient, as I only
check for mail something like once a week. - Si vous allez répondre
personellement, patientez s.v.p., car je ne lis les courriels
qu'environ une fois par semaine.

       reply	other threads:[~2003-07-28 16:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pan.2003.07.19.16.31.24.555973@dzr-web.com>
2003-07-28 16:14 ` Florian von Savigny [this message]
2003-07-28 16:51   ` "Smart" quotes and dashes in PSGML Benjamin Riefenstahl
2003-07-28 16:54   ` Kai Großjohann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3he56bpdb.fsf@russel.teuto37 \
    --to=florian265@uboot.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).