]> code.delx.au - gnu-emacs/blobdiff - lisp/add-log.el
(set-selection-coding-system): Make it
[gnu-emacs] / lisp / add-log.el
index d671cbf8854b2b29a1a59fb85f260aab0b83b4e2..287ff094ae88fc25d7e1344e477dfa6acc9dd02e 100644 (file)
@@ -151,6 +151,8 @@ this variable."
 It takes the same format as the TZ argument of `set-time-zone-rule'.
 If nil, use local time.")
 
+(defvar add-log-debugging)
+
 (defun add-log-iso8601-time-zone (time)
   (let* ((utc-offset (or (car (current-time-zone time)) 0))
         (sign (if (< utc-offset 0) ?- ?+))
@@ -305,6 +307,8 @@ non-nil, otherwise in local time."
                         (substring buffer-file-name (match-end 0))
                       (file-name-nondirectory buffer-file-name))))
 
+    (let ((buffer (find-buffer-visiting file-name)))
+      (setq add-log-debugging (list (gap-position) (gap-size))))
     (if (and other-window (not (equal file-name buffer-file-name)))
        (find-file-other-window file-name)
       (find-file file-name))
@@ -487,18 +491,22 @@ Has a preference of looking backwards."
                 (or (eobp) (forward-char 1))
                 (beginning-of-defun)
                 ;; Make sure we are really inside the defun found, not after it.
-                (if (and (looking-at "\\s(")
-                         (progn (end-of-defun)
-                                (< location (point)))
-                         (progn (forward-sexp -1)
-                                (>= location (point))))
-                    (progn
-                      (if (looking-at "\\s(")
-                          (forward-char 1))
-                      (forward-sexp 1)
-                      (skip-chars-forward " '")
-                      (buffer-substring (point)
-                                        (progn (forward-sexp 1) (point))))))
+                (when (and (looking-at "\\s(")
+                           (progn (end-of-defun)
+                                  (< location (point)))
+                           (progn (forward-sexp -1)
+                                  (>= location (point))))
+                  (if (looking-at "\\s(")
+                      (forward-char 1))
+                  ;; Skip the defining construct name, typically "defun"
+                  ;; or "defvar".
+                  (forward-sexp 1)
+                  ;; The second element is usually a symbol being defined.
+                  ;; If it is not, use the first symbol in it.
+                  (skip-chars-forward " \t\n'(")
+                  (buffer-substring (point)
+                                    (progn (forward-sexp 1)
+                                           (point)))))
                ((and (memq major-mode add-log-c-like-modes)
                      (save-excursion
                        (beginning-of-line)
@@ -636,20 +644,20 @@ Has a preference of looking backwards."
                  (let ((case-fold-search t)) ; case-insensitive
                    ;; search for fortran subprogram start
                    (if (re-search-forward
-                        "^[ \t]*\\(program\\|subroutine\\|function\
+                        "^[ \t]*\\(program\\|subroutine\\|function\
 \\|[ \ta-z0-9*()]*[ \t]+function\\|\\(block[ \t]*data\\)\\)"
-                        (progn (end-of-fortran-subprogram)
-                               (point))
-                        t)
+                        (save-excursion (end-of-fortran-subprogram)
+                                        (point))
+                        t)
                        (or (match-string 2)
-                       (progn
-                         ;; move to EOL or before first left paren
-                         (if (re-search-forward "[(\n]" nil t)
+                           (progn
+                             ;; move to EOL or before first left paren
+                             (if (re-search-forward "[(\n]" nil t)
                                 (progn (backward-char)
-                                   (skip-chars-backward " \t"))
-                          (end-of-line))
-                        ;; Use the name preceding that.
-                         (buffer-substring (point)
+                                        (skip-chars-backward " \t"))
+                               (end-of-line))
+                             ;; Use the name preceding that.
+                             (buffer-substring (point)
                                               (progn (backward-sexp)
                                                      (point)))))
                     "main")))