comparison lisp/progmodes/mantemp.el @ 77374:74462e953a2c

(mantemp-make-mantemps-region) (mantemp-insert-cxx-syntax, mantemp-sort-and-unique-lines) (mantemp-remove-memfuncs): Use delete-region instead of kill-word and kill-line.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 21 Apr 2007 20:04:06 +0000
parents e3694f1cb928
children c1ec1c8a8d2e e6fdae9180d4
comparison
equal deleted inserted replaced
77373:164923acff54 77374:74462e953a2c
103 (message "Removing member function extensions") 103 (message "Removing member function extensions")
104 (while (re-search-forward 104 (while (re-search-forward
105 "^[A-z :&*<>~=,0-9+]*>::operator " nil t nil) 105 "^[A-z :&*<>~=,0-9+]*>::operator " nil t nil)
106 (progn 106 (progn
107 (backward-char 11) 107 (backward-char 11)
108 (kill-line))) 108 (delete-region (point) (line-end-position))))
109 ;; Remove other member function extensions. 109 ;; Remove other member function extensions.
110 (goto-char (point-min)) 110 (goto-char (point-min))
111 (message "Removing member function extensions") 111 (message "Removing member function extensions")
112 (while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil) 112 (while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil)
113 (progn 113 (progn
114 (backward-char 2) 114 (backward-char 2)
115 (kill-line))))) 115 (delete-region (point) (line-end-position))))))
116 116
117 (defun mantemp-sort-and-unique-lines () 117 (defun mantemp-sort-and-unique-lines ()
118 "Eliminate all consecutive duplicate lines in the buffer." 118 "Eliminate all consecutive duplicate lines in the buffer."
119 (save-excursion 119 (save-excursion
120 (message "Sorting") 120 (message "Sorting")
125 (message "Removing consecutive duplicate lines") 125 (message "Removing consecutive duplicate lines")
126 (while (re-search-forward "\\(^.+\\)\n\\1" nil t nil) 126 (while (re-search-forward "\\(^.+\\)\n\\1" nil t nil)
127 (progn 127 (progn
128 (forward-line -1) 128 (forward-line -1)
129 (beginning-of-line) 129 (beginning-of-line)
130 (kill-line 1))))) 130 (delete-region (point) (progn (forward-line 1) (point)))))))
131 131
132 (defun mantemp-insert-cxx-syntax () 132 (defun mantemp-insert-cxx-syntax ()
133 "Insert C++ syntax around each template class and function. 133 "Insert C++ syntax around each template class and function.
134 Insert 'template class' for classes, 'template' for 134 Insert 'template class' for classes, 'template' for
135 functions and add the statement delimiter `;' at the end of 135 functions and add the statement delimiter `;' at the end of
159 (while (re-search-forward 159 (while (re-search-forward
160 "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil) 160 "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil)
161 (progn 161 (progn
162 (beginning-of-line) 162 (beginning-of-line)
163 (forward-word 1) 163 (forward-word 1)
164 (kill-word 1))))) 164 (delete-region (point) (progn (forward-word 1) (point)))))))
165 165
166 (defun mantemp-make-mantemps () 166 (defun mantemp-make-mantemps ()
167 "Gathering interface to the functions modifying the buffer." 167 "Gathering interface to the functions modifying the buffer."
168 (mantemp-remove-comments) 168 (mantemp-remove-comments)
169 (mantemp-remove-memfuncs) 169 (mantemp-remove-memfuncs)
187 "Make manual template instantiations from g++ error messages in the region. 187 "Make manual template instantiations from g++ error messages in the region.
188 This function does the same thing as `mantemp-make-mantemps-buffer', 188 This function does the same thing as `mantemp-make-mantemps-buffer',
189 but operates on the region." 189 but operates on the region."
190 (interactive) 190 (interactive)
191 (let ((cur-buf (current-buffer)) 191 (let ((cur-buf (current-buffer))
192 (mantemp-buffer (generate-new-buffer "*mantemp*"))) 192 (mantemp-buffer (generate-new-buffer "*mantemp*"))
193 (str (buffer-substring (mark) (point))))
193 ;; Copy the region to a temporary buffer, make the C++ code there 194 ;; Copy the region to a temporary buffer, make the C++ code there
194 ;; and copy the result back to the current buffer. 195 ;; and copy the result back to the current buffer.
195 (kill-region (mark) (point))
196 (set-buffer mantemp-buffer) 196 (set-buffer mantemp-buffer)
197 (yank) 197 (insert str)
198 (mantemp-make-mantemps) 198 (mantemp-make-mantemps)
199 (kill-region (point-min) (point-max)) 199 (setq str (buffer-string))
200 (set-buffer cur-buf) 200 (set-buffer cur-buf)
201 (yank) 201 (insert str)
202 (kill-buffer mantemp-buffer)) 202 (kill-buffer mantemp-buffer))
203 (message "Done")) 203 (message "Done"))
204 204
205 (provide 'mantemp) 205 (provide 'mantemp)
206 206