* Abbrev for shorthand purposes @ 2022-08-05 5:31 uzibalqa via Users list for the GNU Emacs text editor 2022-08-07 0:08 ` kf 2022-08-10 20:30 ` Jean Louis 0 siblings, 2 replies; 6+ messages in thread From: uzibalqa via Users list for the GNU Emacs text editor @ 2022-08-05 5:31 UTC (permalink / raw) To: help-gnu-emacs@gnu.org Have been trying to use abbrev for shorthand purposes. I can go from text to shorthand but not the other way round, because of the punctuation. Is there something I can do? Use of abbrev-mode also fails in situations when different the same abbreviation could expand to more than one word. ("wayward" "wa/") ("westward" "W/") ("adjustment" "ajs-") ("armament" "am-") ("basement" "bs-") ("casement" "ks-") ("enactment" "nak-") ("enjoyment" "njy-") ("enlargement" "nlj-") ("entertainment" "Ntn-") ("measurement" "mz/-") ("movement" "mv-") ("recommend" "rk-") ("require" "rqi") ("separate" "sp;") ("silk" "slk") ("struck" "Sk") ("subject" "sj") ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Abbrev for shorthand purposes 2022-08-05 5:31 Abbrev for shorthand purposes uzibalqa via Users list for the GNU Emacs text editor @ 2022-08-07 0:08 ` kf 2022-08-10 20:30 ` Jean Louis 1 sibling, 0 replies; 6+ messages in thread From: kf @ 2022-08-07 0:08 UTC (permalink / raw) To: help-gnu-emacs On 8/5/22 1:31 AM, uzibalqa via Users list for the GNU Emacs text editor wrote: > Have been trying to use abbrev for shorthand purposes. I can go from text to shorthand but not the other way round, because > of the punctuation. Is there something I can do? Use of abbrev-mode also fails in situations when different the same abbreviation > could expand to more than one word. > > ("wayward" "wa/") ("westward" "W/") > ("adjustment" "ajs-") ("armament" "am-") > ("basement" "bs-") ("casement" "ks-") > ("enactment" "nak-") ("enjoyment" "njy-") > ("enlargement" "nlj-") ("entertainment" "Ntn-") ("measurement" "mz/-") ("movement" "mv-") > ("recommend" "rk-") ("require" "rqi") ("separate" "sp;") > ("silk" "slk") ("struck" "Sk") ("subject" "sj") > Since no one else has yet to reply, I'll jump in with my non-expertise. I see at least two problems: (1) the order of your terms is reversed, e.g., '("wayward" "wa/")' should be '("wa/" "wayward")' and (2) those term pairs should be one to a line, at least that's how emacs has always constructed my ~/.abbrevs file. In addition, there are some other terms to each line. Here's a small part of my ~/.abbrevs file: .... (define-abbrev-table 'global-abbrev-table '( ("aann" "Just got an annoyance phone call." nil :count 14) ("abck" "back" nil :count 3) ("abiltiy" "ability" nil :count 2) ("abotu" "about" nil :count 41) ("abt" "about" nil :count 1) ("abuot" "about" nil :count 7) .... The first line defines a table of abbrevs for all modes. My ~/.abbrevs contains multiple tables, each for a different mode. Note that there are 5 elements to each line. Unfortunately, I understand only the first two, but that much has worked for me for a long time. hth. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Abbrev for shorthand purposes 2022-08-05 5:31 Abbrev for shorthand purposes uzibalqa via Users list for the GNU Emacs text editor 2022-08-07 0:08 ` kf @ 2022-08-10 20:30 ` Jean Louis 2022-08-10 21:43 ` uzibalqa 1 sibling, 1 reply; 6+ messages in thread From: Jean Louis @ 2022-08-10 20:30 UTC (permalink / raw) To: uzibalqa; +Cc: help-gnu-emacs@gnu.org * uzibalqa via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-08-05 08:34]: > Have been trying to use abbrev for shorthand purposes. I can go from text to shorthand but not the other way round, because > of the punctuation. Is there something I can do? Use of abbrev-mode also fails in situations when different the same abbreviation > could expand to more than one word. > > ("wayward" "wa/") ("westward" "W/") > ("adjustment" "ajs-") ("armament" "am-") > ("basement" "bs-") ("casement" "ks-") > ("enactment" "nak-") ("enjoyment" "njy-") > ("enlargement" "nlj-") ("entertainment" "Ntn-") ("measurement" "mz/-") ("movement" "mv-") > ("recommend" "rk-") ("require" "rqi") ("separate" "sp;") > ("silk" "slk") ("struck" "Sk") ("subject" "sj") Why don't you use Emacs built-in interactive functions to add abbrevs? Purpose of abbrevs was not to use them programmatically, but to have it handy to quickly add them while writing text. Abbrevs are not really made to abbreviate common words. Come one. That is way too complicated. They are rather for more complex statements, let us say to expand rms into Richard M. Stallman. There are other good packages for that purpose to expand common words of English language. How about {M-x dynamic-completion-mode RET}? From completion.el: ;; After you type a few characters, pressing the "complete" key inserts ;; the rest of the word you are likely to type. ;; ;; This watches all the words that you type and remembers them. When ;; typing a new word, pressing "complete" (meta-return) "completes" the ;; word by inserting the most recently used word that begins with the ;; same characters. If you press meta-return repeatedly, it cycles ;; through all the words it knows about. ;; ;; If you like the completion then just continue typing, it is as if you ;; entered the text by hand. If you want the inserted extra characters ;; to go away, type control-w or delete. More options are described below. ;; ;; The guesses are made in the order of the most recently "used". Typing ;; in a word and then typing a separator character (such as a space) "uses" ;; the word. So does moving a cursor over the word. If no words are found, ;; it uses an extended version of the dabbrev style completion. ;; ;; You automatically save the completions you use to a file between ;; sessions. ;; ;; Completion enables programmers to enter longer, more descriptive ;; variable names while typing fewer keystrokes than they normally would. ;; ;; ;; Full documentation ;;--------------------- ;; ;; A "word" is any string containing characters with either word or symbol ;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.] ;; Unless you change the constants, you must type at least three characters ;; for the word to be recognized. Only words longer than 6 characters are ;; saved. ;; ;; When you load this file, completion will be on. I suggest you use the ;; compiled version (because it is noticeably faster). ;; ;; M-x completion-mode toggles whether or not new words are added to the ;; database by changing the value of enable-completion. ;; ;; SAVING/LOADING COMPLETIONS ;; Completions are automatically saved from one session to another ;; (unless save-completions-flag or enable-completion is nil). ;; Activating this minor-mode (calling completion-initialize) loads ;; a completions database for a saved completions file ;; (default: ~/.completions). When you exit, Emacs saves a copy of the ;; completions that you often use. When you next start, Emacs loads in ;; the saved completion file. ;; ;; The number of completions saved depends loosely on ;; *saved-completions-decay-factor*. Completions that have never been ;; inserted via "complete" are not saved. You are encouraged to experiment ;; with different functions (see compute-completion-min-num-uses). ;; ;; Some completions are permanent and are always saved out. These ;; completions have their num-uses slot set to T. Use ;; add-permanent-completion to do this ;; ;; Completions are saved only if enable-completion is T. The number of old ;; versions kept of the saved completions file is controlled by ;; completions-file-versions-kept. ;; ;; COMPLETE KEY OPTIONS ;; The complete function takes a numeric arguments. ;; control-u :: leave the point at the beginning of the completion rather ;; than the middle. ;; a number :: rotate through the possible completions by that amount ;; `-' :: same as -1 (insert previous completion) ;; ;; HOW THE DATABASE IS MAINTAINED ;; <write> ;; ;; UPDATING THE DATABASE MANUALLY ;; m-x kill-completion ;; kills the completion at point. ;; m-x add-completion ;; m-x add-permanent-completion ;; ;; UPDATING THE DATABASE FROM A SOURCE CODE FILE ;; m-x add-completions-from-buffer ;; Parses all the definition names from a C or LISP mode buffer and ;; adds them to the completion database. ;; ;; m-x add-completions-from-lisp-file ;; Parses all the definition names from a C or Lisp mode file and ;; adds them to the completion database. ;; ;; UPDATING THE DATABASE FROM A TAGS TABLE ;; m-x add-completions-from-tags-table ;; Adds completions from the current tags-table-buffer. ;; ;; HOW A COMPLETION IS FOUND ;; <write> ;; ;; STRING CASING ;; Completion is string case independent if case-fold-search has its ;; normal default of T. Also when the completion is inserted the case of the ;; entry is coerced appropriately. ;; [E.G. APP --> APPROPRIATELY app --> appropriately ;; App --> Appropriately] ;; ;; INITIALIZATION ;; The form `(completion-initialize)' initializes the completion system by ;; trying to load in the user's completions. After the first call, further ;; calls have no effect so one should be careful not to put the form in a ;; site's standard site-init file. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Abbrev for shorthand purposes 2022-08-10 20:30 ` Jean Louis @ 2022-08-10 21:43 ` uzibalqa 2022-08-11 3:43 ` Jean Louis 0 siblings, 1 reply; 6+ messages in thread From: uzibalqa @ 2022-08-10 21:43 UTC (permalink / raw) To: Jean Louis; +Cc: help-gnu-emacs@gnu.org ------- Original Message ------- On Wednesday, August 10th, 2022 at 8:30 PM, Jean Louis <bugs@gnu.support> wrote: > * uzibalqa via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org [2022-08-05 08:34]: > > > Have been trying to use abbrev for shorthand purposes. I can go from text to shorthand but not the other way round, because > > of the punctuation. Is there something I can do? Use of abbrev-mode also fails in situations when different the same abbreviation > > could expand to more than one word. > > > > ("wayward" "wa/") ("westward" "W/") > > ("adjustment" "ajs-") ("armament" "am-") > > ("basement" "bs-") ("casement" "ks-") > > ("enactment" "nak-") ("enjoyment" "njy-") > > ("enlargement" "nlj-") ("entertainment" "Ntn-") ("measurement" "mz/-") ("movement" "mv-") > > ("recommend" "rk-") ("require" "rqi") ("separate" "sp;") > > ("silk" "slk") ("struck" "Sk") ("subject" "sj") > > > Why don't you use Emacs built-in interactive functions to add abbrevs? > > Purpose of abbrevs was not to use them programmatically, but to have > it handy to quickly add them while writing text. I am using them programmatically because I want to implement a specific scheme for short writing. > Abbrevs are not really made to abbreviate common words. Come one. That > is way too complicated. They are rather for more complex statements, > let us say to expand rms into Richard M. Stallman. You are absolutely right, but found abbrev the closest things I can do and test the idea. I can take a normal word and make an abbreviated word. But I cannot perform the reverse because the results include punctuation, which abbrev cannot process. For instance I can go from "sentimental" to "s--l" but not the reverse. ("sentimental" "s--l") I use company-mode to quickly complete the word "sentimental" whilst abbrev mode would change "sentimental" to "s--l" once I hit space. > There are other good packages for that purpose to expand common words > of English language. > > How about {M-x dynamic-completion-mode RET}? I am thinking about completion (after trying abbrev). How can I go about it. What can I try? > From completion.el: > > ;; After you type a few characters, pressing the "complete" key inserts > ;; the rest of the word you are likely to type. > ;; Yes I can complete the word "sentimental", but am struggling on how the word can then be changed to "s--l". > ;; This watches all the words that you type and remembers them. When > ;; typing a new word, pressing "complete" (meta-return) "completes" the > ;; word by inserting the most recently used word that begins with the > ;; same characters. If you press meta-return repeatedly, it cycles > ;; through all the words it knows about. > ;; > ;; If you like the completion then just continue typing, it is as if you > ;; entered the text by hand. If you want the inserted extra characters > ;; to go away, type control-w or delete. More options are described below. > ;; > ;; The guesses are made in the order of the most recently "used". Typing > ;; in a word and then typing a separator character (such as a space) "uses" > ;; the word. So does moving a cursor over the word. If no words are found, > ;; it uses an extended version of the dabbrev style completion. > ;; > ;; You automatically save the completions you use to a file between > ;; sessions. > ;; > ;; Completion enables programmers to enter longer, more descriptive > ;; variable names while typing fewer keystrokes than they normally would. > ;; > ;; > ;; Full documentation > ;;--------------------- > ;; > ;; A "word" is any string containing characters with either word or symbol > ;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.] > ;; Unless you change the constants, you must type at least three characters > ;; for the word to be recognized. Only words longer than 6 characters are > ;; saved. > ;; > ;; When you load this file, completion will be on. I suggest you use the > ;; compiled version (because it is noticeably faster). > ;; > ;; M-x completion-mode toggles whether or not new words are added to the > ;; database by changing the value of enable-completion. > ;; > ;; SAVING/LOADING COMPLETIONS > ;; Completions are automatically saved from one session to another > ;; (unless save-completions-flag or enable-completion is nil). > ;; Activating this minor-mode (calling completion-initialize) loads > ;; a completions database for a saved completions file > ;; (default: ~/.completions). When you exit, Emacs saves a copy of the > ;; completions that you often use. When you next start, Emacs loads in > ;; the saved completion file. > ;; > ;; The number of completions saved depends loosely on > ;; saved-completions-decay-factor. Completions that have never been > ;; inserted via "complete" are not saved. You are encouraged to experiment > ;; with different functions (see compute-completion-min-num-uses). > ;; > ;; Some completions are permanent and are always saved out. These > ;; completions have their num-uses slot set to T. Use > ;; add-permanent-completion to do this > ;; > ;; Completions are saved only if enable-completion is T. The number of old > ;; versions kept of the saved completions file is controlled by > ;; completions-file-versions-kept. > ;; > ;; COMPLETE KEY OPTIONS > ;; The complete function takes a numeric arguments. > ;; control-u :: leave the point at the beginning of the completion rather > ;; than the middle. > ;; a number :: rotate through the possible completions by that amount > ;; `-' :: same as -1 (insert previous completion) > ;; > ;; HOW THE DATABASE IS MAINTAINED > ;; <write> > > ;; > ;; UPDATING THE DATABASE MANUALLY > ;; m-x kill-completion > ;; kills the completion at point. > ;; m-x add-completion > ;; m-x add-permanent-completion > ;; > ;; UPDATING THE DATABASE FROM A SOURCE CODE FILE > ;; m-x add-completions-from-buffer > ;; Parses all the definition names from a C or LISP mode buffer and > ;; adds them to the completion database. > ;; > ;; m-x add-completions-from-lisp-file > ;; Parses all the definition names from a C or Lisp mode file and > ;; adds them to the completion database. > ;; > ;; UPDATING THE DATABASE FROM A TAGS TABLE > ;; m-x add-completions-from-tags-table > ;; Adds completions from the current tags-table-buffer. > ;; > ;; HOW A COMPLETION IS FOUND > ;; <write> > > ;; > ;; STRING CASING > ;; Completion is string case independent if case-fold-search has its > ;; normal default of T. Also when the completion is inserted the case of the > ;; entry is coerced appropriately. > ;; [E.G. APP --> APPROPRIATELY app --> appropriately > > ;; App --> Appropriately] > > ;; > ;; INITIALIZATION > ;; The form `(completion-initialize)' initializes the completion system by > ;; trying to load in the user's completions. After the first call, further > ;; calls have no effect so one should be careful not to put the form in a > ;; site's standard site-init file. > > > > > -- > Jean > > Take action in Free Software Foundation campaigns: > https://www.fsf.org/campaigns > > In support of Richard M. Stallman > https://stallmansupport.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Abbrev for shorthand purposes 2022-08-10 21:43 ` uzibalqa @ 2022-08-11 3:43 ` Jean Louis 2022-08-11 12:28 ` uzibalqa 0 siblings, 1 reply; 6+ messages in thread From: Jean Louis @ 2022-08-11 3:43 UTC (permalink / raw) To: uzibalqa; +Cc: help-gnu-emacs@gnu.org * uzibalqa <uzibalqa@proton.me> [2022-08-11 00:43]: > > Purpose of abbrevs was not to use them programmatically, but to have > > it handy to quickly add them while writing text. > > I am using them programmatically because I want to implement a specific > scheme for short writing. You can implement it rather by thinking and using Emacs built-in functions. You are inserting them into parenthesis, but you can insert them into parenthesises by using built in Emacs functions as well, without worries. Your file will be saved. You may reuse the information. > Yes I can complete the word "sentimental", but am struggling on how the word can then be > changed to "s--l". For that you do following: - write s--l - put cursor after s--l - Press C-2 C-x a g This is because C-2 or C-u 2 is equivalent of going 2 words back, as s--l probably looks as 2 words to Emacs because of dashes. - insert "sentimental" - when you write sentimental it will expand into s--l That method is faster. -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Abbrev for shorthand purposes 2022-08-11 3:43 ` Jean Louis @ 2022-08-11 12:28 ` uzibalqa 0 siblings, 0 replies; 6+ messages in thread From: uzibalqa @ 2022-08-11 12:28 UTC (permalink / raw) To: Jean Louis; +Cc: help-gnu-emacs@gnu.org ------- Original Message ------- On Thursday, August 11th, 2022 at 3:43 AM, Jean Louis <bugs@gnu.support> wrote: > * uzibalqa uzibalqa@proton.me [2022-08-11 00:43]: > > > > Purpose of abbrevs was not to use them programmatically, but to have > > > it handy to quickly add them while writing text. > > > > I am using them programmatically because I want to implement a specific > > scheme for short writing. > > > You can implement it rather by thinking and using Emacs built-in > functions. You are inserting them into parenthesis, but you can insert them into > parenthesises by using built in Emacs functions as well, without > worries. > > Your file will be saved. You may reuse the information. > > > Yes I can complete the word "sentimental", but am struggling on how the word can then be > > changed to "s--l". > > > For that you do following: > > - write s--l > > - put cursor after s--l > > - Press C-2 C-x a g > > This is because C-2 or C-u 2 is equivalent of going 2 words back, as > s--l probably looks as 2 words to Emacs because of dashes. > > - insert "sentimental" > > - when you write sentimental it will expand into s--l > > That method is faster. Hi Jean, I need the functionality for use with my group, meaning that the list of words and substitutions have to be done programatically, so I can send them the `.el` file. What I would like to have is completion of tho word "sentimental", so writing "sentim" will complete it like company-mode does. Then the more difficult task of replacing with the shortened version (which I currently do with abbrev, user just introduces space just like writing and the replacement happens). People would be writing prose and do not want them have to use key binding input for every word they write. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-11 12:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-08-05 5:31 Abbrev for shorthand purposes uzibalqa via Users list for the GNU Emacs text editor 2022-08-07 0:08 ` kf 2022-08-10 20:30 ` Jean Louis 2022-08-10 21:43 ` uzibalqa 2022-08-11 3:43 ` Jean Louis 2022-08-11 12:28 ` uzibalqa
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.