help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make-list.el


From: Emanuel Berg
Subject: make-list.el
Date: Sat, 23 Mar 2019 06:28:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

;; This file: http://user.it.uu.se/~embe8573/emacs-init/make-list.el
;;
;;
;;              EXAMPLE WHAT IT DOES
;;
;; Turn this:
;;
;; gnus-summary--inv                      gnus-summary-add-mark
;; gnus-summary-article-ancient-p         gnus-summary-article-children
;; gnus-summary-article-header            gnus-summary-article-intangible-p
;;
;; into this:
;;
;; gnus-summary--inv
;; gnus-summary-add-mark
;; gnus-summary-article-ancient-p
;; gnus-summary-article-children
;; gnus-summary-article-header
;; gnus-summary-article-intangible-p
;;
;;
;;                   QUICK START
;;
;; Three ways to use:
;;
;;   1) from Lisp, e.g.
;;      (make-buffer-list 1 268)
;;
;;   2) interactively (`M-x blist RET') with
;;      a region
;;
;;   3) interactively _without_ a region, then
;;      the whole buffer is affected
;;
;;
;;                      TODO
;;
;;   - docstring
;;
;;   - add an additional optional argument
;;     REGEXP-SEP in case text separators
;;     aren't "[[:space:]]+" as is currently
;;     hardcoded
;;
;;
;;           SOME SAMPLE DATA TO TRY ON
;;
;; (first uncomment - well, it will work anyway
;; I guess...)
;;
;; gnus-summary--inv                      gnus-summary-add-mark
;; gnus-summary-article-ancient-p         gnus-summary-article-children
;; gnus-summary-article-header            gnus-summary-article-intangible-p
;; gnus-summary-article-map               gnus-summary-article-mark
;; gnus-summary-article-number            gnus-summary-article-parent
;; gnus-summary-article-pos               gnus-summary-article-posted-p
;; gnus-summary-article-pseudo-p          gnus-summary-article-score
;; gnus-summary-article-sparse-p          gnus-summary-article-subject
;; gnus-summary-article-unread-p          gnus-summary-articles-in-thread
;; gnus-summary-auto-select-subject       gnus-summary-backend-map
;; gnus-summary-beginning-of-article      gnus-summary-best-group
;; gnus-summary-best-unread-article       gnus-summary-best-unread-subject

(defun make-buffer-list (&optional start stop)
  (interactive
   (if (use-region-p)
       (list (region-beginning) (region-end))
     (list (point-min) (point-max)) ))
  (if (< stop start)
      (error (format
              "Start (%s) cannot be bigger than stop (%s)"
              start stop) )
    (if (or  (< start        (point-min))
             (< (point-max)  stop) )
        (error (format
                "Range provided [%s %s] but buffer is [%s %s]"
                start stop (point-min) (point-max) ))
      (progn
        (narrow-to-region start stop)
        (goto-char (point-min))
        (while (re-search-forward "[[:space:]]+" nil t) ; BOUND NOERROR
          (replace-match "\n" nil nil) ) ; FIXEDCASE LITERAL
        (widen) ))))
(defalias 'blist #'make-buffer-list)

;;;; Testing indata verification:
;;
;; (make-buffer-list  10      1) ; error,
;; (make-buffer-list   0    100) ; error,
;; (make-buffer-list   1  10000) ; and error - good

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]