[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hideshowvis 7cb98a4455 02/20: v0.1
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hideshowvis 7cb98a4455 02/20: v0.1 |
Date: |
Sat, 15 Jun 2024 10:00:26 -0400 (EDT) |
branch: elpa/hideshowvis
commit 7cb98a44550a3a63a40c4458cdc0efde4579a3fc
Author: Jan Rehders <cmdkeen@gmx.de>
Commit: Jan Rehders <cmdkeen@gmx.de>
v0.1
---
hideshowvis.el | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 192 insertions(+)
diff --git a/hideshowvis.el b/hideshowvis.el
new file mode 100644
index 0000000000..3f656fc55e
--- /dev/null
+++ b/hideshowvis.el
@@ -0,0 +1,192 @@
+;;; hideshowvis.el --- Add markers to the fringe for regions foldable by
hideshow.el
+;;
+;; Copyright 2008 Jan Rehders
+;;
+;; Author: Jan Rehders <cmdkeen@gmx.de>
+;; Version: 0.1
+;; Contributions by Bryan Waite
+;;
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+;;
+
+;;; Commentary:
+;;
+;; This minor mode will add little +/- displays to foldable regions in the
+;; buffer and to folded regions. It is indented to be used in conjunction with
+;; hideshow.el which is a part of GNU Emacs since version 20.
+;;
+;; Currently it works for me but is not tested heavily. Please report any bugs
+;; to the above email address
+;;
+;;; Installation:
+;; Add the following to your .emacs:
+;;
+;; (autoload 'hideshowvis-enable "hideshowvis" "Highlight foldable regions")
+;;
+;; (dolist (hook (list 'emacs-lisp-mode-hook
+;; 'c++-mode-hook))
+;; (add-hook hook 'hideshowvis-enable))
+;;
+;; If enabling hideshowvis-minor-mode is slow on your machine use M-x,
+;; customize-option, hideshowvis-ignore-same-line and set it to nil. This will
+;; then display - icons for foldable regions of one line, too but is faster
+;;
+;; At the end of this file you will find code to add to your .emacs to enable
+;; displaying a + symbol in the fringe for folded regions. It is not enabled by
+;; default because it might interfere with custom hs-set-up-overlay functions
+;;
+
+(define-fringe-bitmap 'hideshowvis-hideable-marker [0 0 0 126 126 0 0 0])
+
+(defface hideshowvis-hidable-face
+ '((t (:foreground "#ccc" :box t)))
+ "Face to highlight foldable regions"
+ :group 'hideshow)
+
+(defcustom hideshowvis-ignore-same-line t
+ "Do not display foldable regions in the fringe if the matching
+ closing parenthesis is on the same line. Set this to nil if
+ enabling the minor mode is slow on your machine"
+ :group 'hideshow)
+
+(defun hideshowvis-highlight-hs-regions-in-fringe (&optional start end
old-text-length)
+ (when hs-minor-mode
+ (save-restriction
+ (save-excursion
+ (when (and start end)
+ (narrow-to-region start end))
+ (goto-char (point-min))
+ (remove-overlays (point-min) (point-max) 'hideshowvis-hs t)
+ (while (search-forward-regexp hs-block-start-regexp nil t)
+ (let* ((ovl (make-overlay (match-beginning 0) (match-end 0)))
+ (marker-string "*hideshowvis*")
+ (mdata (hs-match-data t))
+ (doit
+ (if hideshowvis-ignore-same-line
+ (let (begin-line)
+ (setq begin-line
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (line-number-at-pos (point))))
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (condition-case nothing
+ (progn
+ (funcall hs-forward-sexp-func 1)
+ (> (line-number-at-pos (point)) begin-line))
+ (error nil))))
+ t)))
+ (when doit
+ (put-text-property 0
+ (length marker-string)
+ 'display
+ (list 'left-fringe
+ 'hideshowvis-hideable-marker
+ 'hideshowvis-hidable-face)
+ marker-string)
+ (overlay-put ovl 'before-string marker-string)
+ (overlay-put ovl 'hideshowvis-hs t))))))))
+
+(defun hideshowvis-click-fringe (event)
+ (interactive "e")
+ (mouse-set-point event)
+ (end-of-line)
+ (if (save-excursion
+ (end-of-line 1)
+ (or (hs-already-hidden-p)
+ (progn
+ (forward-char 1)
+ (hs-already-hidden-p))))
+ (hs-show-block)
+ (hs-hide-block)
+ (beginning-of-line)))
+
+(defvar hideshowvis-mode-map
+ (let ((hideshowvis-mode-map (make-sparse-keymap)))
+ (define-key hideshowvis-mode-map [left-fringe mouse-1]
+ 'hideshowvis-click-fringe)
+ hideshowvis-mode-map)
+ "Keymap for hideshowvis mode")
+
+(define-minor-mode hideshowvis-minor-mode ()
+ "Will indicate regions foldable with hideshow in the fringe"
+ :init-value nil
+ :require 'hideshow
+ :group 'hideshow
+ (condition-case nil
+ (if hideshowvis-minor-mode
+ (progn
+ (hs-minor-mode 1)
+ (hideshowvis-highlight-hs-regions-in-fringe (point-min)
(point-max) 0)
+ (add-to-list 'after-change-functions
+ 'hideshowvis-highlight-hs-regions-in-fringe))
+ (use-local-map hideshowvis-mode-map)
+ (remove-overlays (point-min) (point-max) 'hideshowvis-hs t)
+ (setq after-change-functions
+ (remove 'hideshowvis-highlight-hs-regions-in-fringe
+ after-change-functions)))
+ (error
+ (message "Failed to toggle hideshowvis-minor-mode")
+ )))
+
+(defun hideshowvis-enable ()
+ (hideshowvis-minor-mode 1))
+
+
+;; Add the following to your .emacs and uncomment it in order to get a + symbol
+;; in the fringe and a yellow marker indicating the number of hidden lines at
+;; the end of the line for hidden regions:
+
+
+;; (define-fringe-bitmap 'hs-marker [0 24 24 126 126 24 24 0])
+;;
+;; (defcustom hs-fringe-face 'hs-fringe-face
+;; "*Specify face used to highlight the fringe on hidden regions."
+;; :type 'face
+;; :group 'hideshow)
+;;
+;; (defface hs-fringe-face
+;; '((t (:foreground "#888" :box (:line-width 2 :color "grey75" :style
released-button))))
+;; "Face used to highlight the fringe on folded regions"
+;; :group 'hideshow)
+;;
+;; (defcustom hs-face 'hs-face
+;; "*Specify the face to to use for the hidden region indicator"
+;; :type 'face
+;; :group 'hideshow)
+;;
+;; (defface hs-face
+;; '((t (:background "#ff8" :box t)))
+;; "Face to hightlight the ... area of hidden regions"
+;; :group 'hideshow)
+;;
+;; (defun display-code-line-counts (ov)
+;; (when (eq 'code (overlay-get ov 'hs))
+;; (let* ((marker-string "*fringe-dummy*")
+;; (marker-length (length marker-string))
+;; (display-string (format "(%d)..." (count-lines (overlay-start
ov) (overlay-end ov))))
+;; )
+;; (overlay-put ov 'help-echo "Hiddent text. C-c,= to show")
+;; (put-text-property 0 marker-length 'display (list 'left-fringe
'hs-marker 'hs-fringe-face) marker-string)
+;; (overlay-put ov 'before-string marker-string)
+;; (put-text-property 0 (length display-string) 'face 'hs-face
display-string)
+;; (overlay-put ov 'display display-string)
+;; )))
+;;
+;; (setq hs-set-up-overlay 'display-code-line-counts)
+
+(provide 'hideshowvis)
+
- [nongnu] branch elpa/hideshowvis created (now 3a605b78d8), ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 7cb98a4455 02/20: v0.1,
ELPA Syncer <=
- [nongnu] elpa/hideshowvis 5e5ab24a35 03/20: v0.2, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 6dee54598e 01/20: Initial commit, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 7d5a6e259d 04/20: v0.3, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 51c9fcd8ff 05/20: v0.4, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 2474bb3175 07/20: v0.6, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 3a5cd08c4f 10/20: Fixed version constant., ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis c2ab91bd77 18/20: Fix interaction with auto-revert-mode., ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 7b174241c9 15/20: fix: Check hideshowvis-ignore-same-line before making overlay., ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 136d94e8f1 08/20: Updated readme, ELPA Syncer, 2024/06/15
- [nongnu] elpa/hideshowvis 3a605b78d8 20/20: Applied code review comments by Philip Kaludercic, ELPA Syncer, 2024/06/15