From bfa8cc602b3eeb2f7a81f97f9027548f5b34fa34 Mon Sep 17 00:00:00 2001 From: William Xu Date: Tue, 1 Apr 2008 15:46:00 +0000 Subject: [PATCH] *** empty log message *** darcs-hash:20080401154630-cfa61-197994c1eea4633116ee41304e05e5ded7b9018d.gz --- smart-operator.el | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/smart-operator.el b/smart-operator.el index 3239e97..7f23356 100644 --- a/smart-operator.el +++ b/smart-operator.el @@ -48,6 +48,10 @@ ;; reimplementing as a minor mode and providing an initial patch for ;; that. +;;; TODO: + +;; - for c mode, probaly it would be much better doing this in cc-mode. + ;;; Code: ;;; smart-operator minor mode @@ -118,13 +122,15 @@ When ONLY-AFTER, insert space at back only." (defun smart-operator-< () "See `smart-operator-insert'." (interactive) - (cond ((and (memq major-mode '(c-mode c++-mode)) + (cond ((and (memq major-mode '(c-mode c++-mode objc-mode)) (looking-back (concat "\\(" (regexp-opt - '("#include" "vector" "deque" "list" "map" - "multimap" "set" "hash_map" "iterator" "template" - "pair" "auto_ptr")) + (append + '("#include" "vector" "deque" "list" "map" + "multimap" "set" "hash_map" "iterator" "template" + "pair" "auto_ptr") + '("#import"))) "\\)\\ *") (smart-operator-bol))) (insert "<>") @@ -140,7 +146,7 @@ When ONLY-AFTER, insert space at back only." (interactive) (cond ((memq major-mode '(c-mode c++-mode)) (if (looking-back "\\?.+" (smart-operator-bol)) - (smart-operator-c-mode-:) + (smart-operator-insert ":") (insert ":"))) (t (smart-operator-insert ":" t)))) @@ -165,21 +171,18 @@ When ONLY-AFTER, insert space at back only." "See `smart-operator-insert'." (interactive) (cond ((memq major-mode '(c-mode c++-mode)) - (if (or (looking-back " " (1- (point))) - (bolp)) - (insert "&") - (smart-operator-insert "&"))) + (insert "&")) (t (smart-operator-insert "&")))) (defun smart-operator-* () "See `smart-operator-insert'." (interactive) - (cond ((memq major-mode '(c-mode c++-mode)) - (if (or (looking-back "[0-9a-zA-Z]" (1- (point))) - (bolp)) - (smart-operator-insert "*") - (insert "*"))) + (cond ((memq major-mode '(c-mode c++-mode objc-mode)) +;; (if (or (looking-back "[0-9a-zA-Z]" (1- (point))) +;; (bolp)) +;; (smart-operator-insert "*") + (insert "*")) (t (smart-operator-insert "*")))) @@ -228,9 +231,7 @@ When ONLY-AFTER, insert space at back only." (defun smart-operator-% () "See `smart-operator-insert'." (interactive) - (cond ((and (memq major-mode '(c-mode c++-mode)) - (looking-back "\"" (smart-operator-bol)) - (not (looking-back "\".*\"" (smart-operator-bol)))) + (cond ((and (memq major-mode '(c-mode c++-mode objc-mode))) (insert "%")) (t (smart-operator-insert "%")))) -- 2.11.4.GIT