emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Desktop saves TAGS-LISP


From: Juri Linkov
Subject: Re: Desktop saves TAGS-LISP
Date: Wed, 19 Oct 2005 18:52:09 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

> It would be more reliable to identify tags tables through a method
> other than their file names.  Could you implement that?
>
> The clean way would be to create a major mode for tags tables,
> and make `initialize-new-tags-table' put the buffer in that mode.
> Then desktop could check for that mode.
>
> Alternatively it could check for a local binding of `tags-table-files'.

Perhaps in the long run a better way would be to read contents of
TAGS files into a special buffer with a leading space in its name,
thus hiding such buffers from many operations (e.g. from the buffer list).

But this may require considerable modifications in etags.el, so the
simplest fix is below.  The call to `initialize-new-tags-table' is placed
inside `tags-table-mode' for the case when desktop.el still saves TAGS
files in the desktop file (this may happen when .emacs overwrites
the default value of `desktop-modes-not-to-save' by removing
`tags-table-mode' from it).  The desktop file will store the major
mode for TAGS files as `tags-table-mode', so restoring the desktop
file will call `tags-table-mode' on saved TAGS files and thus
eventually will call `initialize-new-tags-table' on them.

The default value of `desktop-modes-not-to-save' is changed to contain
'(tags-table-mode), so normally TAGS files will not be saved in the
desktop file.

Index: lisp/progmodes/etags.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/etags.el,v
retrieving revision 1.190
diff -c -r1.190 etags.el
*** lisp/progmodes/etags.el     16 Oct 2005 09:31:44 -0000      1.190
--- lisp/progmodes/etags.el     19 Oct 2005 15:52:00 -0000
***************
*** 274,279 ****
--- 274,287 ----
    (run-hook-with-args-until-success 'tags-table-format-functions))
  
  ;;;###autoload
+ (defun tags-table-mode ()
+   "Major mode for tags table file buffers."
+   (interactive)
+   (setq major-mode 'tags-table-mode)
+   (setq mode-name "Tags Table")
+   (initialize-new-tags-table))
+ 
+ ;;;###autoload
  (defun visit-tags-table (file &optional local)
    "Tell tags commands to use tags table file FILE.
  FILE should be the name of a file created with the `etags' program.
***************
*** 415,421 ****
        ;; having changed since we last used it.
        (let (win)
        (set-buffer (get-file-buffer file))
!       (setq win (or verify-tags-table-function (initialize-new-tags-table)))
        (if (or (verify-visited-file-modtime (current-buffer))
                ;; Decide whether to revert the file.
                ;; revert-without-query can say to revert
--- 423,429 ----
        ;; having changed since we last used it.
        (let (win)
        (set-buffer (get-file-buffer file))
!       (setq win (or verify-tags-table-function (tags-table-mode)))
        (if (or (verify-visited-file-modtime (current-buffer))
                ;; Decide whether to revert the file.
                ;; revert-without-query can say to revert
***************
*** 434,440 ****
            (and verify-tags-table-function
                 (funcall verify-tags-table-function))
          (revert-buffer t t)
!         (initialize-new-tags-table)))
      (and (file-exists-p file)
         (progn
           (set-buffer (find-file-noselect file))
--- 442,448 ----
            (and verify-tags-table-function
                 (funcall verify-tags-table-function))
          (revert-buffer t t)
!         (tags-table-mode)))
      (and (file-exists-p file)
         (progn
           (set-buffer (find-file-noselect file))
***************
*** 446,452 ****
                     (setcar tail buffer-file-name))
                 (if (eq file tags-file-name)
                     (setq tags-file-name buffer-file-name))))
!          (initialize-new-tags-table)))))
  
  ;; Subroutine of visit-tags-table-buffer.  Search the current tags tables
  ;; for one that has tags for THIS-FILE (or that includes a table that
--- 454,460 ----
                     (setcar tail buffer-file-name))
                 (if (eq file tags-file-name)
                     (setq tags-file-name buffer-file-name))))
!          (tags-table-mode)))))
  
  ;; Subroutine of visit-tags-table-buffer.  Search the current tags tables
  ;; for one that has tags for THIS-FILE (or that includes a table that

Index: lisp/desktop.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/desktop.el,v
retrieving revision 1.94
diff -c -r1.94 desktop.el
*** lisp/desktop.el     12 Oct 2005 09:16:35 -0000      1.94
--- lisp/desktop.el     19 Oct 2005 15:51:23 -0000
***************
*** 293,301 ****
  
  ;; We skip .log files because they are normally temporary.
  ;;         (ftp) files because they require passwords and whatnot.
- ;;         TAGS files to save time (tags-file-name is saved instead).
  (defcustom desktop-buffers-not-to-save
!   "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
    "Regexp identifying buffers that are to be excluded from saving."
    :type 'regexp
    :group 'desktop)
--- 293,300 ----
  
  ;; We skip .log files because they are normally temporary.
  ;;         (ftp) files because they require passwords and whatnot.
  (defcustom desktop-buffers-not-to-save
!   "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\)$"
    "Regexp identifying buffers that are to be excluded from saving."
    :type 'regexp
    :group 'desktop)
***************
*** 307,313 ****
    :type 'regexp
    :group 'desktop)
  
! (defcustom desktop-modes-not-to-save nil
    "List of major modes whose buffers should not be saved."
    :type '(repeat symbol)
    :group 'desktop)
--- 306,314 ----
    :type 'regexp
    :group 'desktop)
  
! ;; We skip TAGS files to save time (tags-file-name is saved instead).
! (defcustom desktop-modes-not-to-save
!   '(tags-table-mode)
    "List of major modes whose buffers should not be saved."
    :type '(repeat symbol)
    :group 'desktop)

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]