Skip to content

Commit

Permalink
Patch pabbrev to inhibit read only
Browse files Browse the repository at this point in the history
  • Loading branch information
jwiegley committed Nov 29, 2012
1 parent 21d5577 commit 62569e8
Showing 1 changed file with 45 additions and 42 deletions.
87 changes: 45 additions & 42 deletions site-lisp/pabbrev.el
Expand Up @@ -1306,15 +1306,16 @@ self inserting commands."
(defun pabbrev-scavenge-some() (defun pabbrev-scavenge-some()
"Gather some words up from around point" "Gather some words up from around point"
(interactive) (interactive)
(save-excursion (let ((inhibit-read-only t))
;; move somewhat away from point, as this is likely to not contain
;; complete words.
(pabbrev-forward-thing -2)
(pabbrev-scavenge-words -1
(* 2 pabbrev-scavenge-some-chunk-size))
(save-excursion (save-excursion
(pabbrev-forward-thing 2) ;; move somewhat away from point, as this is likely to not contain
(pabbrev-scavenge-words 1 pabbrev-scavenge-some-chunk-size)))) ;; complete words.
(pabbrev-forward-thing -2)
(pabbrev-scavenge-words -1
(* 2 pabbrev-scavenge-some-chunk-size))
(save-excursion
(pabbrev-forward-thing 2)
(pabbrev-scavenge-words 1 pabbrev-scavenge-some-chunk-size)))))


(defun pabbrev-scavenge-region() (defun pabbrev-scavenge-region()
(interactive) (interactive)
Expand All @@ -1325,48 +1326,50 @@ self inserting commands."
(defun pabbrev-scavenge-buffer-fast() (defun pabbrev-scavenge-buffer-fast()
(interactive) (interactive)
(message "pabbrev fast scavenging buffer...") (message "pabbrev fast scavenging buffer...")
(save-excursion (let ((inhibit-read-only t))
(goto-char (point-min)) (save-excursion
(while (pabbrev-forward-thing) (goto-char (point-min))
(while (pabbrev-forward-thing)


(let* ((bounds (pabbrev-bounds-of-thing-at-point)) (let* ((bounds (pabbrev-bounds-of-thing-at-point))
(start (car bounds)) (start (car bounds))
(stop (cdr bounds))) (stop (cdr bounds)))
(unless (unless
(pabbrev-bounds-marked-p start stop) (pabbrev-bounds-marked-p start stop)
(pabbrev-add-word (pabbrev-add-word
(buffer-substring-no-properties start stop))))) (buffer-substring-no-properties start stop)))))


(pabbrev-debug-message "Dictionary size %s total usage %s" (pabbrev-debug-message "Dictionary size %s total usage %s"
(pabbrev-get-usage-dictionary-size)) (pabbrev-get-usage-dictionary-size))
(pabbrev-save-buffer-modified-p (pabbrev-save-buffer-modified-p
(add-text-properties (point-min) (point-max) (add-text-properties (point-min) (point-max)
'(pabbrev-added t))) '(pabbrev-added t)))
(message "pabbrev fast scavenging buffer...done."))) (message "pabbrev fast scavenging buffer...done."))))




(defun pabbrev-scavenge-buffer() (defun pabbrev-scavenge-buffer()
(interactive) (interactive)
(save-excursion (let ((inhibit-read-only t))
(goto-char (point-min)) (save-excursion
(goto-char (point-min))


(working-status-forms "pabbrev scavenging buffer" "done" (working-status-forms "pabbrev scavenging buffer" "done"
(while (pabbrev-forward-thing) (while (pabbrev-forward-thing)
(working-status (/ (* 100 (point)) (point-max))) (working-status (/ (* 100 (point)) (point-max)))
;;(message "pabbrev scavenging (buffer %s words %s line %s done %s %%)..." ;;(message "pabbrev scavenging (buffer %s words %s line %s done %s %%)..."
;; (current-buffer) ;; (current-buffer)
;; (pabbrev-get-usage-dictionary-size) ;; (pabbrev-get-usage-dictionary-size)
;; current-line ;; current-line
;; (/ (* 100 current-line) total-line)) ;; (/ (* 100 current-line) total-line))
;;(message "pabbrev scavenging buffer...On line %s" ;;(message "pabbrev scavenging buffer...On line %s"
;; (count-lines (point-min) (point))) ;; (count-lines (point-min) (point)))
(pabbrev-mark-add-word (pabbrev-mark-add-word
(pabbrev-bounds-of-thing-at-point))) (pabbrev-bounds-of-thing-at-point)))
(working-status t)) (working-status t))


(pabbrev-debug-message "Dictionary size %s total usage %s" (pabbrev-debug-message "Dictionary size %s total usage %s"
(pabbrev-get-usage-dictionary-size)) (pabbrev-get-usage-dictionary-size))
(message "pabbrev scavenging buffer...done."))) (message "pabbrev scavenging buffer...done."))))




(defun pabbrev-scavenge-words(&optional direction number) (defun pabbrev-scavenge-words(&optional direction number)
Expand Down

0 comments on commit 62569e8

Please sign in to comment.