[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ascii-art-to-unicode c25476c 19/42: [aa2u] New command:
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ascii-art-to-unicode c25476c 19/42: [aa2u] New command: aa2u-mark-as-text |
Date: |
Sun, 29 Nov 2020 18:57:06 -0500 (EST) |
branch: externals/ascii-art-to-unicode
commit c25476c94d89558083ab6f9cfbeb6c95ab9abb6d
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[aa2u] New command: aa2u-mark-as-text
* packages/ascii-art-to-unicode/ascii-art-to-unicode.el
(aa2u--text-p): New defsubst.
(aa2u-phase-1, aa2u-phase-2): If the character
in question is ‘aa2u--text-p’, just ignore it.
(aa2u-mark-as-text): New command, w/ autoload cookie.
---
HACKING | 1 -
NEWS | 3 +++
ascii-art-to-unicode.el | 42 ++++++++++++++++++++++++++++++++++++++----
3 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/HACKING b/HACKING
index f591a58..59ba535 100644
--- a/HACKING
+++ b/HACKING
@@ -3,7 +3,6 @@ HACKING ascii-art-to-unicode.el -*-
org -*-
This file is both a guide for newcomers and a todo list for oldstayers.
* ideas / wishlist
-*** add phase 0, to grok and lock label (as opposed to line) text
*** add interactive mode, to choose per-line light vs heavy
*** improve neighbor-determining heuristic
*** support "naked" line terminal (no plus)
diff --git a/NEWS b/NEWS
index 9280cfb..492c4ca 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ NEWS for ascii-art-to-unicode.el
See the end for copying conditions.
+- 1.8 | NOT YET RELEASED
+ - new command: ‘aa2u-mark-as-text’
+
- 1.7 | 2014-05-11
- new var: ‘aa2u-uniform-weight’
- new command: ‘aa2u-rectangle’
diff --git a/ascii-art-to-unicode.el b/ascii-art-to-unicode.el
index 733413c..45e5d0f 100644
--- a/ascii-art-to-unicode.el
+++ b/ascii-art-to-unicode.el
@@ -76,6 +76,22 @@
;; ┃ ┃
;; ┗━━━━━━━━━━┛
;;
+;; To protect particular ‘|’, ‘-’ or ‘+’ characters from conversion,
+;; you can set the property `aa2u-text' on that text with command
+;; `aa2u-mark-as-text'. A prefix arg clears the property, instead.
+;; (You can use `describe-text-properties' to check.) For example:
+;;
+;;
+;; ┌───────────────────┐
+;; │ │
+;; │ |\/| │
+;; │ `Oo' --Oop Ack! │
+;; │ ^&-MM. │
+;; │ │
+;; └─────────┬─────────┘
+;; │
+;; """""""""
+;;
;;
;; See Also
;; - HACKING:
<http://git.sv.gnu.org/cgit/emacs/elpa.git/tree/packages/ascii-art-to-unicode/HACKING>
@@ -93,6 +109,9 @@ This specifies the weight of all the lines.")
;;;---------------------------------------------------------------------------
;;; support
+(defsubst aa2u--text-p (pos)
+ (get-text-property pos 'aa2u-text))
+
(defun aa2u-ucs-bd-uniform-name (&rest components)
"Return a string naming UCS char w/ WEIGHT and COMPONENTS.
The string begins with \"BOX DRAWINGS\"; followed by the weight
@@ -136,7 +155,8 @@ Their values are STRINGIFIER and COMPONENTS, respectively."
(goto-char (point-min))
(let ((now (aa2u-1c 'aa2u-ucs-bd-uniform-name name)))
(while (search-forward was nil t)
- (replace-match now t t)))))
+ (unless (aa2u--text-p (match-beginning 0))
+ (replace-match now t t))))))
(gsr "|" 'VERTICAL)
(gsr "-" 'HORIZONTAL)))
@@ -194,9 +214,10 @@ Their values are STRINGIFIER and COMPONENTS, respectively."
;; ‘memq’ to an ‘intersction’.
(while (search-forward "+" nil t)
(let ((p (point)))
- (push (cons p (or (aa2u-replacement (1- p))
- "?"))
- changes)))
+ (unless (aa2u--text-p (1- p))
+ (push (cons p (or (aa2u-replacement (1- p))
+ "?"))
+ changes))))
;; (phase 2.2 -- apply changes)
(dolist (ch changes)
(goto-char (car ch))
@@ -274,6 +295,19 @@ are START (top left) and END (bottom right)."
(goto-char (min start end))
(insert-rectangle now)))
+;;;###autoload
+(defun aa2u-mark-as-text (start end &optional unmark)
+ "Set property `aa2u-text' of the text from START to END.
+This prevents `aa2u' from misinterpreting \"|\", \"-\" and \"+\"
+in that region as lines and intersections to be replaced.
+Prefix arg means to remove property `aa2u-text', instead."
+ (interactive "r\nP")
+ (funcall (if unmark
+ 'remove-text-properties
+ 'add-text-properties)
+ start end
+ '(aa2u-text t)))
+
;;;---------------------------------------------------------------------------
;;; that's it
- [elpa] externals/ascii-art-to-unicode f319591 01/42: New package: ascii-art-to-unicode, (continued)
- [elpa] externals/ascii-art-to-unicode f319591 01/42: New package: ascii-art-to-unicode, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 1e682b8 02/42: [aa2u] Make ‘aa2u’ region-aware., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 42f07bc 04/42: [aa2u] Fix bug: Make ‘M-x aa2u’ operate on accessible portion., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode fc130df 05/42: [aa2u] Release: 1.6, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 1a107c7 06/42: [aa2u maint] Extract NEWS and HACKING to separate files; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 80b9003 08/42: [aa2u int] Don't use ‘cl-labels’ when ‘cl-flet*’ will do., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 6b628eb 14/42: [aa2u] New command: aa2u-rectangle, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 45094de 11/42: [aa2u maint] Update HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 119855b 15/42: [aa2u] Release: 1.7, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode dfc56c7 18/42: [aa2u int] Add abstraction: gsr, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode c25476c 19/42: [aa2u] New command: aa2u-mark-as-text,
Stefan Monnier <=
- [elpa] externals/ascii-art-to-unicode b9fcf21 21/42: [aa2u maint] Mention TAB infelicity in HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 01635f7 07/42: [aa2u int] Add "Tip Jar" URL in Commentary; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 1de2351 09/42: [aa2u int] Compute vertical/horizontal components separately., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 1dd85cc 10/42: [aa2u] Make weight dynamically customizable., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 9ab9dbc 03/42: [aa2u] Release: 1.5, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode c6fac9c 12/42: fixup! [aa2u] Make weight dynamically customizable., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 770d0eb 13/42: ascii-art-to-unicode.el (aa2u-replacement): Use cl-case instead of case., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 5e2eb49 16/42: [aa2u maint] Add ‘Maintainer’ header per top-level README; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 9b97434 22/42: [aa2u] New command: aa2u-mark-rectangle-as-text, Stefan Monnier, 2020/11/29
- [elpa] externals/ascii-art-to-unicode 507bf63 29/42: [aa2u slog] Handle ‘ucs-names’ that returns a hash table., Stefan Monnier, 2020/11/29