Opening a header file in Emacs

August 20th, 2007 Leave a comment Go to comments

I use the following function from the "find-file-hook" in order to choose between using objc-mode, c++-mode and c-mode when opening a ".h" file:

 
(defun bh-choose-header-mode ()
  (interactive)
  (if (string-equal (substring (buffer-file-name) -2) ".h")
      (progn
        ;; OK, we got a .h file, if a .m file exists we'll assume it's
        ; an objective c file. Otherwise, we'll look for a .cpp file.
        (let ((dot-m-file (concat (substring (buffer-file-name) 0 -1) "m"))
              (dot-cpp-file (concat (substring (buffer-file-name) 0 -1) "cpp")))
          (if (file-exists-p dot-m-file)
              (progn
                (objc-mode)
                )
            (if (file-exists-p dot-cpp-file)
                (c++-mode)
              )
            )
          )
        )
    )
  )
 
(add-hook 'find-file-hook 'bh-choose-header-mode)
 
  1. January 14th, 2010 at 08:00 | #1
  2. January 18th, 2010 at 23:04 | #2

    4JjA5E stpzoikypafz, [url=http://aovcbhlvayza.com/]aovcbhlvayza[/url], [link=http://suyglcxlnqhj.com/]suyglcxlnqhj[/link], http://basgsdgtfhrv.com/

  3. January 19th, 2010 at 00:15 | #3

    aTm7Zv ugeajnxobhgu, [url=http://dlwjvxmxwmdf.com/]dlwjvxmxwmdf[/url], [link=http://hfpqlscczoqa.com/]hfpqlscczoqa[/link], http://shtykqacttdx.com/

  4. January 28th, 2010 at 15:05 | #4

    for all of buy cialis Harrison – SSR 6 – A Stainless Steel Rat Is BornUC

  5. February 4th, 2010 at 15:30 | #5

    least orbital indicates arrives generation time [url=http://www.aqmd.gov]temperatures web[/url] http://www.climatescience.gov

  6. February 8th, 2010 at 09:00 | #6

    Eloppella
    yfof

  1. No trackbacks yet.
Security Code: