References
“Dwyl/English-Words - Kimim - Cape-Dict - Autocompletion.” (2014) 2025. dwyl. https://github.com/dwyl/english-words.
MA, Kimi. (2024) 2024. “Kimim/Cloel-Rand-Quote.” https://github.com/kimim/cloel-rand-quote.
뭐가 문제야? 영어 사전 자동 완성 좀 줄여줘
-
-
cape-dict-file “/usr/share/dict/words”
-
cape-dict-limit 100
-rw-r--r-- 1 199 2023-09-07 17:57 README.select-wordlist
-rw-r--r-- 1 962K 2022-01-20 14:16 american-english
-rw-r--r-- 1 955K 2022-01-20 14:16 british-english
-rw-r--r-- 1 482K 2024-03-31 16:30 cracklib-small
lrwxrwxrwx 1 30 2022-07-13 06:25 words -> /etc/dictionaries-common/words
lrwxrwxrwx 1 16 2022-07-13 06:25 words.pre-dictionaries-common -> american-english
dwyl/english-words - kimim - cape-dict - autocompletion
(“Dwyl/English-Words - Kimim - Cape-Dict - Autocompletion” [2014] 2025) 2025
A text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion
Related-Notes
kimim/cloel-rand-quote
(MA [2024] 2024) MA, Kimi 2024
Generate random quote
dwyl/english-words
(“Dwyl/English-Words - Kimim - Cape-Dict - Autocompletion” [2014] 2025) 2025
:memo: A text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion
|2025-04-08 Tue 17:42|
@user 자동완성에 사용되는 사전이 너무 단어가 많아. ’s 들어간 단어들은 다 제외하고 핵심 영어 단어만 들어가 있는 wordlist 찾아줘
- cape-dict-file “/usr/share/dict/words”
- cape-dict-limit 100
-rw-r--r-- 1 199 2023-09-07 17:57 README.select-wordlist
-rw-r--r-- 1 962K 2022-01-20 14:16 american-english
-rw-r--r-- 1 955K 2022-01-20 14:16 british-english
-rw-r--r-- 1 482K 2024-03-31 16:30 cracklib-small
lrwxrwxrwx 1 30 2022-07-13 06:25 words -> /etc/dictionaries-common/words
lrwxrwxrwx 1 16 2022-07-13 06:25 words.pre-dictionaries-common -> american-english
@assistant 핵심 영어 단어만 포함된 wordlist를 찾으려면, *‘s*가 들어간 단어를 제외하고 기본적인 영어 단어만 포함된 목록을 선택하는 것이 좋습니다.
-
기초 영어 단어 목록: 네이버 블로그에 기초 영어 단어 1000개가 정리된 게시글이 있습니다. 이 목록은 중학교 수준의 어휘로 구성되어 있으며, 일상생활에서 자주 사용되는 단어들입니다[3].
-
영단어 어플: 마이보카, Vocat, 암기고래 같은 어플은 사용자가 원하는 단어를 선택하여 나만의 단어장을 만들 수 있는 기능을 제공합니다. 이 어플들은 기본적인 영어 단어 학습에 유용합니다[2].
-
cape-dict 설정: 현재 사용 중인 사전 파일에서 *‘s*가 들어간 단어를 제외하기 위해서는, 직접 단어를 필터링하거나 특정한 단어 목록을 생성해야 합니다. 예를 들어,
grep
명령어를 사용하여 *‘s*가 포함되지 않은 단어만 추출할 수 있습니다.
grep -v "'s" /usr/share/dict/words > core-words.txt
이 명령어는 *‘s*가 포함되지 않은 단어들을 core-words.txt
파일에 저장합니다. 이 파일을 사용하여 cape-dict의 wordlist를 설정할 수 있습니다.
cape-dict-file "/path/to/core-words.txt"
cape-dict-limit 100
- Citations: [1] https://www.youtube.com/watch?v=wHdzMX6-PsA [2] https://manytip.tistory.com/44 [3] https://blog.naver.com/cu1023/221296679654 [4] https://www.youtube.com/watch?v=yWa_nOn3URA [5] https://www.youtube.com/watch?v=PLeQnsm5Egw
@user 코드를 한글로 설명해줘
```text `cape—dict-all-words`라는 변수를 정의하고 초기값으로 nil을 설정합니다. `cape-dict-limit`이라는 변수를 정의하고 초기값으로 100을 설정합니다. `kimim/cape—dict-list`라는 함수를 정의합니다. 이 함수는 grep을 사용하지 않고 `cape-dict-file`에서 INPUT과 일치하는 모든 단어를 반환합니다. 만약 INPUT이 비어있지 않으면 다음을 수행합니다. `inhibit-message`를 t로 설정하고, `message-log-max`를 nil로 설정합니다. `cape-dict-file`이 함수이면 함수를 호출하고, 그렇지 않으면 `cape-dict-file`을 리스트로 묶어 files에 저장합니다. `cape—dict-all-words`가 nil이면, files의 내용을 임시 버퍼에 삽입하고, 버퍼의 내용을 개행 문자를 기준으로 분할하여 `cape—dict-all-words`에 저장합니다. `completion-ignore-case`를 t로 설정하고, `completion-regexp-list`를 INPUT을 정규 표현식으로 인용한 리스트로 설정하여 words에 저장합니다. `cape-dict-limit`가 있고 words의 길이가 `cape-dict-limit`와 같으면 `equal` 함수를, 그렇지 않으면 `string-search` 함수를 사용하여 부분적으로 적용된 함수와 `cape—case-replace-list` 함수를 사용하여 결과를 반환합니다. `cape—dict-list` 함수에 `kimim/cape—dict-list` 함수를 override하도록 advice를 추가합니다. ```
@user 왜 이함수가 필요한거야?
@assistant 코드 자동 완성 시 사용자 정의 단어 목록 (사전)을 활용하기 위해 필요합니다. 기본적으로 제공되는 단어 외에 사용자가 원하는 단어를 추가하여 자동 완성의 정확도와 편의성을 높일 수 있습니다. 즉, =cape-dict-file=에 정의된 단어들을 기반으로 더 풍부한 자동 완성 기능을 제공합니다.
@user 그렇다면 cape-dict-file에 파일 여러개를 사용한다는 말인가?
@assistant 네, cape-dict-file
변수에 파일 여러 개를 리스트 형태로 지정하여 사용할 수 있습니다.
@user
TODO kimim cape-dict
(progn
;; (setq cape-dabbrev-check-other-buffers nil)
;; (setq cape-dict-grep nil)
(setq cape-dict-file (concat user-dotemacs-dir "local/english-words/words_alpha.txt"))
;; "/usr/share/dict/words"
(defvar cape--dict-all-words nil)
(defvar cape-dict-limit 100)
(defun kimim/cape--dict-list (input)
"Return all words from `cape-dict-file' matching INPUT without grep."
(unless (equal input "")
(let* ((inhibit-message t)
(message-log-max nil)
(files (ensure-list
(if (functionp cape-dict-file)
(funcall cape-dict-file)
cape-dict-file)))
(_ (unless cape--dict-all-words
(setq cape--dict-all-words
(split-string (with-temp-buffer
(mapc #'insert-file-contents
files)
(buffer-string))
"\n" 'omit-nulls))))
(words (let ((completion-ignore-case t)
(completion-regexp-list
(list (regexp-quote input))))
(all-completions "" cape--dict-all-words))))
(cons
(apply-partially
(if (and cape-dict-limit (length= words cape-dict-limit))
#'equal #'string-search)
input)
(cape--case-replace-list cape-dict-case-replace input words)))))
(advice-add 'cape--dict-list :override #'kimim/cape--dict-list))
informable
질의
이맥스에서 cape-dict=를 사용할 때 =kimim/cape--dict-list
함수를 정의하여 사용하는 이유는 주로 성능 최적화와 사용자 정의 필요성 때문입니다. 검색 결과와 코드 분석을 바탕으로 다음과 같은 이유를 확인할 수 있습니다.
1. 외부 프로세스(grep
) 의존성 제거
기본 =cape—dict-list=는 =grep=을 통해 사전 파일을 검색합니다[5]. 사용자 코드에서 =(setq cape-dict-grep nil)=로 설정하여 이를 비활성화하고, 대신 *메모리 내에서 직접 사전 검색*을 수행합니다[7]. 이는 외부 프로세스 호출 오버헤드를 줄여 *반응 속도를 개선*합니다.
;; grep 대신 메모리 기반 검색 활성화
(setq cape-dict-grep nil)
2. 사전 파일 캐싱
사전 파일(words_alpha.txt
)을 *한 번만 로드*하여 변수 =cape—dict-all-words=에 저장합니다[7]. 이는 매번 파일 I/O를 수행하는 기본 동작과 달리 *리소스 사용을 최적화*합니다.
;; 파일 내용을 메모리에 캐시
(unless cape--dict-all-words
(setq cape--dict-all-words ...))
3. 대소문자 처리 및 결과 제한
=completion-ignore-case=와 =completion-regexp-list=를 활용해 *대소문자 구분 없이 유연한 검색*이 가능하며, =cape-dict-limit=으로 표시할 후보 수를 제어합니다[7]. 이는 사용자 경험을 개선하기 위한 조치입니다.
;; 대소문자 무시 및 입력 기반 필터링
(let ((completion-ignore-case t)
(completion-regexp-list (list (regexp-quote input))))
(all-completions "" cape--dict-all-words))
4. 사용자 정의 정렬 전략
=apply-partially=를 통해 *동적 정렬 방식을 적용*합니다. 입력값과 완전 일치하는 단어가 있으면 이를 우선시하도록 설계되었습니다[7]. 이는 기본 동작보다 *더 직관적인 완성 흐름*을 제공합니다.
;; 정렬 조건 커스터마이징
(cons (apply-partially ...) ...)
5. 코드 유지보수 용이성
=advice-add=를 사용해 원본 함수를 수정하지 않고 *동작을 오버라이드*합니다[7]. 이는 패키지 업데이트 시 발생할 수 있는 충돌을 방지하는 모범 사례입니다.
;; 기존 함수 동작 변경 없이 확장
(advice-add 'cape--dict-list :override #'kimim/cape--dict-list)
이러한 수정 사항들은 주로 *성능 개선*과 *개인 워크플로우에 맞춘 동작 조정*을 목적으로 합니다. 사용자가 ADHD 진단 후 집중력 관리에 중점을 두고 디지털 미니멀리즘을 실천하는 점[개인화 프로필]을 고려할 때, 반응 속도와 예측 가능한 자동완성 동작이 특히 중요했을 것으로 추정됩니다.
Citations
- [1] https://www.reddit.com/r/emacs/comments/1c4p0hy/corfu_cape_how_to_complete_words_in_buffer_and/
- [2] https://kristofferbalintona.me/posts/202203130102/
- [3] https://blog.tjll.net/a-beginners-guide-to-extending-emacs/
- [4] https://github.com/minad/cape/blob/main/cape.el
- [5] https://github.com/minad/cape
- [6] https://elpa.gnu.org/devel/cape.html
- [7] https://github.com/kimim/kimim-emacs
- [8] https://mirrors.sjtug.sjtu.edu.cn/emacs-elpa/gnu/doc/cape.html
- [9] https://www.marines.mil/portals/1/publications/navmc%202667.pdf
- [10] https://github.com/rileyrg/Emacs-Customisations
- [11] https://github.com/minad/cape/issues/52
- [12] https://stackoverflow.com/questions/9110754/emacs-autocomplete-add-existing-dictionary-to-a-major-mode
- [13] https://emacs.stackexchange.com/questions/75071/cape-dict-cape-ispell-problem-with-language
- [14] https://languagecentre.sun.ac.za/wp-content/uploads/2021/01/SaPlaceNamesDictionary1987.pdf
- [15] https://lists.gnu.org/archive/html/gnu-emacs-sources/2025-01/msg00045.html
- [16] http://bnbeckwith.com/bnb-emacs/
- [17] https://en.wikipedia.org/wiki/Sarah_Baartman
- [18] https://apiacoa.org/publications/teaching/datasets/google-10000-english.txt
- [19] https://inventwithpython.com/dictionary.txt
- [20] https://en.wikipedia.org/wiki/Wikipedia:Unusual_articles
- [21] https://eumgill98.tistory.com/101
- [22] https://github.com/emacs-straight/cape
- [23] https://eunjin3786.tistory.com/343
- [24] https://www.reddit.com/r/emacs/comments/15qnymz/how_does_cape_backends_to/
- [25] https://wikidocs.net/86293
- [26] https://elektrubadur.se/emacs-configuration/
- [27] https://www.mit.edu/~ecprice/wordlist.10000
- [28] https://github.com/minad/corfu
- [29] http://elpa.gnu.org/packages/doc/cape.html
- [30] https://developers.google.com/edu/python/dict-files
- [32] https://inma.tistory.com/138
- [33] https://drshapeless.com/blog/posts/writing-go-templ-with-emacs.html