Skip to content
Back to skills

Emacs Buffer

ASecurity

Use when manipulating Emacs buffers - provides elisp patterns for listing, switching, creating, killing, and working with buffer contents

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
businessgo

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill emacs-buffer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Emacs Buffer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Emacs Buffer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-emacs-buffer/badge)](https://www.skillsdirectory.com/skills/majiayu000-emacs-buffer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: emacs-buffer
description: Use when manipulating Emacs buffers - provides elisp patterns for listing, switching, creating, killing, and working with buffer contents
---

# Emacs Buffer Skill

## Display Guidelines

**E-ink Monitor Compatibility**: User uses an e-ink monitor that only supports black, white, and grey.
- NEVER use colors (`:foreground "red"`, `:foreground "cyan"`, etc.)
- Use `:weight bold`, `:weight light`, `:slant italic`, `:underline t` for differentiation
- Standard Emacs faces (font-lock-*-face) are acceptable as they adapt to themes

## Buffer Basics

### Get current buffer
```elisp
(current-buffer)      ; returns buffer object
(buffer-name)         ; returns buffer name string
(buffer-file-name)    ; returns file path or nil
```

### Switch to buffer
```elisp
(switch-to-buffer "buffer-name")
(set-buffer "buffer-name")  ; doesn't change window display
(pop-to-buffer "buffer-name")  ; shows in new window
```

### Create buffer
```elisp
(get-buffer-create "*my-buffer*")
(with-current-buffer (get-buffer-create "*my-buffer*")
  ;; work in buffer
  )
```

### Kill buffer
```elisp
(kill-buffer "buffer-name")
(kill-buffer (current-buffer))
```

## Buffer Contents

### Read buffer text
```elisp
(buffer-string)  ; entire buffer
(buffer-substring start end)  ; region
(buffer-substring-no-properties start end)  ; without text properties
```

### Insert text
```elisp
(insert "text")
(insert-buffer-substring other-buffer start end)
```

### Erase buffer
```elisp
(erase-buffer)
(delete-region start end)
```

## Buffer Properties

### Check buffer state
```elisp
(buffer-modified-p)  ; unsaved changes?
(buffer-live-p buf)  ; buffer exists?
(get-buffer "name")  ; returns buffer or nil
```

### Set buffer properties
```elisp
(set-buffer-modified-p nil)  ; mark as saved
(rename-buffer "new-name")
```

## Buffer Lists

### List all buffers
```elisp
(buffer-list)  ; all buffers
(mapcar #'buffer-name (buffer-list))  ; just names
```

### Filter buffers
```elisp
;; Get file-visiting buffers
(seq-filter #'buffer-file-name (buffer-list))

;; Get buffers matching pattern
(seq-filter (lambda (b)
              (string-match-p "\\*claude" (buffer-name b)))
            (buffer-list))
```

## Working with Buffer Positions

### Point operations
```elisp
(point)          ; current position
(point-min)      ; buffer start
(point-max)      ; buffer end
(goto-char pos)  ; move to position
```

### Save and restore position
```elisp
(save-excursion
  ;; point and buffer restored after body
  (goto-char (point-min))
  (search-forward "text"))
```

## Temporary Buffers

### with-temp-buffer
```elisp
(with-temp-buffer
  (insert "temporary content")
  (buffer-string))  ; returns content, buffer killed after
```

### Generate new buffer
```elisp
(generate-new-buffer "*unique-name*")
```

## Buffer-Local Variables

### Set buffer-local
```elisp
(setq-local my-var "value")
(make-local-variable 'my-var)
```

### Check if buffer-local
```elisp
(local-variable-p 'my-var)
(buffer-local-value 'my-var some-buffer)
```

## Common Patterns

### Process buffer safely
```elisp
(when-let ((buf (get-buffer "*my-buffer*")))
  (with-current-buffer buf
    ;; work with buffer
    ))
```

### Create output buffer
```elisp
(let ((buf (get-buffer-create "*output*")))
  (with-current-buffer buf
    (erase-buffer)
    (insert "Output:\n")
    (insert result))
  (display-buffer buf))
```

### Find buffer by mode
```elisp
(seq-find (lambda (b)
            (with-current-buffer b
              (derived-mode-p 'org-mode)))
          (buffer-list))
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.