help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can one modify a variable definition in a major mode depending on bu


From: Emanuel Berg
Subject: Re: Can one modify a variable definition in a major mode depending on buffer name?
Date: Sat, 30 Jul 2016 16:26:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Tom Browder wrote:

> I think I can do that, with some
> experimentation, but can anyone confirm that
> it's reasonably possible?

;;; Perl
(defvar perl-propaganda)
(setq perl-propaganda "There's more than one way to do it!")

;; (setq perl-mode-hook nil)
(defun perl-mode-hook-f ()
  (let*((filename       (buffer-name))
        (filename-parts (split-string filename "\\."))
        (extention      (cadr filename-parts) ))
    (when (string-equal extention "nqp")
      (setq-local perl-propaganda "Do it today, in a different way!") )))
(add-hook 'perl-mode-hook #'perl-mode-hook-f)

(let ((modes (list
     '("\\.nqp\\'" . perl-mode)
     '("\\.tex\\'" . latex-mode)
     '("\\.php\\'" . html-mode)
     ;; etc.
    )))
  (setf auto-mode-alist (nconc modes auto-mode-alist)) )

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 64 Blogomatic articles -                   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]