Joost Kremers <joostkremers@fastmail.fm> writes:
> On Thu, Mar 28 2024, Heime wrote:
>> Reading the emacs manual '24.3 Choosing File Modes'. Is it correct to assert
>> that
>> the file mode is synonymous with the major mode ?
>>
>> https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html
>
> Given that that page talks about both major and minor modes, I'd say no. It
> rather refers to any modes activated for a specific file.
>
> Note that it's hardly an issue. "File mode" does not have any specific meaning
> in Emacs (unlike major and minor mode), so I wouldn't worry about it too much.
> (In fact, going through the manual, there appears to be another use of the term
> "file mode", referring to what is more commonly called "file permissions": see
> (info "(emacs) Misc File Ops").)
Also, the major mode that is in effect for a given buffer may have
nothing to do with ANY file. For example, the *scratch* buffer and Help
buffers have no file associated with them, but both have a major mode.
You can create a new buffer simply by switching to it with C-x b (bound
to ‘switch-to-buffer’):
C-x b a-new-buffer
That buffer will have your default major mode, which is usually
Fundamental mode. You can then change that mode to, for example,
emacs-lisp-mode, by entering the command ‘emacs-lisp-mode’:
M-x emacs-lisp-mode
Your new buffer will now have its major mode changed to one that is
normally associated with Emacs Lisp files and yet still have no
association with any file.
Likewise, you could have a file of Emacs Lisp code associated with a
buffer in emacs-lisp-mode and could change its major mode to, for
example, text mode:
M-x text-mode
In that case, even though your file has Emacs Lisp code, the buffer
associated with it could be operated on as though it was plain text.
(Besides looking at the first field of the Emacs mode line near the
bottom of the screen, it is also possible to determine which major mode
is in effect by evaluating the variable ‘major-mode’, either in a Lisp
expression or by typing C-h v major-mode RET.)
--
Ok, I will refer to Elisp manual and docstrings !
I've noticed there are many comments explaining related concepts
and functionalities.
On Tue, Mar 26, 2024, at 10:56 PM, Stefan Monnier via Users list for the GNU Emacs text editor wrote:
>> This function is requently used for point movement, and "An
>> Introduction to Programming in Emacs Lisp" should mention this point
>> movement behavior.
>
> "An Introduction to Programming in Emacs Lisp" is an introduction.
> Once you've read it and you actually write code, you're expected to
> refer to the ELisp manual and the docstrings.
>
>
> Stefan
On Thu, Mar 28 2024, Heime wrote:
> Reading the emacs manual '24.3 Choosing File Modes'. Is it correct to assert
> that
> the file mode is synonymous with the major mode ?
>
> https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html
Given that that page talks about both major and minor modes, I'd say no. It
rather refers to any modes activated for a specific file.
Note that it's hardly an issue. "File mode" does not have any specific meaning
in Emacs (unlike major and minor mode), so I wouldn't worry about it too much.
(In fact, going through the manual, there appears to be another use of the term
"file mode", referring to what is more commonly called "file permissions": see
(info "(emacs) Misc File Ops").)
--
Joost Kremers
Life has its moments
Reading the emacs manual '24.3 Choosing File Modes'. Is it correct to assert that the file mode is synonymous with the major mode ? https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html
Sent with Proton Mail secure email. On Thursday, March 28th, 2024 at 10:48 AM, tpeplt <tpeplt@gmail.com> wrote: > Heime heimeborgia@protonmail.com writes: > > > I would like to have two commands, one to insert a heading, the other to > > insert a new page in a buffer. So I can easily traverse the code in a buffer. > > > The Emacs function ‘insert’ inserts text into the current buffer: > > (insert &rest ARGS) > > Insert the arguments, either strings or characters, at point. > > A simple function to insert a form-feed character: > > (defun new-page () > "Insert a page separator into the current buffer." > (interactive) > (newline) > (insert ?\f) ;Form feed is \f or Ctrl-l or ASCII 012 > (newline)) That does the job. > ‘insert’ accepts either characters or strings, so it could be used to > define a command that inserts whatever text you want in a heading. > > (newline) > (insert "Header line 1\n") > (insert "Line 2\n") > (insert (format "Parameter is %s.\n" parm)) > > --
Heime <heimeborgia@protonmail.com> writes:
> I would like to have two commands, one to insert a heading, the other to
> insert a new page in a buffer. So I can easily traverse the code in a buffer.
The Emacs function ‘insert’ inserts text into the current buffer:
(insert &rest ARGS)
Insert the arguments, either strings or characters, at point.
A simple function to insert a form-feed character:
(defun new-page ()
"Insert a page separator into the current buffer."
(interactive)
(newline)
(insert ?\f) ;Form feed is \f or Ctrl-l or ASCII 012
(newline))
‘insert’ accepts either characters or strings, so it could be used to
define a command that inserts whatever text you want in a heading.
(newline)
(insert "Header line 1\n")
(insert "Line 2\n")
(insert (format "Parameter is %s.\n" parm))
--
Heime <heimeborgia@protonmail.com> writes:
> Want to display the result of calling 'describe-input-method' based on a user
> selection. But I cannot get the resulting text to be displayed.
>
> (defun razad (uselec)
> (interactive
> (list
> (let ( (cseq '("icelandic-keyboard" "italian-alt-postfix" "icelandic-postfix")) )
> (completing-read
> " Lingu: " cseq nil t "icelandic-postfix"))))
>
> (describe-input-method uselec)
> ;; (call-interactively 'describe-input-method)
>
> )
The resulting text is displayed in a *Help* buffer. Are you not seeing
that result?
Using Emacs version 29.2:
1. Start emacs from a shell prompt:
$ emacs -Q
2. Copy your definition above to the *scratch* buffer and then evaluate
it to define the command ‘razad’.
3. Invoke the command ‘razad’: M-x razad
4. At the prompt " Lingu: icelandic-postfix", accept the default by
pressing RET.
5. A second window is displayed with a *Help* buffer that has the
following contents:
Input method: icelandic-postfix (mode line indicator:IS<)
Icelandic (Íslenska) input method with postfix modifiers
A' -> Á
E' -> É
I' -> Í
O' -> Ó
U' -> Ú
Y' -> Ý
AE -> Æ
OE -> Ö
D/ -> Ð (eth)
T/ -> Þ (thorn)
E= -> €
Doubling the postfix separates the letter and postfix: e.g. a'' -> a'
KEY SEQUENCE
------------
You can input characters by the following key sequences:
key char [type a key sequence to insert the corresponding character]
--- ---- --- ---- --- ---- --- ---- --- ---- --- ---- --- ----
A' Á E' É OE Ö Y' Ý d/ ð o' ó u' ú
AE Æ I' Í T/ Þ a' á e' é oe ö y' ý
D/ Ð O' Ó U' Ú ae æ i' í t/ þ
-- End of *Help* buffer text --
On Thursday, March 28th, 2024 at 7:12 AM, Christopher Dimech <dimech@gmx.com> wrote: > > Sent: Thursday, March 21, 2024 at 4:32 PM > > From: "Stefan Monnier via Users list for the GNU Emacs text editor" help-gnu-emacs@gnu.org > > To: help-gnu-emacs@gnu.org > > Subject: Re: Allowing spaces in the regexp for outlines > > > > > Have made a regexp for outlines to use ';;;' followed by 'H' and a number. > > > > > > I would like to allow any number of spaces between the ';;;' and the letter 'H'. > > > How can I change the regexp to allow such a capability ? > > > > Why? > > > There is already the functionality for changing the font-lock for outline-minor-mode. > So why not ! It is not so easy to do though. Because managing outlines in a buffer > is valuable for almost everybody, it would help for there to me clear explanation > of what has to be done with actual examples. Good for this would be in the Introduction > to Emacs Lisp Programming. That would help a lot. How can one set general patterns for each outline level precisely ? Is the way to do it like this (defvar el-hglevels '( (";;; H1" . 1) (";;; H2" . 2) (";;; H3" . 3) )) (setq outline-regexp (concat (regexp-opt (mapcar 'car el-hglevels)) "\\>")) (setq outline-heading-alist el-hglevels) (setq-local outline-level 'outline-level) > > ELisp already has a set convention for outlining, where `;;;` is > > a top-level heading, then `;;;;` is a subheading, `;;;;;` is > > a subsubheading, etc... > > > > Stefan
> Sent: Thursday, March 21, 2024 at 4:32 PM > From: "Stefan Monnier via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org> > To: help-gnu-emacs@gnu.org > Subject: Re: Allowing spaces in the regexp for outlines > > > Have made a regexp for outlines to use ';;;' followed by 'H' and a number. > > > > I would like to allow any number of spaces between the ';;;' and the letter 'H'. > > How can I change the regexp to allow such a capability ? > > Why? There is already the functionality for changing the font-lock for outline-minor-mode. So why not ! It is not so easy to do though. Because managing outlines in a buffer is valuable for almost everybody, it would help for there to me clear explanation of what has to be done with actual examples. Good for this would be in the Introduction to Emacs Lisp Programming. > ELisp already has a set convention for outlining, where `;;;` is > a top-level heading, then `;;;;` is a subheading, `;;;;;` is > a subsubheading, etc... > > > Stefan > > >
Hello, I’d like to send a multipart/form-data HTTP POST request with ‘url-retrieve-synchronously’ which should be equivlent to this cURL request: #+begin_src shell curl -X POST \ -H "Content-Type: multipart/form-data" \ --form file="@/tmp/x.png" \ http://127.0.0.1:8898/ #+end_src My current elisp function: #+begin_src elisp (defun xtest/http-post-multipart-boundary () "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") (defun xtest/http-post (url data extra-headers) (let ((url-request-method "POST") (url-request-data data) (url-request-extra-headers extra-headers)) (let (header data status) (with-current-buffer (url-retrieve-synchronously url) (setq status url-http-response-status) (goto-char (point-min)) (if (search-forward-regexp "^$" nil t) (setq header (buffer-substring (point-min) (point)) data (buffer-substring (1+ (point)) (point-max))) (setq data (buffer-string)))) (list (cons 'data data) (cons 'header header) (cons 'status status))))) (xtest/http-post "http://127.0.0.1:8898" ;; Data: (format "%s%s%s%s\r\n" "Content-Disposition: form-data; name=x; filename=x.png\r\n" "Content-type: image/png\r\n" (with-temp-buffer (insert-file-contents-literally "/tmp/x.png") (buffer-substring-no-properties (point-min) (point-max))) (format "--%s--" (xtest/http-post-multipart-boundary))) ;; Extra Headers: `(("Content-Type" . ,(format "multipart/form-data; boundary=%S" (xtest/http-post-multipart-boundary)) ))) #+end_src (this is a simplified version of my original code - I tried to reconstruct the problem with a simpler version. My original elisp defuns are a bit larger and based on [4]) The problem: With this code in place, I get an error message: "Multibyte text in HTTP request: [..]" As far as I can see, it is generated at Line 416 in url-http.el [1]. When I remove this length check, everything works as expected and I can POST binary data (image/png in my case) to the remote server. My questions: Am I doing something wrong with the encoding of the binary data? Is this length check in line 416 at [1] really correct when sending binary data? Is there a simpler way with native emacs functions to send multipart/form-data with POST? [1] https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/url/url-http.el#n416 [2] The bug report when the lines were introduced: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23750 [3] The git-commit a98aa02a5dbf079f7b4f3be5487a2f2b741d103d: https://git.savannah.gnu.org/cgit/emacs.git/commit/lisp/url/url-http.el?id=a98aa02a5dbf079f7b4f3be5487a2f2b741d103d [4] https://www.emacswiki.org/emacs/http-post-simple.el -- Christian Barthel
How can I ensure that the text strings from completing-read are properly transformed to the symbols required by outline-minor-mode-highlight ? (defun outl-flock (actm) "Set font-lock rules for 'outline-minor-mode'. (interactive (let ( (cseq '("append" "t" "nil" "override")) ) (list (completing-read "Font-Lock Rules: " cseq nil t "override")))) (setq outline-minor-mode-highlight (if (equal actm "t") t (intern actm))) )
Hi All While I am quite happy with character composition using ligature.el, there is one particular feature that would like to see. Some programming languages reuse certain character sequences in different contexts. E.g. in Verilog the character sequence “<=” could be an assignment operator or a less-or-equal operator, depending on the context. The latter should be composited using the ligature for “less than or equal to”, while in the former case I'd rather get a fancy arrow ligature (ideally) or no ligature at all. Is there any way to achieve this? Cheers, Marcus
Tim Landscheidt <tim@tim-landscheidt.de> writes:
>
>>>> 1. Is there an idiom in Emacs Lisp for writing this that
>>>> eliminates this warning?
>
>>> (dotimes (_ 100)
>>> (insert "I will not obey absurd orders\n"))
>
>>> Or any other var name that starts with an underscore.
>
>> Thank you. I have not been able to find this documented anywhere (that
>> is, that lexical variables whose names begin with an underscore are not
>> flagged with a warning message if they are not referenced). This
>> appears to be true with, for example, ‘let’ expressions, also.
>
> It is mentioned in the GNU Emacs Lisp Reference Manual (C-h
> i g (elisp) RET) in the node "Converting to Lexical
> Binding":
>
> | […]
>
> | A warning about an unused variable may be a good hint that the
> | variable was intended to be dynamically scoped (because it is actually
> | used, but in another function), but it may also be an indication that
> | the variable is simply really not used and could simply be removed. So
> | you need to find out which case it is, and based on that, either add a
> | ‘defvar’ or remove the variable altogether. If removal is not possible
> | or not desirable (typically because it is a formal argument and that we
> | cannot or don’t want to change all the callers), you can also add a
> | leading underscore to the variable’s name to indicate to the compiler
> | that this is a variable known not to be used.)
>
> | […]
>
Again, thank you. This will be useful knowledge in future instances of
variables that have to be declared, but are not referenced.
--
(anonymous) wrote: >>> 1. Is there an idiom in Emacs Lisp for writing this that >>> eliminates this warning? >> (dotimes (_ 100) >> (insert "I will not obey absurd orders\n")) >> Or any other var name that starts with an underscore. > Thank you. I have not been able to find this documented anywhere (that > is, that lexical variables whose names begin with an underscore are not > flagged with a warning message if they are not referenced). This > appears to be true with, for example, ‘let’ expressions, also. It is mentioned in the GNU Emacs Lisp Reference Manual (C-h i g (elisp) RET) in the node "Converting to Lexical Binding": | […] | A warning about an unused variable may be a good hint that the | variable was intended to be dynamically scoped (because it is actually | used, but in another function), but it may also be an indication that | the variable is simply really not used and could simply be removed. So | you need to find out which case it is, and based on that, either add a | ‘defvar’ or remove the variable altogether. If removal is not possible | or not desirable (typically because it is a formal argument and that we | cannot or don’t want to change all the callers), you can also add a | leading underscore to the variable’s name to indicate to the compiler | that this is a variable known not to be used.) | […] Tim
Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
>> 1. Is there an idiom in Emacs Lisp for writing this that
>> eliminates this warning?
>
> (dotimes (_ 100)
> (insert "I will not obey absurd orders\n"))
>
> Or any other var name that starts with an underscore.
>
>
> Stefan
Thank you. I have not been able to find this documented anywhere (that
is, that lexical variables whose names begin with an underscore are not
flagged with a warning message if they are not referenced). This
appears to be true with, for example, ‘let’ expressions, also.
--
> 1. Is there an idiom in Emacs Lisp for writing this that
> eliminates this warning?
(dotimes (_ 100)
(insert "I will not obey absurd orders\n"))
Or any other var name that starts with an underscore.
Stefan
Consider a file that contains the following lines only:
┌───────────────────────────────
│;; -*- lexical-binding: t; -*-
│
│(dotimes (i 100)
│ (insert "I will not obey absurd orders\n"))
└───────────────────────────────
(Example from the Emacs Lisp manual.)
When this file is byte-compiled, the compiler will issue a warning:
> Warning: Unused lexical variable `i'
The following change could be used to eliminate this warning:
(dotimes (i 100)
(null i)
(insert "I will not obey absurd orders\n"))
1. Is there an idiom in Emacs Lisp for writing this that
eliminates this warning?
2. Should the compiler be changed so that it does not issue this warning
for ‘dotimes’ and ‘dolist’, where declaring the variable required,
but use of the variable is optional?
--
Hello, I am trying to a simple interface using the vtable package. I would like the background colour of each row to depend on the value of its underlying object (e.g. the row should have a green background if the foo field of the object it represents is 1, otherwise it should have a plain white background). I am a beginner in emacs-lisp and am wondering what the best way to do this is. The :displayer parameter to the vtable takes the formatted string of the text only so it wouldn't affect the background for the whole row. The :row-colors parameter takes a list and not a function, so I'm a bit stuck on updating it properly. I tried to set :row-colors to be the value of a global variable which is set by my :objects-function function, but now when updating the table, the colours become out of sync. Thank you
Sent with Proton Mail secure email.
On Wednesday, March 27th, 2024 at 1:56 AM, Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> > This function is requently used for point movement, and "An
> > Introduction to Programming in Emacs Lisp" should mention this point
> > movement behavior.
>
> "An Introduction to Programming in Emacs Lisp" is an introduction.
> Once you've read it and you actually write code, you're expected to
> refer to the ELisp manual and the docstrings.- Stefan
Moving from "Introduction to Programming" to "ELisp Reference Manual"
is a climb too steep. Would help if there was an Abbreviated Guidebook
at an intermediate level. Then the task of moving from the Abbreviated
Guidebook to the Reference Manual would be reasonable.
> This function is requently used for point movement, and "An
> Introduction to Programming in Emacs Lisp" should mention this point
> movement behavior.
"An Introduction to Programming in Emacs Lisp" is an introduction.
Once you've read it and you actually write code, you're expected to
refer to the ELisp manual and the docstrings.
Stefan
> messy etc., but I don't care about such issues -- I just want to know
> how many lines are actually visible in the current window.
(count-lines (window-start) (window-end))?
Stefan
I would like to have two commands, one to insert a heading, the other to insert a new page in a buffer. So I can easily traverse the code in a buffer.
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --] On Fri, Mar 22, 2024 at 08:56:37AM -0500, Robert Boyer wrote: > Could some kind soul give me a line like the following, but one that > includes 'auto-revert tail' and 'display-line'? > > ;;; -*- Mode: auto-revert -*- Ah, this is not what usually is called the "mode line". The mode line is that line outside your text which indicates which mode the buffer you see is currently "in" (I'm saying that because I was first misled when I read your subject line). Now to your problem: you set a major mode for a file in the above way. That's because a major mode is more closely related to the kind of file. But auto-revert mode is a minor mode. This one is more related to how you, the user, do things. You might set it with ;;; -*- eval: (auto-revert-mode 1) -*- (before that you may set a major mode). But it is recommended against, since you'd force other users of your file to adopt your customs :-) See chapter 25 "Major and Minor Modes" of the fine manual, especially 25.3 "Choosing File Modes" for all the gory detail. Cheers -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --]
> I could not find where to report this proposal about "An
> Introduction to Programming in Emacs Lisp". Does someone have any idea
> how to propose modification to the introduction?
`M-x report-emacs-bug'
That's also for enhancement requests and suggestions.
I want to try foldout to navigate through elisp outline headings using the mouse. What would I need to do ? Have been looking for the source code but could not find it.