Function: change-log-search-tag-name

change-log-search-tag-name is a byte-compiled function defined in add-log.el.gz.

Signature

(change-log-search-tag-name &optional AT)

Documentation

Search for a tag name near point.

Optional argument AT non-nil means search near buffer position AT. Return value is a cons whose car is the string representing the tag and whose cdr is the position where the tag was found.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/add-log.el.gz
(defun change-log-search-tag-name (&optional at)
  "Search for a tag name near `point'.
Optional argument AT non-nil means search near buffer position AT.
Return value is a cons whose car is the string representing
the tag and whose cdr is the position where the tag was found."
  (save-excursion
    (goto-char (setq at (or at (point))))
    (save-restriction
      (widen)
      (or (condition-case nil
	      ;; Within parenthesized list?
	      (save-excursion
		(backward-up-list)
		(when (looking-at change-log-tag-re)
		  (change-log-search-tag-name-1 at)))
	    (error nil))
	  (condition-case nil
	      ;; Before parenthesized list on same line?
	      (save-excursion
		(when (and (skip-chars-forward " \t")
			   (looking-at change-log-tag-re))
		  (change-log-search-tag-name-1)))
	    (error nil))
	  (condition-case nil
	      ;; Near file name?
	      (save-excursion
		(when (and (progn
			     (beginning-of-line)
			     (looking-at change-log-file-names-re))
			   (goto-char (match-end 0))
			   (skip-syntax-forward " ")
			   (looking-at change-log-tag-re))
		  (change-log-search-tag-name-1)))
	    (error nil))
	  (condition-case nil
	      ;; Anywhere else within current entry?
	      (let ((from
		     (save-excursion
		       (end-of-line)
		       (if (re-search-backward change-log-start-entry-re nil t)
			   (match-beginning 0)
			 (point-min))))
		    (to
		     (save-excursion
		       (end-of-line)
		       (if (re-search-forward change-log-start-entry-re nil t)
			   (match-beginning 0)
			 (point-max)))))
		(when (and (< from to) (<= from at) (<= at to))
		  (save-restriction
		    ;; Narrow to current change log entry.
		    (narrow-to-region from to)
		    (cond
		     ((re-search-backward change-log-tag-re nil t)
		      (narrow-to-region (match-beginning 1) (match-end 1))
		      (goto-char (point-max))
		      (cons (find-tag-default) (point-max)))
		     ((re-search-forward change-log-tag-re nil t)
		      (narrow-to-region (match-beginning 1) (match-end 1))
		      (goto-char (point-min))
		      (cons (find-tag-default) (point-min)))))))
	    (error nil))))))