X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b14e3e21ec6702d27257a1400681fc36ee10282f..5f46725992bf26f887483c14c63c03f5b5794f34:/lisp/progmodes/glasses.el diff --git a/lisp/progmodes/glasses.el b/lisp/progmodes/glasses.el index a1dc19da1e..23fced7ef8 100644 --- a/lisp/progmodes/glasses.el +++ b/lisp/progmodes/glasses.el @@ -1,6 +1,6 @@ ;;; glasses.el --- make cantReadThis readable -;; Copyright (C) 1999-2011 Free Software Foundation, Inc. +;; Copyright (C) 1999-2014 Free Software Foundation, Inc. ;; Author: Milan Zamazal ;; Maintainer: Milan Zamazal @@ -51,10 +51,6 @@ ;;; Code: -(eval-when-compile - (require 'cl)) - - ;;; User variables @@ -78,7 +74,7 @@ string." (defcustom glasses-original-separator "_" - "*String to be displayed as `glasses-separator' in separator positions. + "String to be displayed as `glasses-separator' in separator positions. For instance, if you set it to \"_\" and set `glasses-separator' to \"-\", underscore separators are displayed as hyphens. If `glasses-original-separator' is an empty string, no such display change is @@ -116,6 +112,15 @@ parenthesis expression starts." :group 'glasses :type '(repeat regexp)) +(defcustom glasses-separate-capital-groups t + "If non-nil, try to separate groups of capital letters. +When the value is non-nil, HTMLSomething and IPv6 are displayed +as HTML_Something and I_Pv6 respectively. Set the value to nil +if you prefer to display them unchanged." + :group 'glasses + :type 'boolean + :version "24.1") + (defcustom glasses-uncapitalize-p nil "If non-nil, downcase embedded capital letters in identifiers. Only identifiers starting with lower case letters are affected, letters inside @@ -212,8 +217,11 @@ CATEGORY is the overlay category. If it is nil, use the `glasses' category." 'glasses-init)) ;; Face + separator (goto-char beg) - (while (re-search-forward "[a-z]\\([A-Z]\\)\\|[A-Z]\\([A-Z]\\)[a-z]" - end t) + (while (re-search-forward + (if glasses-separate-capital-groups + "[a-z]\\([A-Z]\\)\\|[A-Z]\\([A-Z]\\)[a-z]" + "[a-z]\\([A-Z]\\)") + end t) (let* ((n (if (match-string 1) 1 2)) (o (glasses-make-overlay (match-beginning n) (match-end n)))) (goto-char (match-beginning n)) @@ -290,7 +298,7 @@ recognized according to the current value of the variable `glasses-separator'." nil) -(defun glasses-change (beg end &optional old-len) +(defun glasses-change (beg end &optional _old-len) "After-change function updating glass overlays." (let ((beg-line (save-excursion (goto-char beg) (line-beginning-position))) (end-line (save-excursion (goto-char end) (line-end-position)))) @@ -304,8 +312,10 @@ recognized according to the current value of the variable `glasses-separator'." ;;;###autoload (define-minor-mode glasses-mode "Minor mode for making identifiers likeThis readable. -When this mode is active, it tries to add virtual separators (like underscores) -at places they belong to." +With a prefix argument ARG, enable the mode if ARG is positive, +and disable it otherwise. If called from Lisp, enable the mode +if ARG is omitted or nil. When this mode is active, it tries to +add virtual separators (like underscores) at places they belong to." :group 'glasses :lighter " o^o" (save-excursion (save-restriction