unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: "Smart" quotes and dashes in PSGML
       [not found] <pan.2003.07.19.16.31.24.555973@dzr-web.com>
@ 2003-07-28 16:14 ` Florian von Savigny
  2003-07-28 16:51   ` Benjamin Riefenstahl
  2003-07-28 16:54   ` Kai Großjohann
  0 siblings, 2 replies; 3+ messages in thread
From: Florian von Savigny @ 2003-07-28 16:14 UTC (permalink / raw)


[-- 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Smart" quotes and dashes in PSGML
  2003-07-28 16:14 ` "Smart" quotes and dashes in PSGML Florian von Savigny
@ 2003-07-28 16:51   ` Benjamin Riefenstahl
  2003-07-28 16:54   ` Kai Großjohann
  1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Riefenstahl @ 2003-07-28 16:51 UTC (permalink / raw)


Hi Florian,


Florian von Savigny <florian265@uboot.com> writes:
> Incidentally, it's a pity something like the following doesn't work:
>
>   (define-key sgml-mode-map [?ä] '(lambda (insert "\&auml\;")))

That would be

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


benny

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Smart" quotes and dashes in PSGML
  2003-07-28 16:14 ` "Smart" quotes and dashes in PSGML Florian von Savigny
  2003-07-28 16:51   ` Benjamin Riefenstahl
@ 2003-07-28 16:54   ` Kai Großjohann
  1 sibling, 0 replies; 3+ messages in thread
From: Kai Großjohann @ 2003-07-28 16:54 UTC (permalink / raw)


Florian von Savigny <florian265@uboot.com> writes:

> Incidentally, it's a pity something like the following doesn't work:
>
>   (define-key sgml-mode-map [?ä] '(lambda (insert "\&auml\;")))

I don't think that the small defuns are a problem, but why not try
this?

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

This assumes that the lambda expression was the problem.  If the [?ä]
part was the problem, please holler.
-- 
~/.signature

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-28 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <pan.2003.07.19.16.31.24.555973@dzr-web.com>
2003-07-28 16:14 ` "Smart" quotes and dashes in PSGML Florian von Savigny
2003-07-28 16:51   ` Benjamin Riefenstahl
2003-07-28 16:54   ` Kai Großjohann

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).