help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Smart" quotes and dashes in PSGML


From: Florian von Savigny
Subject: Re: "Smart" quotes and dashes in PSGML
Date: 28 Jul 2003 18:14:08 +0200


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 ­ (soft hyphen, which I frequently need), M-Space to  
(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 via email to

[Prev in Thread] Current Thread [Next in Thread]