1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-01 20:06:00 +00:00

Replace some inappropriate uses of toggle-read-only. (Bug#7292)

* lisp/speedbar.el (speedbar-mode):
* lisp/play/fortune.el (fortune-in-buffer, fortune):
* lisp/play/gomoku.el (gomoku-mode):
* lisp/play/landmark.el (lm-mode):
* lisp/textmodes/bibtex.el (bibtex-validate, bibtex-validate-globally):
* lisp/cedet/mode-local.el (mode-local-augment-function-help):
* lisp/semantic/analyze/debug.el (semantic-analyzer-debug-add-buttons):
* lisp/semantic/symref/list.el (semantic-symref-results-dump)
(semantic-symref-rb-toggle-expand-tag):
Replace inappropriate uses of toggle-read-only.
This commit is contained in:
Glenn Morris 2010-10-29 00:48:10 -07:00
parent 97af9a72d0
commit d2ce10d221
10 changed files with 158 additions and 180 deletions

View File

@ -1,3 +1,12 @@
2010-10-29 Glenn Morris <rgm@gnu.org>
* speedbar.el (speedbar-mode):
* play/fortune.el (fortune-in-buffer, fortune):
* play/gomoku.el (gomoku-mode):
* play/landmark.el (lm-mode):
* textmodes/bibtex.el (bibtex-validate, bibtex-validate-globally):
Replace inappropriate uses of toggle-read-only. (Bug#7292)
2010-10-28 Glenn Morris <rgm@gnu.org>
* select.el (x-selection): Mark it as an obsolete alias.

View File

@ -1,3 +1,11 @@
2010-10-29 Glenn Morris <rgm@gnu.org>
* mode-local.el (mode-local-augment-function-help):
* semantic/analyze/debug.el (semantic-analyzer-debug-add-buttons):
* semantic/symref/list.el (semantic-symref-results-dump)
(semantic-symref-rb-toggle-expand-tag): Replace inappropriate uses
of toggle-read-only.
2010-10-12 Juanma Barranquero <lekktu@gmail.com>
* semantic/symref/list.el (semantic-symref-list-rename-open-hits):

View File

@ -1,6 +1,7 @@
;;; mode-local.el --- Support for mode local facilities
;;
;; Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
;; Free Software Foundation, Inc.
;;
;; Author: David Ponce <david@dponce.com>
;; Maintainer: David Ponce <david@dponce.com>
@ -610,19 +611,16 @@ PROMPT, INITIAL, HIST, and DEFAULT are the same as for `completing-read'."
SYMBOL is a function that can be overridden."
(with-current-buffer "*Help*"
(pop-to-buffer (current-buffer))
(unwind-protect
(progn
(toggle-read-only -1)
(goto-char (point-min))
(unless (re-search-forward "^$" nil t)
(goto-char (point-max))
(beginning-of-line)
(forward-line -1))
(insert (overload-docstring-extension symbol) "\n")
;; NOTE TO SELF:
;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE
)
(toggle-read-only 1))))
(goto-char (point-min))
(unless (re-search-forward "^$" nil t)
(goto-char (point-max))
(beginning-of-line)
(forward-line -1))
(let ((inhibit-read-only t))
(insert (overload-docstring-extension symbol) "\n")
;; NOTE TO SELF:
;; LIST ALL LOADED OVERRIDES FOR SYMBOL HERE
)))
;; Help for mode-local bindings.
(defun mode-local-print-binding (symbol)
@ -782,5 +780,4 @@ invoked interactively."
(provide 'mode-local)
;; arch-tag: 14b77823-f93c-4b3d-9116-495f69a6ec07
;;; mode-local.el ends here

View File

@ -586,34 +586,28 @@ Look for key expressions, and add push-buttons near them."
(set-marker orig-buffer (point) (current-buffer))
;; Get a buffer ready.
(with-current-buffer "*Help*"
(toggle-read-only -1)
(goto-char (point-min))
(set (make-local-variable 'semantic-analyzer-debug-orig) orig-buffer)
;; First, add do-in buttons to recommendations.
(while (re-search-forward "^\\s-*M-x \\(\\(\\w\\|\\s_\\)+\\) " nil t)
(let ((fcn (match-string 1)))
(when (not (fboundp (intern-soft fcn)))
(error "Help Err: Can't find %s" fcn))
(end-of-line)
(insert " ")
(insert-button "[ Do It ]"
'mouse-face 'custom-button-pressed-face
'do-fcn fcn
'action `(lambda (arg)
(let ((M semantic-analyzer-debug-orig))
(set-buffer (marker-buffer M))
(goto-char M))
(call-interactively (quote ,(intern-soft fcn))))
)
))
(let ((inhibit-read-only t))
(goto-char (point-min))
(set (make-local-variable 'semantic-analyzer-debug-orig) orig-buffer)
;; First, add do-in buttons to recommendations.
(while (re-search-forward "^\\s-*M-x \\(\\(\\w\\|\\s_\\)+\\) " nil t)
(let ((fcn (match-string 1)))
(when (not (fboundp (intern-soft fcn)))
(error "Help Err: Can't find %s" fcn))
(end-of-line)
(insert " ")
(insert-button "[ Do It ]"
'mouse-face 'custom-button-pressed-face
'do-fcn fcn
'action `(lambda (arg)
(let ((M semantic-analyzer-debug-orig))
(set-buffer (marker-buffer M))
(goto-char M))
(call-interactively (quote ,(intern-soft fcn))))))))
;; Do something else?
;; Clean up the mess
(toggle-read-only 1)
(set-buffer-modified-p nil)
)))
(set-buffer-modified-p nil))))
(provide 'semantic/analyze/debug)
;; arch-tag: 943db1e5-47e6-4bec-9989-78ebfadf0358
;;; semantic/analyze/debug.el ends here

View File

@ -221,49 +221,38 @@ Some useful functions are found in `semantic-format-tag-functions'."
(defun semantic-symref-results-dump (results)
"Dump the RESULTS into the current buffer."
;; Get ready for the insert.
(toggle-read-only -1)
(erase-buffer)
;; Insert the contents.
(let ((lastfile nil)
)
(dolist (T (oref results :hit-tags))
(when (not (equal lastfile (semantic-tag-file-name T)))
(setq lastfile (semantic-tag-file-name T))
(insert-button lastfile
'mouse-face 'custom-button-pressed-face
'action 'semantic-symref-rb-goto-file
(let ((inhibit-read-only t))
(erase-buffer)
;; Insert the contents.
(let ((lastfile nil))
(dolist (T (oref results :hit-tags))
(unless (equal lastfile (semantic-tag-file-name T))
(setq lastfile (semantic-tag-file-name T))
(insert-button lastfile
'mouse-face 'custom-button-pressed-face
'action 'semantic-symref-rb-goto-file
'tag T)
(insert "\n"))
(insert " ")
(insert-button "[+]"
'mouse-face 'highlight
'face nil
'action 'semantic-symref-rb-toggle-expand-tag
'tag T
)
(insert "\n"))
(insert " ")
(insert-button "[+]"
'mouse-face 'highlight
'face nil
'action 'semantic-symref-rb-toggle-expand-tag
'tag T
'state 'closed)
(insert " ")
(insert-button (funcall semantic-symref-results-summary-function
T nil t)
'mouse-face 'custom-button-pressed-face
'face nil
'action 'semantic-symref-rb-goto-tag
'tag T)
(insert "\n")
))
;; Auto expand
(when semantic-symref-auto-expand-results
(semantic-symref-list-expand-all))
;; Clean up the mess
(toggle-read-only 1)
(set-buffer-modified-p nil)
)
'state 'closed)
(insert " ")
(insert-button (funcall semantic-symref-results-summary-function
T nil t)
'mouse-face 'custom-button-pressed-face
'face nil
'action 'semantic-symref-rb-goto-tag
'tag T)
(insert "\n")))
;; Auto expand
(when semantic-symref-auto-expand-results
(semantic-symref-list-expand-all)))
;; Clean up the mess
(set-buffer-modified-p nil))
;;; Commands for semantic-symref-results
;;
@ -283,11 +272,9 @@ BUTTON is the button that was clicked."
(buff (semantic-tag-buffer tag))
(hits (semantic--tag-get-property tag :hit))
(state (button-get button 'state))
(text nil)
)
(text nil))
(cond
((eq state 'closed)
(toggle-read-only -1)
(with-current-buffer buff
(dolist (H hits)
(goto-char (point-min))
@ -295,48 +282,42 @@ BUTTON is the button that was clicked."
(beginning-of-line)
(back-to-indentation)
(setq text (cons (buffer-substring (point) (point-at-eol)) text)))
(setq text (nreverse text))
)
(setq text (nreverse text)))
(goto-char (button-start button))
(forward-char 1)
(delete-char 1)
(insert "-")
(button-put button 'state 'open)
(save-excursion
(end-of-line)
(while text
(insert "\n")
(insert " ")
(insert-button (car text)
'mouse-face 'highlight
'face nil
'action 'semantic-symref-rb-goto-match
'tag tag
'line (car hits))
(setq text (cdr text)
hits (cdr hits))))
(toggle-read-only 1)
)
(let ((inhibit-read-only t))
(delete-char 1)
(insert "-")
(button-put button 'state 'open)
(save-excursion
(end-of-line)
(while text
(insert "\n")
(insert " ")
(insert-button (car text)
'mouse-face 'highlight
'face nil
'action 'semantic-symref-rb-goto-match
'tag tag
'line (car hits))
(setq text (cdr text)
hits (cdr hits))))))
((eq state 'open)
(toggle-read-only -1)
(button-put button 'state 'closed)
;; Delete the various bits.
(goto-char (button-start button))
(forward-char 1)
(delete-char 1)
(insert "+")
(save-excursion
(end-of-line)
(let ((inhibit-read-only t))
(button-put button 'state 'closed)
;; Delete the various bits.
(goto-char (button-start button))
(forward-char 1)
(delete-region (point)
(save-excursion
(forward-char 1)
(forward-line (length hits))
(point))))
(toggle-read-only 1)
)
))
)
(delete-char 1)
(insert "+")
(save-excursion
(end-of-line)
(forward-char 1)
(delete-region (point)
(save-excursion
(forward-char 1)
(forward-line (length hits))
(point)))))))))
(defun semantic-symref-rb-goto-file (&optional button)
"Go to the file specified in the symref results buffer.
@ -554,5 +535,4 @@ Return the number of occurrences FUNCTION was operated upon."
;; generated-autoload-load-name: "semantic/symref/list"
;; End:
;; arch-tag: e355d9c6-26e0-42d1-9bf1-f4801a54fffa
;;; semantic/symref/list.el ends here

View File

@ -1,7 +1,7 @@
;;; fortune.el --- use fortune to create signatures
;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
;; 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
;; 2009, 2010 Free Software Foundation, Inc.
;; Author: Holger Schauer <Holger.Schauer@gmx.de>
;; Keywords: games utils mail
@ -285,48 +285,41 @@ and choose the directory as the fortune-file."
;;; Display fortune
(defun fortune-in-buffer (interactive &optional file)
"Put a fortune cookie in the *fortune* buffer.
INTERACTIVE is ignored. Optional argument FILE,
when supplied, specifies the file to choose the fortune from."
INTERACTIVE is ignored. Optional argument FILE, when supplied,
specifies the file to choose the fortune from."
(let ((fortune-buffer (or (get-buffer fortune-buffer-name)
(generate-new-buffer fortune-buffer-name)))
(fort-file (expand-file-name
(substitute-in-file-name
(or file fortune-file)))))
(with-current-buffer fortune-buffer
(toggle-read-only 0)
(erase-buffer)
(if fortune-always-compile
(fortune-compile fort-file))
(apply 'call-process
fortune-program ; program to call
nil fortune-buffer nil ; INFILE BUFFER DISPLAY
(append (if (stringp fortune-program-options)
(split-string fortune-program-options)
fortune-program-options) (list fort-file))))))
(let ((inhibit-read-only t))
(erase-buffer)
(if fortune-always-compile
(fortune-compile fort-file))
(apply 'call-process
fortune-program ; program to call
nil fortune-buffer nil ; INFILE BUFFER DISPLAY
(append (if (stringp fortune-program-options)
(split-string fortune-program-options)
fortune-program-options) (list fort-file)))))))
;;;###autoload
(defun fortune (&optional file)
"Display a fortune cookie.
If called with a prefix asks for the FILE to choose the fortune from,
otherwise uses the value of `fortune-file'. If you want to have fortune
choose from a set of files in a directory, call interactively with prefix
and choose the directory as the fortune-file."
(interactive
(list
(if current-prefix-arg
(fortune-ask-file)
fortune-file)))
(interactive (list (if current-prefix-arg
(fortune-ask-file)
fortune-file)))
(fortune-in-buffer t file)
(switch-to-buffer (get-buffer fortune-buffer-name))
(toggle-read-only 1))
(setq buffer-read-only t))
;;; Provide ourselves.
(provide 'fortune)
;; arch-tag: a1e4cb8a-3792-40e7-86a7-fc75ce094bcc
;;; fortune.el ends here

View File

@ -1,7 +1,7 @@
;;; gomoku.el --- Gomoku game between you and Emacs
;; Copyright (C) 1988, 1994, 1996, 2001, 2002, 2003, 2004,
;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Copyright (C) 1988, 1994, 1996, 2001, 2002, 2003, 2004, 2005, 2006,
;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Philippe Schnoebelen <phs@lsv.ens-cachan.fr>
;; Maintainer: FSF
@ -201,8 +201,8 @@ is non-nil."
(gomoku-display-statistics)
(use-local-map gomoku-mode-map)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(gomoku-font-lock-keywords t))
(toggle-read-only t)
(setq font-lock-defaults '(gomoku-font-lock-keywords t)
buffer-read-only t)
(run-mode-hooks 'gomoku-mode-hook))
;;;
@ -1213,5 +1213,4 @@ If the game is finished, this command requests for another game."
(provide 'gomoku)
;; arch-tag: b1b8205e-77fc-4597-b373-3ea2c04311eb
;;; gomoku.el ends here

View File

@ -255,8 +255,8 @@ is non-nil. One interesting value is `turn-on-font-lock'."
(lm-display-statistics)
(use-local-map lm-mode-map)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(lm-font-lock-keywords t))
(toggle-read-only t)
(setq font-lock-defaults '(lm-font-lock-keywords t)
buffer-read-only t)
(run-mode-hooks 'lm-mode-hook))
@ -1700,5 +1700,4 @@ Use \\[describe-mode] for more info."
(provide 'landmark)
;; arch-tag: ae5031be-96e6-459e-a3df-1df53117d3f2
;;; landmark.el ends here

View File

@ -1,7 +1,8 @@
;;; speedbar --- quick access to files and tags in a frame
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; 2005, 2006, 2007, 2008, 2009, 2010
;; Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: file, tags, tools
@ -1128,9 +1129,9 @@ in the selected file.
(setq font-lock-keywords nil) ;; no font-locking please
(setq truncate-lines t)
(make-local-variable 'frame-title-format)
(setq frame-title-format (concat "Speedbar " speedbar-version))
(setq case-fold-search nil)
(toggle-read-only 1)
(setq frame-title-format (concat "Speedbar " speedbar-version)
case-fold-search nil
buffer-read-only t)
(speedbar-set-mode-line-format)
;; Add in our dframe hooks.
(if speedbar-track-mouse-flag
@ -4142,5 +4143,4 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
;; run load-time hooks
(run-hooks 'speedbar-load-hook)
;; arch-tag: 4477e6d1-f78c-48b9-a503-387d3c9767d5
;;; speedbar ends here

View File

@ -1,7 +1,8 @@
;;; bibtex.el --- BibTeX mode for GNU Emacs
;; Copyright (C) 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
;; Free Software Foundation, Inc.
;; Author: Stefan Schoef <schoef@offis.uni-oldenburg.de>
;; Bengt Martensson <bengt@mathematik.uni-Bremen.de>
@ -3833,16 +3834,16 @@ Return t if test was successful, nil otherwise."
(with-current-buffer (get-buffer-create err-buf)
(setq default-directory dir)
(unless (eq major-mode 'compilation-mode) (compilation-mode))
(toggle-read-only -1)
(delete-region (point-min) (point-max))
(insert "BibTeX mode command `bibtex-validate'\n"
(if syntax-error
"Maybe undetected errors due to syntax errors. Correct and validate again.\n"
"\n"))
(dolist (err error-list)
(insert (format "%s:%d: %s\n" file (car err) (cdr err))))
(set-buffer-modified-p nil)
(toggle-read-only 1)
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
(insert "BibTeX mode command `bibtex-validate'\n"
(if syntax-error
"Maybe undetected errors due to syntax errors. \
Correct and validate again.\n"
"\n"))
(dolist (err error-list)
(insert (format "%s:%d: %s\n" file (car err) (cdr err))))
(set-buffer-modified-p nil))
(goto-char (point-min))
(forward-line 2)) ; first error message
(display-buffer err-buf)
@ -3894,12 +3895,11 @@ Return t if test was successful, nil otherwise."
(let ((err-buf "*BibTeX validation errors*"))
(with-current-buffer (get-buffer-create err-buf)
(unless (eq major-mode 'compilation-mode) (compilation-mode))
(toggle-read-only -1)
(delete-region (point-min) (point-max))
(insert "BibTeX mode command `bibtex-validate-globally'\n\n")
(dolist (err (sort error-list 'string-lessp)) (insert err))
(set-buffer-modified-p nil)
(toggle-read-only 1)
(let ((inhibit-read-only t))
(delete-region (point-min) (point-max))
(insert "BibTeX mode command `bibtex-validate-globally'\n\n")
(dolist (err (sort error-list 'string-lessp)) (insert err))
(set-buffer-modified-p nil))
(goto-char (point-min))
(forward-line 2)) ; first error message
(display-buffer err-buf)
@ -4776,5 +4776,4 @@ Return the URL or nil if none can be generated."
(provide 'bibtex)
;; arch-tag: ee2be3af-caad-427f-b42a-d20fad630d04
;;; bibtex.el ends here