Emacs的一个语法亮显问题

Vim、Emacs配置和使用
回复
field
帖子: 156
注册时间: 2005-05-31 19:32

Emacs的一个语法亮显问题

#1

帖子 field » 2006-08-06 10:39

找到了一个Ansys APDL语言的emacs的语法亮显的包。但是在.emacs文件中设置后不起效果,请各位指点。
语法亮显文件:ansys-mod.el
存放目录:/home/xsl/.emacs.d/elisp/ansys-mod.el
.emacs中相应的设置为:
;; Ansys APDL语法加亮
(load-file "/home/xsl/.emacs.d/elisp/ansys-mod.el")
(autoload 'ansys-mode "ansys-mod" nil t)
(setq auto-mode-alist
(cons '("\\.mac$" . ansys-mode) auto-mode-alist))
(setq auto-mode-alist (mapcar 'purecopy
'(("\\.mac\\'" . ansys-mode))))

(add-hook 'ansys-mode-hook
(lambda()
(abbrev-mode 1)
(auto-fill-mode 1)
(if (eq window-system 'x)
(font-lock-mode 1))))
;;

在emacs中打开类似于model.mac格式的文件没有语法加亮的效果,不知如何处理?
kardinal
帖子: 750
注册时间: 2006-03-19 11:39

#2

帖子 kardinal » 2006-08-06 22:45

M-x ansys-mode 试试……
field
帖子: 156
注册时间: 2005-05-31 19:32

#3

帖子 field » 2006-08-07 23:04

没有成功。
M-x ansys-mode 显示找不到匹配的命令。

下面是ansys-mode.el的开头一部分内容:

;;; ansys-mod.el --- editing Ansys log files under Emacs

;;; Copyright (C) 1997 Free Software Foundation, Inc.

;; Author: Tim Read <Tim.Read@fp.co.nz>
;; Author: Geoff Foster <fosterg@fp.co.nz>
;; Maintainer: Tim Read <Tim.Read@fp.co.nz>
;; Keywords: languages

;;
;; This file has used code from octave-mod.el
;; Copyright (C) 1997 Free Software Foundation, Inc.
;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
;; Author: John Eaton <jwe@bevo.che.wisc.edu>
;;

;; This file is part of GNU Emacs.

;; GNU Emacs 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.

;; GNU Emacs 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:

;; This package provides Emacs support for Ansys.
;; It defines Ansys mode, a major mode for editing Ansys log files.

;;; Code:

(defconst ansys-maintainer-address
"Tim Read <Tim.Read@fp.co.nz> "
"Current maintainer of the Emacs Ansys package.")

;; Extra highlighting of matching parenthesis (or brace or bracket)
(require 'paren)

(defvar ansys-abbrev-table nil
"Abbrev table for Ansys's reserved words.
All Ansys abbrevs start with a grave accent (`).")
(if ansys-abbrev-table
()
(let ((ac abbrevs-changed))
(define-abbrev-table 'ansys-abbrev-table ())
(define-abbrev ansys-abbrev-table "`i" "*IF,,LT,,THEN" nil)
(define-abbrev ansys-abbrev-table "`eli" "*ELSEIF," nil)
(define-abbrev ansys-abbrev-table "`el" "*ELSE\n" nil)
(define-abbrev ansys-abbrev-table "`ei" "*ENDIF\n" nil)
(define-abbrev ansys-abbrev-table "`cy" "*CYCLE" nil)
(define-abbrev ansys-abbrev-table "`d" "*DO,,1,10,1\n\n*ENDDO" nil)
(define-abbrev ansys-abbrev-table "`ex" "*EXIT" nil)
(define-abbrev ansys-abbrev-table "`g" "*GO" nil)
(define-abbrev ansys-abbrev-table "`cr" "*CREATE\n\n*END" nil)
(define-abbrev ansys-abbrev-table "`e" "*END" nil)
(define-abbrev ansys-abbrev-table "`rp" "/REPLOT" nil)
(define-abbrev ansys-abbrev-table "`t" "/TITLE," nil)
(setq abbrevs-changed ac)))

(defvar ansys-comment-char ?!
"Character to start an Ansys comment.")
kardinal
帖子: 750
注册时间: 2006-03-19 11:39

#4

帖子 kardinal » 2006-08-08 0:53

放到Emacs能找到的目录试试 比如 /usr/share/emacs/emacs23/lisp (印象中这样的)

或者将其存放的路径添加到配置文件中

(load-path "xxx") 应该是这样,记不清楚了,懒查了……

先不要在配置文件中写那个东东的语句,使用
M-x load-library 加载试试

然后
M-x ansy…… 中间多按几次TAB看看
field
帖子: 156
注册时间: 2005-05-31 19:32

#5

帖子 field » 2006-08-08 9:59

在执行 M-x load library 指定ansys-mod.el, 错误提示为: Invalid read syntax: ". in wrong context"
是不是 ansys-mod.el文件本身有问题?
kardinal
帖子: 750
注册时间: 2006-03-19 11:39

#6

帖子 kardinal » 2006-08-08 13:45

极有可能………………
回复