* cmake emacs mode @ 2006-04-26 2:31 William A. Hoffman 2006-04-26 15:17 ` Stuart D. Herring 0 siblings, 1 reply; 3+ messages in thread From: William A. Hoffman @ 2006-04-26 2:31 UTC (permalink / raw) Hi, I need some help with an emacs mode for cmake: www.cmake.org. The mode file we have is here: http://www.cmake.org/CMakeDocs/cmake-mode.el The file has the following problem: ; TODO: If anyone knows how to match function names occurring before an ; open-paren and highlight them without also highlighting the ; open-paren, please contact cmake@cmake.org or kitware@kitware.com ; and tell us how to do it. We would rather not have to include the ; entire list of CMake commands in this mode file, which is a pain to ; maintain. Thanks. Any ideas? Thanks. -Bill ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cmake emacs mode 2006-04-26 2:31 cmake emacs mode William A. Hoffman @ 2006-04-26 15:17 ` Stuart D. Herring 2006-04-26 21:01 ` Miles Bader 0 siblings, 1 reply; 3+ messages in thread From: Stuart D. Herring @ 2006-04-26 15:17 UTC (permalink / raw) Cc: cmake, emacs-devel > ; TODO: If anyone knows how to match function names occurring before an > ; open-paren and highlight them without also highlighting the > ; open-paren, please contact cmake@cmake.org or kitware@kitware.com > ; and tell us how to do it. We would rather not have to include the > ; entire list of CMake commands in this mode file, which is a pain to > ; maintain. Thanks. There's several things here. First, there's no reason you have to go through the *scratch* nonsense. Just put the big commented-out `regexp-opt' call into the `defvar': (defconst cmake-font-lock-defaults (list (cons (regexp-opt '("foo" "bar") 'words) 'font-lock-function-name-face)) "Highlighting expressions for CMAKE mode.") You then don't have to have the 3k output in the file, just the code in the comment. I also note that there's a syntax error that makes the doc string actually be a part of the (list) form. If you want to not force the load of regexp-opt, you can use `eval-when-compile'; see regexp-opt.el for info. Moreover, later you do (setq font-lock-defaults '(cmake-font-lock-defaults)) ...which suggests to me that the variable should in fact be called `cmake-font-lock-keywords' or so, not `...-defaults'. Now, if you'd really rather get rid of the list altogether, as the comment suggests, then you can use this as an element of the keywords list: ("\\(\\w+\\)(" 1 font-lock-function-name-face) The trick is that the 1 says to highlight the first captured expression, rather than the whole match, and the group doesn't contain the `('. Moreover, this mode (aside from the indenting) looks to be extremely simple; you might be able to get away with making it a derived major mode (from Fundamental mode, probably; see `define-derived-mode') or even a generic mode (see `define-generic-mode'). Might make it less trouble to keep up with. Hope it helps, Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cmake emacs mode 2006-04-26 15:17 ` Stuart D. Herring @ 2006-04-26 21:01 ` Miles Bader 0 siblings, 0 replies; 3+ messages in thread From: Miles Bader @ 2006-04-26 21:01 UTC (permalink / raw) Cc: cmake, William A. Hoffman, emacs-devel "Stuart D. Herring" <herring@lanl.gov> writes: > Moreover, this mode (aside from the indenting) looks to be extremely > simple; you might be able to get away with making it a derived major mode > (from Fundamental mode, probably; see `define-derived-mode') or even a > generic mode (see `define-generic-mode'). Might make it less trouble to > keep up with. Yeah, I've found `define-generic-mode' to be very helpful for my own language modes: it makes font-locking and basic mode definition details almost trivial, and usually doesn't get in the way of adding additional functionality. I think it really deserves more attention than it seems to get (is d-g-m more or less compatible between Emacs 21 and 22?). [Now if only there was a similarly easy way to define an indentation engine... :-] -Miles -- Saa, shall we dance? (from a dance-class advertisement) ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-26 21:01 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-04-26 2:31 cmake emacs mode William A. Hoffman 2006-04-26 15:17 ` Stuart D. Herring 2006-04-26 21:01 ` Miles Bader
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).