restore asm extension associations

Ed L Cashin ecashin at uga.edu
Mon Mar 1 02:08:20 CET 2004


Hi.  I'm an ESS user who uses R but not S and who visits many
assembler files.

I noticed comments in ess-site.el about the issue of .s and .S files
conflicting with S files:

;; This fails in Emacs.  How can it be done simply?  Should it be
;; done?  It works in XEmacs.
;;    ;; get rid of assembler mode.
;;    (set auto-mode-alist (remassoc "\\.[sS]\\'" auto-mode-alist))
;; Our current solution is as follows.


I put the following code in my .emacs file to get back assembler mode
for asm files.  


(progn					; setup for ESS
  ;; remassoc exists as a built-in function in xemacs, but
  ;; not in GNU emacs
  ;;
  (if (not (functionp 'remassoc))
      (defun remassoc (key a)     
	"remove an association pair from an alist"
	(if a
	    (let ((pair (car a)))
	      (if (equal (car pair) key)
		  (cdr a)
		  (cons pair (remassoc key (cdr a))))))))

  (defun un-annex-asm-extns ()
    "take away the association for .s and .S files added by ESS"
    (if (assoc "\\.[qsS]\\'" auto-mode-alist)
	(progn
	  (setq auto-mode-alist
		(remassoc "\\.[qsS]\\'" auto-mode-alist))
	  ;; put .q extention back
	  (add-to-list 'auto-mode-alist '("\\.q\\'" . S-mode)))))

  ;; doesn't work ;; (add-hook 'ess-mode-load-hook 'un-annex-asm-extns)
  (add-hook 'ess-mode-hook 'un-annex-asm-extns)
  (add-hook 'inferior-ess-mode-hook 'un-annex-asm-extns))


This may already exist somewhere that other newbies will find it, or
it may already be obsolete in the latest ESS.  Otherwise, perhaps it
could serve as the basis for an ess function with a name like
"ess-restore-asm-associations", along with documentation showing how
to add the necessary hooks in .emacs.

-- 
--Ed L Cashin            |   PGP public key:
  ecashin at uga.edu        |   http://noserose.net/e/pgp/




More information about the ESS-help mailing list