Mercurial > emacs
comparison lisp/progmodes/glasses.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 2fc21ed3beac |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; glasses.el --- make cantReadThis readable | 1 ;;; glasses.el --- make cantReadThis readable |
2 | 2 |
3 ;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1999, 2000, 2001, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Milan Zamazal <pdm@zamazal.org> | 5 ;; Author: Milan Zamazal <pdm@zamazal.org> |
6 ;; Maintainer: Milan Zamazal <pdm@zamazal.org> | 6 ;; Maintainer: Milan Zamazal <pdm@zamazal.org> |
7 ;; Keywords: tools | 7 ;; Keywords: tools |
8 | 8 |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 ;; GNU General Public License for more details. | 19 ;; GNU General Public License for more details. |
20 | 20 |
21 ;; You should have received a copy of the GNU General Public License | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02111-1307, USA. | 24 ;; Boston, MA 02110-1301, USA. |
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; This file defines a minor mode for making unreadableIdentifiersLikeThis | 28 ;; This file defines a minor mode for making unreadableIdentifiersLikeThis |
29 ;; readable. In some environments, for instance Java, it is common to use such | 29 ;; readable. In some environments, for instance Java, it is common to use such |
80 | 80 |
81 For example, you can set `glasses-separator' to an empty string and | 81 For example, you can set `glasses-separator' to an empty string and |
82 `glasses-face' to `bold'. Then unreadable identifiers will have no separators, | 82 `glasses-face' to `bold'. Then unreadable identifiers will have no separators, |
83 but will have their capitals in bold." | 83 but will have their capitals in bold." |
84 :group 'glasses | 84 :group 'glasses |
85 :type 'symbol | 85 :type '(choice (const :tag "None" nil) face) |
86 :set 'glasses-custom-set | 86 :set 'glasses-custom-set |
87 :initialize 'custom-initialize-default) | 87 :initialize 'custom-initialize-default) |
88 | 88 |
89 | 89 |
90 (defcustom glasses-separate-parentheses-p t | 90 (defcustom glasses-separate-parentheses-p t |
193 (save-match-data | 193 (save-match-data |
194 (re-search-backward "\\<.") | 194 (re-search-backward "\\<.") |
195 (looking-at glasses-uncapitalize-regexp)))) | 195 (looking-at glasses-uncapitalize-regexp)))) |
196 (overlay-put o 'invisible t) | 196 (overlay-put o 'invisible t) |
197 (overlay-put o 'after-string (downcase (match-string n)))))) | 197 (overlay-put o 'after-string (downcase (match-string n)))))) |
198 ;; Separator change | |
199 (unless (string= glasses-separator "_") | |
200 (goto-char beg) | |
201 (while (re-search-forward "[a-zA-Z0-9]\\(_+\\)[a-zA-Z0-9]" end t) | |
202 (goto-char (match-beginning 1)) | |
203 (while (eql (char-after) ?\_) | |
204 (let ((o (glasses-make-overlay (point) (1+ (point))))) | |
205 ;; `concat' ensures the character properties won't merge | |
206 (overlay-put o 'display (concat glasses-separator))) | |
207 (forward-char)))) | |
198 ;; Parentheses | 208 ;; Parentheses |
199 (when glasses-separate-parentheses-p | 209 (when glasses-separate-parentheses-p |
200 (goto-char beg) | 210 (goto-char beg) |
201 (while (re-search-forward "[a-zA-Z]_*\\(\(\\)" end t) | 211 (while (re-search-forward "[a-zA-Z]_*\\(\(\\)" end t) |
202 (glasses-make-overlay (match-beginning 1) (match-end 1) | 212 (glasses-make-overlay (match-beginning 1) (match-end 1) |
225 separator separator) | 235 separator separator) |
226 nil t) | 236 nil t) |
227 (let ((n (if (match-string 1) 1 2))) | 237 (let ((n (if (match-string 1) 1 2))) |
228 (replace-match "" t nil nil n) | 238 (replace-match "" t nil nil n) |
229 (goto-char (match-end n)))) | 239 (goto-char (match-end n)))) |
240 (unless (string= glasses-separator "_") | |
241 (goto-char (point-min)) | |
242 (while (re-search-forward (format "[a-zA-Z0-9]\\(%s+\\)[a-zA-Z0-9]" | |
243 separator) | |
244 nil t) | |
245 (replace-match "_" nil nil nil 1) | |
246 (goto-char (match-beginning 1)))) | |
230 (when glasses-separate-parentheses-p | 247 (when glasses-separate-parentheses-p |
231 (goto-char (point-min)) | 248 (goto-char (point-min)) |
232 (while (re-search-forward "[a-zA-Z]_*\\( \\)\(" nil t) | 249 (while (re-search-forward "[a-zA-Z]_*\\( \\)\(" nil t) |
233 (replace-match "" t nil nil 1)))))) | 250 (replace-match "" t nil nil 1)))))) |
234 ;; nil must be returned to allow use in write file hooks | 251 ;; nil must be returned to allow use in write file hooks |
249 ;;;###autoload | 266 ;;;###autoload |
250 (define-minor-mode glasses-mode | 267 (define-minor-mode glasses-mode |
251 "Minor mode for making identifiers likeThis readable. | 268 "Minor mode for making identifiers likeThis readable. |
252 When this mode is active, it tries to add virtual separators (like underscores) | 269 When this mode is active, it tries to add virtual separators (like underscores) |
253 at places they belong to." | 270 at places they belong to." |
254 nil " o^o" nil | 271 :group 'glasses :lighter " o^o" |
255 (save-excursion | 272 (save-excursion |
256 (save-restriction | 273 (save-restriction |
257 (widen) | 274 (widen) |
258 ;; We erase all the overlays anyway, to avoid dual sight in some | 275 ;; We erase all the overlays anyway, to avoid dual sight in some |
259 ;; circumstances | 276 ;; circumstances |
271 ;;; Announce | 288 ;;; Announce |
272 | 289 |
273 (provide 'glasses) | 290 (provide 'glasses) |
274 | 291 |
275 | 292 |
293 ;;; arch-tag: a3515167-c89e-484f-90a1-d85143e52b12 | |
276 ;;; glasses.el ends here | 294 ;;; glasses.el ends here |