emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/last-cedet-merge 783fb86 09/11: semantic: Add 'fro


From: David Engster
Subject: [Emacs-diffs] scratch/last-cedet-merge 783fb86 09/11: semantic: Add 'fromfile' option to grammar package
Date: Mon, 23 Jan 2017 21:13:49 +0000 (UTC)

branch: scratch/last-cedet-merge
commit 783fb86bb8e79895f256c8208816baac280f2966
Author: Eric Ludlam <address@hidden>
Commit: David Engster <address@hidden>

    semantic: Add 'fromfile' option to grammar package
    
    * lisp/cedet/semantic/grammar.el (semantic-grammar-package): Add
      optional 'fromfile' option. This indicates we want to make a
      filename from the originating file name.
---
 lisp/cedet/semantic/grammar.el |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index e71832f..5cd4932 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -266,17 +266,19 @@ That is tag names plus names defined in tag attribute 
`:rest'."
 No argument or nil as argument means use the current buffer."
   (file-name-nondirectory (buffer-file-name buffer)))
 
-(defun semantic-grammar-package ()
+(defun semantic-grammar-package (&optional fromfile)
   "Return the %package value as a string.
-If there is no %package statement in the grammar, return a default
-package name derived from the grammar file name.  For example, the
-default package name for the grammar file foo.wy is foo-wy, and for
-foo.by it is foo-by."
-  (or (semantic-grammar-first-tag-name 'package)
+If there is no %package statement in the grammar, or if FROMFILE
+is non-nil, return a default package name derived from the
+grammar file name.  For example, the default package name for the
+grammar file foo.wy is foo-wy, and for foo.by it is foo-by."
+  (let ((pkgtoken (semantic-grammar-first-tag-name 'package)))
+    (if (and (not fromfile) pkgtoken)
+       pkgtoken
       (let* ((file (semantic-grammar-buffer-file))
              (ext  (file-name-extension file))
              (i    (string-match (format "\\([.]\\)%s\\'" ext) file)))
-        (concat (substring file 0 i) "-" ext))))
+        (concat (substring file 0 i) "-" ext)))))
 
 (defsubst semantic-grammar-languagemode ()
   "Return the %languagemode value as a list of symbols or nil."



reply via email to

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