]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ascii-art-to-unicode/ascii-art-to-unicode.el
[aa2u int] Add "Tip Jar" URL in Commentary; nfc.
[gnu-emacs-elpa] / packages / ascii-art-to-unicode / ascii-art-to-unicode.el
index 6c691a71fd02bbde2a5116ab78591223fd44a0b0..7d03a9d72e8883dd634728002b4e0097b52cd115 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2014  Free Software Foundation, Inc.
 
 ;; Author: Thien-Thi Nguyen <ttn@gnu.org>
-;; Version: 1.4
+;; Version: 1.6
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;;           │          │
 ;;           └──────────┘
 ;;
-;; TODO:
-;; - 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.
-;; - Choose plus-replacement by composing "VERTICAL", "LEFT", etc.
-
-;;; News:
-
-;; - 1.4 | 2014-01-14
-;;   - move to ELPA (from <http://www.gnuvola.org/software/j/aa2u/>)
-;;   - change copyright to FSF
-;;   - require 'cl-lib instead of 'cl
-;;   - use ‘cl-flet’ and ‘cl-labels’
-;;   - comment munging
-;;     - add ‘lexical-binding: t’
-;;     - remove huge list at EOF
-;;     - add Author and News headers
-;;
-;; - 1.3 | 2013-09-21
-;;   - bug fixed: ‘?+’ neighbor valuation polarity flipped
-;;   - new support for BOX DRAWINGS LIGHT {UP,DOWN,LEFT,RIGHT} (singleton)
-;;
-;; - 1.2 | 2012-11-05
-;;   - refer to Unicode characters by name, not number
+;; Much easier on the eyes now!
 ;;
-;; - 1.1 | 2012-04-17
-;;   - TAB agnostic
-;;   - ‘aa2u’ operates on active region if ‘use-region-p’
-;;   - example use case also demonstrates transformation
 ;;
-;; - 1.0 | 2012-04-07
-;;   - initial release
+;; See Also
+;; - HACKING: <http://git.sv.gnu.org/cgit/emacs/elpa.git/tree/packages/ascii-art-to-unicode/HACKING>
+;; - Tip Jar: <http://www.gnuvola.org/software/aa2u/>
 
 ;;; Code:
 
@@ -228,7 +202,7 @@ Their values are STRINGIFIER and COMPONENTS, respectively."
 ;;; command
 
 ;;;###autoload
-(defun aa2u ()
+(defun aa2u (beg end &optional interactive)
   "Convert simple ASCII art line drawings to Unicode.
 Specifically, perform the following replacements:
 
@@ -254,20 +228,24 @@ More precisely, hyphen and vertical bar are substituted unconditionally,
 first, and plus is substituted with a character depending on its north,
 south, east and west neighbors.
 
-This command operates on either the active region, as per
-`use-region-p', or the accessible portion otherwise."
-  (interactive)
+This command operates on either the active region,
+or the accessible portion otherwise."
+  (interactive "r\np")
+  ;; This weirdness, along w/ the undocumented "p" in the ‘interactive’
+  ;; form, is to allow ‘M-x aa2u’ (interactive invocation) w/ no region
+  ;; selected to default to the accessible portion (as documented), which
+  ;; was the norm in ascii-art-to-unicode.el prior to 1.5.  A bugfix,
+  ;; essentially.  This is ugly, unfortunately -- is there a better way?!
+  (when (and interactive (not (region-active-p)))
+    (setq beg (point-min)
+          end (point-max)))
   (save-excursion
-    (cl-flet
-        ((do-it! () (aa2u-phase-1) (aa2u-phase-2) (aa2u-phase-3)))
-      (if (use-region-p)
-          (let ((beg (region-beginning))
-                (end (region-end)))
-            (save-restriction
-              (widen)
-              (narrow-to-region beg end)
-              (do-it!)))
-        (do-it!)))))
+    (save-restriction
+      (widen)
+      (narrow-to-region beg end)
+      (aa2u-phase-1)
+      (aa2u-phase-2)
+      (aa2u-phase-3))))
 
 ;;;---------------------------------------------------------------------------
 ;;; that's it