for the found string, or nil if none found." (let (start end) (while (and (not start) (re-search-forward "\\([\"']\\|/\\*\\|//\\)" nil t)) (cond ((= (preceding-char) ?*) ;; Disregard comments. (search-forward "*/")) ((= (preceding-char) ?/) ;; Disregard C++ comments. (end-of-line) (forward-char 1)) ((= (preceding-char) ?\') ;; Disregard character constants. (forward-char (if (= (following-char) ?\\) 3 2))) ((save-excursion (beginning-of-line) (looking-at "^# *\\(include\\|line\\)")) ;; Disregard lines being #include or #line directives. (end-of-line)) ;; Else, find the end of the (possibly concatenated) string. (t (setq start (1- (point)) end nil) (while (not end) (cond ((= (following-char) ?\") (if (looking-at "\"[ \t\n\\\\]*\"") (goto-char (match-end 0)) (forward-char 1) (setq end (point)))) ((= (following-char) ?\\) (forward-char 2)) (t (skip-chars-forward "^\"\\\\")))) ;; Check before string for keyword and opening parenthesis. (goto-char start) (skip-chars-backward " \n\t") (if (= (preceding-char) ?\() (progn (backward-char 1) (skip-chars-backward " \n\t") (let ((end-keyword (point))) (skip-chars-backward "_A-Za-z0-9") (if (member (list (buffer-substring-no-properties (point) end-keyword)) keywords) ;; Disregard already marked strings. (progn (goto-char end) (setq start nil end nil)) ;; String found. Prepare to resume search. (goto-char end)))) ;; String found. Prepare to resume search. (goto-char end))))) ;; Return the found string, if any. (and start end (list (po-extract-unquoted (current-buffer) start end) start end)))) (defun po-mark-c-string (start end keyword) "Mark the C string, from START to END, with KEYWORD. Leave point after marked string." (goto-char end) (insert ")") (save-excursion (goto-char start) (insert keyword) (or (string-equal keyword "_") (insert " ")) (insert "(")))