summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@lysator.liu.se>2003-07-16 20:55:10 +0000
committerMartin Stjernholm <mast@lysator.liu.se>2003-07-16 20:55:10 +0000
commit71b3429e205322089349cf5a5e4c6986905c0f3b (patch)
tree29fa7547afffb777eb12ec3cfcccf4b65af9af3d /lisp/progmodes
parent5e536b9188bf9d2a0535d51a8fb33cd5fdc1c6f4 (diff)
downloademacs-71b3429e205322089349cf5a5e4c6986905c0f3b.tar.gz
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
functions for syntactic elements.
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-defs.el62
1 files changed, 50 insertions, 12 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 132019618c6..afe0ac0053a 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -105,7 +105,7 @@
;;; Variables also used at compile time.
-(defconst c-version "5.30.3"
+(defconst c-version "5.30.4"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
@@ -864,19 +864,57 @@ This function does not do any hidden buffer changes."
;; This function does not do any hidden buffer changes.
(assq (car (c-intersect-lists list alist1)) alist2))
-(defsubst c-langelem-col (langelem &optional preserve-point)
- "Convenience routine to return the column of LANGELEM's relpos.
-Leaves point at the relpos unless PRESERVE-POINT is non-nil.
+(defsubst c-langelem-sym (langelem)
+ "Return the syntactic symbol in LANGELEM.
+
+LANGELEM is a syntactic element, i.e. either a cons cell on the
+\"old\" form given as the first argument to lineup functions or a list
+on the \"new\" form as used in `c-syntactic-element'.
+
+This function does not do any hidden buffer changes."
+ (car langelem))
+
+(defsubst c-langelem-pos (langelem)
+ "Return the (primary) anchor position in LANGELEM, or nil if there is none.
+
+LANGELEM is a syntactic element, i.e. either a cons cell on the
+\"old\" form given as the first argument to lineup functions or a list
+on the \"new\" form as used in `c-syntactic-element'.
+
+This function does not do any hidden buffer changes."
+ (if (consp (cdr langelem))
+ (car-safe (cdr langelem))
+ (cdr langelem)))
+
+(defun c-langelem-col (langelem &optional preserve-point)
+ "Return the column of the (primary) anchor position in LANGELEM.
+Leave point at that position unless PRESERVE-POINT is non-nil.
+
+LANGELEM is a syntactic element, i.e. either a cons cell on the
+\"old\" form given as the first argument to lineup functions or a list
+on the \"new\" form as used in `c-syntactic-element'.
+
+This function does not do any hidden buffer changes."
+ (let ((pos (c-langelem-pos langelem))
+ (here (point)))
+ (if pos
+ (progn
+ (goto-char pos)
+ (prog1 (current-column)
+ (if preserve-point
+ (goto-char here))))
+ 0)))
+
+(defsubst c-langelem-2nd-pos (langelem)
+ "Return the secondary position in LANGELEM, or nil if there is none.
+
+LANGELEM is a syntactic element, typically on the \"new\" form as used
+in `c-syntactic-element'. It may be on the \"old\" form that is used
+as the first argument to lineup functions, but then the returned value
+always will be nil.
This function does not do any hidden buffer changes."
- (if (cdr langelem)
- (let ((here (point)))
- (goto-char (cdr langelem))
- (prog1 (current-column)
- (if preserve-point
- (goto-char here))
- ))
- 0))
+ (car-safe (cdr-safe (cdr-safe langelem))))
(defsubst c-keep-region-active ()
;; Do whatever is necessary to keep the region active in XEmacs.