ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Guy Worthington <guyw@multiline.com.au>
Cc: auc-tex@sunsite.dk
Subject: Re: Emacs
Date: 27 Jul 2003 16:12:42 +0800	[thread overview]
Message-ID: <uadb0xu9x.fsf@multiline.com.au> (raw)
In-Reply-To: <3.0.5.32.20030726161830.00b22cf0@mail.northcoast.com>

David Arnold wrote:

> What can people tell me about setting up Emacs to work with Context?

> I'd like to gather all information I can.

Hello David,

I run fptex using Emacs 21.3 as an editor on a win2k box.

The customizations I describe below, have been hoarded from various
sources over some period (which of course has generated spaghetti
code).  Regularly, I promise myself, that I'll clean the code up, but
unfortunately my emacs has now become so electric, and the code so
opaque, that for me, it would be a major effort.

The ASCII figure below, shows how I've grouped my customizations into
different files.  I'd like to say that each file customizes a specific
behaviour in emacs, but I can't; the split up is not that logical.

                          default.el
                              |
     --------------------------
     |                        |
mmm-site.el          text-mode-site.el
                              |
                       context-site.el




Starting from the top:



default.el contains the look and feel.  My preferences being to:

  1) keep the Emacs display fairly small (80 character wide, and 
     30 lines deep);

  2) have syntax highlighting wound up to the maximum

The only external lisp code, in default.el is for parenthesis
highlighting.  The package is called mic-paren.el.


;; default.el -------------------------------------------------------

;; set a default font for W3
(setq w32-enable-italics t) ; This must be done before font settings!
;Set the default color, font and frame size for the initial frame.
(setq default-frame-alist
      '(;(menu-bar-lines)
	(vertical-scroll-bars)
	(top . 30) (left . 30)
	(width . 80) (height . 30)
	(cursor-color . "Red")
	(cursor-type . bar)
	(foreground-color . "black")
	(background-color . "IVORY")
	(font . "-*-Courier New-normal-r-*-*-11-82-96-96-c-*-iso8859-1")))

(set-face-background 'modeline "navy")
(set-face-foreground 'modeline "gold")

(set-face-font 'italic "-*-Courier New-normal-i-*-*-11-82-96-96-c-*-iso8859-1")
(set-face-font 'bold "-*-Courier New-bold-r-*-*-11-82-96-96-c-*-iso8859-1")
(set-face-font 'bold-italic "-*-Courier New-bold-i-*-*-11-82-96-96-c-*-iso8859-1")

;; display ISO-Latin-1 characters with accents
;; required for gnus summary display
(standard-display-european t)
;; switch to ISO-Latin-1 (emacs > 20.3)
(set-language-environment "Latin-1")

;; Set the default coding system to be foo-unix, instead of the foo-dos
(setq default-buffer-file-coding-system 'latin-1-unix)

;; allow multiple major modes
(require 'mmm-site)

;; completion-ignored-extensions
(setq completion-ignored-extensions
      (append completion-ignored-extensions
	      (list ".ilg" ".ind" ".pdf" ".tui" ".tuo" ".ted" ".tmp"
		    ".orig" ".ps" ".mp" ".mpo" "mpd"
		    ".1" ".2" ".3" ".4" ".5" ".6" ".7" ".8" ".9")))

;; fontification font-lock.el
;; Must be defined before font lock is loaded.
(setq font-lock-maximum-decoration t)
(global-font-lock-mode t)

;; lazy-lock-mode on by default
(setq font-lock-support-mode 'lazy-lock-mode
      lazy-lock-defer-on-scrolling t)

;; mic-paren.el display highlighting on parenthesis
;; http://www.docs.uu.se/~mic/emacs.html
(require 'mic-paren)
(paren-activate)

;; text mode
(require 'text-mode-site)

;; end of default.el-----------------------------------------------------



mmm-site

Because ConTeXt has now become so intertwined with metapost, I now run
two major modes within a single buffer.  I've embedded the metapost
inside the ConTeXt, using the external mode, MMM Mode.  This package
also doesn't come with Emacs.

;; mmm-site.el --------------------------------------------------
;; load just enough of mmm mode so that it turns itself on
(require 'mmm-auto)

(setq mmm-global-mode 'maybe)

;; for context/metapost
(mmm-add-group 'context-metapost
	       '((context-MPgraphic
		  :submode metapost-mode
		  :face mmm-code-submode-face
		  :front "\\\\startuseMPgraphic"
		  :back "\\\\stopuseMPgraphic")
		 (context-MPcode
		  :submode metapost-mode
		  :face mmm-code-submode-face
		  :front "\\\\startMPcode"
		  :back "\\\\stopMPcode")
		 ))

(add-to-list 'mmm-mode-ext-classes-alist '(nil "\\.ctx\\'" context-metapost))

(provide 'mmm-site)
;; ----------------------------------------------------------------------



text-mode-site.el

text-mode-site provide a couple of electric features, that are common
to all text files (XML files, emails, etc.).  I'm a very slow typist,
and word expansion speeds up my typing. (After my space-bar, I think 
ctrl-<TAB> is my most used key.)

Bracket completion is also very useful.

;;; text-mode-site.el ---------------------------------------------------

;;;;;;;;;;;;;;;;;;;;;Ralf Stubner (from comp.text.tex newsgroup)
(require 'tempo)
(setq transient-mark-mode t)
; `tempo-define-template' returns an interactive function, which is
; then bound to the appropriate key. The `r' simply stands for
; `region'. There are many more possibilities here.
(defun my-text-mode-hook ()
     (local-set-key
      "{" (tempo-define-template "TeX-schweif" '("{" r "}")))
     (local-set-key
      "(" (tempo-define-template "TeX-rundekl" '("(" r ")")))
     (local-set-key
      "[" (tempo-define-template "TeX-eckigek" '("[" r "]")))
;;      (local-set-key
;;       "^" (tempo-define-template "TeX-exponen" '("^{" r "}")))
;;      (local-set-key
;;        "_" (tempo-define-template "TeX-subscri" '("_{" r "}")))
;;      (local-set-key
;;       "$" (tempo-define-template "TeX-dollarm" '("$" r "$")))
     (local-set-key
      "<" (tempo-define-template "XML-tag" '("<" r ">")))
     (turn-on-filladapt-mode)
     (ispell-minor-mode 1)
     (abbrev-mode 1))
(add-hook 'text-mode-hook 'my-text-mode-hook)
;;;;;;;;;;;;;;;;;;;;;

;; Klaus Berndl
;; we want to complete and expand as much as possible in all buffers.
;; order of try-functions is significant!
;; includes the whole dabbrev-stuff!
(require 'hippie-exp)
(setq hippie-expand-try-functions-list
      '(;; try-complete-tempo-tag
        try-expand-dabbrev
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-complete-file-name-partially
        try-complete-file-name
        ;;        try-expand-list
        try-complete-lisp-symbol-partially
        try-complete-lisp-symbol
        try-expand-whole-kill))
;; the expand-function. Called with a positive prefix <P> it jumpes direct
;; to the <P>-th try-function.
(defun my-hippie-expand (arg)
  (interactive "P")
  ;; hippie-expand does not have a customization-feature (like
  ;; dabbrev-expand) to search case-sensitive for completions.
  ;; So we must set 'case-fold-search' temp. to nil!
  (let ((old-case-fold-search case-fold-search))
    (setq case-fold-search nil)
    (hippie-expand arg)
    (setq case-fold-search old-case-fold-search)
    )
  )
;; all expansion is done by 'my-hippie-expand bound to C-TAB!
(global-set-key (quote [C-tab]) (quote my-hippie-expand))
;;

(require 'context-site)

(provide 'text-mode-site)

;; end of text-mode-site -------------------------------------------




context-site.el 

The other major mode is ConTeXt, it requires the external package, 
context.el, which is available from the third-party packages on 
Hans Hagen's pragma-ade web site.


;; context-site.el -----------------------------------------------------

(require 'context)

(setq auto-mode-alist (cons '("\\.ctx$" . tex-mode) auto-mode-alist))

(provide 'context-site)

;; end of context-site.el----------------------------------------------


As you can see it is very spartan.  Indeed the file isn't really
needed since I call conTeXt files by using Local variables hooks in my
ConTeXt source code.  That is, I append, the following tags to the end
of every ConTeXt file:

%%% Local Variables:
%%% mode:context
%%% indent-tabs-mode:nil 
%%% End:



Invoking ConTeXt:

I don't use Emacs to invoke ConTeXt.  I invoke it from a separate
command shell, using the fptex executable texexec, and a view the
resultant pdf file using the fptex executable pdfopen, and afterwards
close it using pdfclose.

       reply	other threads:[~2003-07-27  8:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3.0.5.32.20030726161830.00b22cf0@mail.northcoast.com>
2003-07-27  8:12 ` Guy Worthington [this message]
2003-07-28  7:33 ` Emacs Mari Voipio
2003-07-28 15:52   ` Emacs David Arnold
2003-07-28 16:57 ` Emacs Alexander Klink
2003-07-28 17:20   ` Emacs Patrick Gundlach
2008-10-21 17:56 PhD Thesis in ConTeXt Piotr
2008-10-21 22:46 ` Marcin Borkowski
2008-10-22  5:31   ` emacs (was: Re: PhD Thesis in ConTeXt) Peter Münster
2008-10-22  6:18     ` Marcin Borkowski
2008-10-22 10:50       ` emacs Gour
2008-10-23 21:08       ` emacs Peter Münster
2008-10-23 22:46         ` emacs Marcin Borkowski
2009-02-05 15:06           ` emacs Peter Münster
2009-02-05 15:19             ` emacs luigi scarso
2009-02-05 19:15               ` emacs Peter Münster

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

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

  git send-email \
    --in-reply-to=uadb0xu9x.fsf@multiline.com.au \
    --to=guyw@multiline.com.au \
    --cc=auc-tex@sunsite.dk \
    --cc=ntg-context@ntg.nl \
    /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 NNTP newsgroup(s).