A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/emacs-php/b.el below:

emacs-php/b.el: Emacs Lisp utility functions for buffer manipulation

Utility functions for buffer manipulation.

Documentation and examples b-append (buffer string-or-buffer)

Insert string-or-buffer to bottom of the buffer.

(let ((x (get-buffer-create "buf-1"))
      (y "yyy"))
  (with-current-buffer x
    (erase-buffer)
    (insert "XXX"))
  (b-append x y)
  (b-string x)) ; => "XXXyyy"
(let ((f (find-file-noselect "~/f.png")))
  (b-binary? f)) ; => t

(let ((f (find-file-noselect "~/a.txt")))
  (b-binary? f)) ; => nil
(with-temp-buffer
  (b-blank? (current-buffer))) ; => t

(with-temp-buffer
  (insert "yey!")
  (b-blank? (current-buffer))) ; => nil
(let ((f (find-file-noselect "~/a.txt")))
  (b-coding-system f)) ; => utf-8-unix

(let ((f (find-file-noselect "~/f.png")))
  (b-coding-system f)) ; => no-conversion
b-duplicate (buffer target-buffer &key start end)
(with-temp-buffer
  (let ((new-buffer (get-buffer-create "buf-2"))
        (orig (current-buffer)))
    (insert "0123456789")

    (b-duplicate orig new-buffer)
    (b-string new-buffer) ;=> "0123456789"

    (b-erase new-buffer)

    (b-duplicate orig new-buffer)
    (b-string new-buffer :start 6) ;=> "56789"

    (b-erase new-buffer)

    (b-duplicate orig new-buffer)
    (b-string new-buffer :end 6) ;=> "01234"

    (b-erase new-buffer)

    (b-duplicate orig new-buffer)
    (b-string new-buffer :start 4 :end 8) ;=> "3456"

    ))
(let ((buf (get-buffer-create "buf-3")))
  (with-current-buffer buf
    (insert "ababababa"))
  (b-string buf) ; => "ababababa"

  (b-erase buf)

  (b-string buf) ;=> ""
  )
b-insert (buffer &rest string-or-buffer)
(with-temp-buffer
  (let ((buf (get-buffer-create "buf-4"))
        (tmp (current-buffer)))

    ;; The following idiom is abbreviated to `b-insert'
    (with-current-buffer buf
      (insert "12345"))
    (b-string buf) ; => "12345"

    (b-insert buf "aaaaa")
    (b-string buf) ;=> "12345aaaaa"

    (b-insert buf "67890" "bbbbb")
    (b-string buf) ;=> "12345aaaaa67890bbbbb"

    (b-insert tmp "zzzzz")

    (b-insert buf " | " tmp)
    (b-string buf) ;=> "12345aaaaa67890bbbbb | zzzzz"
    ))
b-prepend (buffer string-or-buffer)
(let ((x (get-buffer-create "buf-1"))
      (y "yyy"))
  (with-current-buffer x
    (erase-buffer)
    (insert "XXX"))
  (b-prepend x y)
  (b-string x)) ; => "yyyXXX"
b-string (buffer &key start end)
(let ((buf (get-buffer-create "buf-4")))

  (b-erase buf)
  (b-string buf) ;=>

  (b-insert buf "nurupo")
  (b-string buf) ; => "nurupo"
  (b-string buf :end 3) ; => "nu"
  (b-string buf :start 3) ; => "rupo"
  (b-string buf :start 3 :end 5) ; => "ru"
  )
b-string-with-properties (buffer &key start end)
(let ((buf (get-buffer-create "buf-5")))
  (b-erase buf)

  (b-insert buf (propertize "Red" 'face 'bold 'foreground "red"))

  (b-string buf) ; => "Red"
  (b-string-with-properties buf) ; => #("Red" 0 3 (foreground "red" face bold))
  )

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4