diff --git a/emacs-irsim-mode.spec b/emacs-irsim-mode.spec new file mode 100644 index 0000000..0e2f1f0 --- /dev/null +++ b/emacs-irsim-mode.spec @@ -0,0 +1,102 @@ +%global pkg irsim-mode +%global pkgname Emacs-irsim-mode + +%if %($(pkg-config emacs) ; echo $?) +%global emacs_version 21.1 +%global emacs_lispdir %{_datadir}/emacs/site-lisp +%global emacs_startdir %{_datadir}/emacs/site-lisp/site-start.d +%else +%global emacs_version %(pkg-config emacs --modversion) +%global emacs_lispdir %(pkg-config emacs --variable sitepkglispdir) +%global emacs_startdir %(pkg-config emacs --variable sitestartdir) +%endif + + +Name: emacs-%{pkg} +Version: 0.1 +Release: 6%{?dist} +Summary: Irsim mode for emacs + +Group: Applications/Editors +License: MIT +URL: http://code.google.com/p/irsim-mode/ +Source0: http://irsim-mode.googlecode.com/files/irsim-mode.el +Source1: %{pkg}-init.el +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildArch: noarch +BuildRequires: emacs emacs-el +Requires: emacs >= %{emacs_version} + +%description +IRSIM is a switch-level simulator for digital logic circuits. +This is an Emacs mode for editing IRSIM netlists. It provides +syntax highlighting and an extremely pleasant method if indentation. + + +%package el +Summary: Source files for %{pkgname} under GNU Emacs +Group: Applications/Editors +Requires: %{name} = %{version}-%{release} + +%description el +This package contains the elisp source files for +use with %{pkgname}. + +%prep +%{__rm} -rf %{_builddir}/%{name}-%{version} +%{__mkdir} -p %{_builddir}/%{name}-%{version} +cp -p %{SOURCE0} %{_builddir}/%{name}-%{version} +cp -p %{SOURCE1} %{_builddir}/%{name}-%{version} + + +%build +cd %{name}-%{version} +emacs -batch -f batch-byte-compile %{pkg}.el + +%install +%{__rm} -rf %{buildroot} +cd %{name}-%{version} +%{__install} -pm 755 -d %{buildroot}%{emacs_lispdir}/irsim-mode/ +%{__install} -pm 755 -d %{buildroot}%{emacs_startdir} +%{__install} -pm 644 %{pkg}.* %{buildroot}%{emacs_lispdir}/%{pkg} +%{__install} -pm 644 %{SOURCE1} %{buildroot}%{emacs_startdir} + + +%clean +%{__rm} -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%{emacs_lispdir}/%{pkg}/*.elc +%{emacs_startdir}/%{pkg}-init.el +%dir %{emacs_lispdir}/%{pkg} +%dir %{emacs_startdir} + +%files el +%defattr(-,root,root,-) +%{emacs_lispdir}/%{pkg}/*.el + +%changelog +* Tue Dec 08 2009 Arun SAG - 0.1-6 +- Fixed Requires for centos + +* Mon Dec 07 2009 Arun SAG - 0.1-5 +- Fixed installtion failure in EL-5 +- irsim-mode handles .out files + +* Thu Dec 03 2009 Arun SAG - 0.1-4 +- Timestamps are preserved +- Autoloads for more file types added + +* Wed Dec 02 2009 Arun SAG - 0.1-3 +- Description updated +- source1 updated + +* Wed Dec 02 2009 Arun SAG - 0.1-2 +- Reduntant globals removed +- Description updated + +* Wed Dec 02 2009 Arun SAG - 0.1-1 +- Initial release 0.1-1 diff --git a/import.log b/import.log new file mode 100644 index 0000000..a6ef52c --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +emacs-irsim-mode-0_1-6_fc12:F-12:emacs-irsim-mode-0.1-6.fc12.src.rpm:1260383425 diff --git a/irsim-mode-init.el b/irsim-mode-init.el new file mode 100644 index 0000000..4a647c5 --- /dev/null +++ b/irsim-mode-init.el @@ -0,0 +1,10 @@ +;; Init file for irsim mode +(autoload 'irsim-mode "irsim-mode" nil t) +(setq auto-mode-alist + (cons '("\\.sim$" . irsim-mode) auto-mode-alist)) +(setq auto-mode-alist + (cons '("\\.cmd$" . irsim-mode) auto-mode-alist)) +(setq auto-mode-alist + (cons '("\\.out$" . irsim-mode) auto-mode-alist)) +(setq auto-mode-alist + (cons '("\\.flt$" . irsim-mode) auto-mode-alist)) \ No newline at end of file diff --git a/irsim-mode.el b/irsim-mode.el new file mode 100644 index 0000000..11a8646 --- /dev/null +++ b/irsim-mode.el @@ -0,0 +1,126 @@ +;;; A major mode for editing IRSIM netlists. Public domain. Created by +;;; Peter Scott in 2008. To install, put +;;; irsim-mode.el somewhere that emacs will see it like you site-lisp/ +;;; sirectory and stick something like this in your .emacs file: +;;; +;;; (autoload 'irsim-mode "irsim-mode" nil t) +;;; (setq auto-mode-alist +;;; (cons '("\\.sim$" . irsim-mode) auto-mode-alist)) +;;; +;;; Note that this will override the default behavior for opening .sim +;;; files, which is to go into simula-mode. This might be a problem if +;;; you use both. +;;; +;;; Note also that this mode is opinionated. It has a very specific +;;; idea of how IRSIM code ought to be indented, and if you don't like +;;; it then just set irsim-use-fancy-indent to nil. I think that the +;;; default indentation method leads to very pretty files and easy +;;; typing, but YMMV. + +(require 'font-lock) +(require 'cl) + +;; Customizable variables: +;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defvar irsim-use-fancy-indent t + "Specifies whether irsim-mode should use fancy indentation or + plain. Default is fancy, but set it to nil for plan.") + +(defvar irsim-tab-stops '(0 3 16 32 48 51) + "The starting column positions for each entry in a transistor + line using the fancy indent function. Change if you like.") + + +;; Some global variables + +(defvar irsim-mode-version "0.1" + "The current version number of irsim-mode.") + +(defvar irsim-mode-hook nil) + +(defconst irsim-font-lock-keywords + (list + '("^[\t ]*[np]" . font-lock-builtin-face) + '("[a-zA-Z_][_-a-zA-Z0-9.]*" . font-lock-variable-name-face)) + "Minimal highlighting expressions for IRSIM mode") + +;; Define comment behavior and make underscores act as normal +;; characters for forward-word and backward-word behavior. This makes +;; a lot more sense than the default. +(defvar irsim-mode-syntax-table + (let ((irsim-mode-syntax-table (make-syntax-table))) + (modify-syntax-entry ?| "< " irsim-mode-syntax-table) + (modify-syntax-entry ?\n "> " irsim-mode-syntax-table) + (modify-syntax-entry ?\^m "> " irsim-mode-syntax-table) + (modify-syntax-entry ?_ "w" irsim-mode-syntax-table) + irsim-mode-syntax-table)) + + +;; Indentation +;;;;;;;;;;;;;; + +(defun irsim-line-type () + "Returns the type of line in IRSIM code that the point is + on. Valid return values are 'transistor-line, 'comment-line, or + nil" + (save-excursion + (move-beginning-of-line nil) + (if (looking-at "^[\t ]*[np]") + 'transistor-line + (if (looking-at "^[\t ]*\\|") + 'comment-line)))) + +;; To indent a transistor line, just move the columns into place and +;; put the cursor at the last empty column. Or don't move it if there +;; are no more empty columns. Comment lines should not be indented. +(defun irsim-indent-line () + "Indent the current line of IRSIM code properly" + (interactive) + (let ((at-end nil)) + (if (looking-at "[\t ]*$") + (setq at-end t)) + (if (eql (irsim-line-type) 'transistor-line) + (progn + (save-excursion + (save-restriction + ;; Narrow to just this line + (narrow-to-region (line-beginning-position) (line-end-position)) + (beginning-of-line) + (indent-line-to 0) + (let ((tab-stops (copy-seq irsim-tab-stops))) + (while (and tab-stops (not (looking-at "[\t ]*$"))) + (while (looking-at "[\t ]") + (delete-char 1)) + (indent-to-column (car tab-stops)) + (setq tab-stops (cdr tab-stops)) + (forward-word)) + (when (and at-end tab-stops) + (message "yarr") + (end-of-line) + (indent-to-column (car tab-stops)))))) + (if at-end (end-of-line))) + (if (eql (irsim-line-type) 'comment-line) + (save-excursion + (beginning-of-line) + (indent-line-to 0)))))) + + + +(defun irsim-mode () + "Major mode for editing IRSIM netlists." + (interactive) + (kill-all-local-variables) + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults '(irsim-font-lock-keywords)) + (set-syntax-table irsim-mode-syntax-table) + (set (make-local-variable 'comment-start) "| ") + + (when irsim-use-fancy-indent + (set (make-local-variable 'indent-line-function) 'irsim-indent-line)) + + (setq mode-name "IRSIM" + major-mode 'irsim-mode) + (run-hooks 'irsim-mode-hook)) + +(provide 'irsim-mode) \ No newline at end of file