texts: Git pull from/push to a specific branch with magit commands in elisp

texts:
When I run magit commands through the magit interface it runs those commands relative to the branch/repository I am currently visiting. However, I am trying to write some code in my config file that will automatically push to or pull from a specific repo, and am not sure how to format magit commands in elisp.

For example, the documentation for magit-pull-from-upstream says:

  Pull from the upstream of the current branch.

But what determines the current branch, and how can I specify it? magit-push-current-to-upstream similarly mentions the "current branch".

What I am looking for is a way to call these commands from my config file in elisp code (or similar commands, if these are not the appropriate ones) while specifying which branch of which repo to pull from/push to. Thank you!


texts:
Note that I'm using a theme (not sure if that changes things).
I have
(set-cursor-color "White")

But my cursor is still yellow.


texts: How can I fill-paragraph a string according to its value rather than its input syntax?

texts:
I have a docstring to a simple function, but the docstring uses many escape sequences to explain the reasoning for the function.

(defun sx-encoding-normalize-line-endings (string)
  "Normalize the line endings for STRING.

The API returns strings that use Windows-style line endings.
These are largely useless in an Emacs environment.  Windows uses
\"\\r\\n\", Unix uses just \"\\n\".  Deleting \"\\r\" is
sufficient for conversion."
  (delete ?\r string))

The docstring evaluates to

Normalize the line endings for STRING.

The API returns strings that use Windows-style line endings.
These are largely useless in an Emacs environment.  Windows uses
"\r\n", Unix uses just "\n".  Deleting "\r" is
sufficient for conversion.

Note that the next-to-last line is needlessly short; 'sufficient' can be put onto the preceding line.  Even 'for' fits:

The API returns strings that use Windows-style line endings.
These are largely useless in an Emacs environment.  Windows uses
"\r\n", Unix uses just "\n".  Deleting "\r" is sufficient for
conversion.

How can I reach Emacs to fill according to the value of the string rather than its input syntax?

I have a solution sketch for this, but I'm having trouble implementing it.

Check to see if we're inside a string literal:

 (unless (nth 3 (syntax-ppss))
   (user-error "Not inside a string literal"))

Evaluate the string.  re-search-forward for [^\\]" (string version: "[^\\\\]\"").  Use eval-last-sexp and insert the result into a temporary buffer.
Record line endings.  Push onto a list every point where char-at-point is a new line.  Start at point-max to keep the list sorted.
Returning to the original string, insert the line breaks where they're needed and remove them where they do not align with the list created.

Alternatively, just evaluate the string into a temp buffer, fill it, replace instances of " with \", and bring that string back in to replace the old one.


texts: Create strings of a wordlist using replace-regexp

texts:
I have a word list with a lot of words that I want to convert into a json file. To do this I need to make them strings and add a comma in the end of all words. I figured it would be nice to use regular expression to do this and I know about replace-regexp. What I have tried to do this, beginning with the file:

This
Is
An
Example

To match each word I use ^([A-Za-z]+)$. I have tried it in https://regex101.com/ and it seems to work the way as expected. But how do I actually use these matches to add a " in front and back of each word to make strings of them?

"This"
"Is"
"An"
"Example"

I can not find in the documentation how to actually use the matches to add more characters.

Edit: After reading https://www.emacswiki.org/emacs/RegularExpression and experimenting with regex101 I found that the words is group 1, so "\1", (added a comma just to complete the json structure) should work, but it does not

Edit2: Just a more clear example of one of the most promising tries: replace-regexp <RET> ^([A-Za-z]+)$ <RET> "\1",


texts:
I have placed my autosave and backup files in a single directory .emacs-saves.

Backup files appear as ~foo

Autosave files appear as #foo#

But Emacs seems to also generate .#foo in the current directory whenever a change is made in a buffer.

What's the purpose of these files and is there a way to specify their default directory?


texts: How to open new buffer instead of current via elisp?

texts:
I want to bind key when in ido-switch-buffer to open ibuffer instead, but I do not understand how to make that with elisp. Here's my config:

(defun my-open-ibuffer ()
  "Open ibuffer from ido-switch-buffer"
  (interactive)
  (minibuffer-keyboard-quit)
  (ibuffer-other-window))

(defun bind-ido-keys ()
  "Keybindings for ido mode."
  (define-key ido-completion-map (kbd "C-H-S-c") 'my-open-ibuffer))

(add-hook 'ido-setup-hook #'bind-ido-keys)

It looks like when I call (minibuffer-keyboard-quit) to close ido-minibuffer function stops evaluating and not running next (ibuffer-other-window) that should open ibuffer. If I comment out (minibuffer-keyboard-quit) it works as supposed - open new ibuffer window with not closed minibuffer. But I want minibuffer to be closed, and config described above only closes minibuffer and not triggering ibuffer opening.


texts: How to pass multiple arguments to hc-highlight-chars?

texts:
How do you pass arguments to a function using lambda? I have looked through: https://www.gnu.org/software/emacs/manual/html_node/elisp/Argument-List.html#Argument-List
and
https://www.emacswiki.org/emacs/download/highlight-chars.el
The only examples I found in the 2nd link were for tabs and whitespaces which use functions requiring no arguments.
Here's what I have tried so far:

1.

  (require 'highlight-chars)
  (defun my:add-semi-colon-highlighting ()
    (add-hook 'font-lock-mode-hook
              (lambda () (hc-highlight-chars ";" "highlight"))))

  (add-hook 'c-mode-common-hook 'my:add-semi-colon-highlighting)

2.

  (require 'highlight-chars)
  (defun my:add-semi-colon-highlighting ()
    (add-hook 'font-lock-mode-hook
              (lambda () (hc-highlight-chars (";","highlight")))))

  (add-hook 'c-mode-common-hook 'my:add-semi-colon-highlighting)

3.

  (require 'highlight-chars)
  (defun my:add-semi-colon-highlighting ()
    (add-hook 'font-lock-mode-hook
              (lambda () (hc-highlight-chars ";" highlight))))

  (add-hook 'c-mode-common-hook 'my:add-semi-colon-highlighting)

Not sure if this should go into another question or not, but if wanted to customize the face for ";" (E.g red foreground and current background), how would I do that in the my:add-semi-colon-highlighting function?


texts: Strategy for proper version control of "auto-filled" text files

texts:
I like auto-fill-mode a lot because it makes text fit into my screen even when I have two buffers side-by-side.
My problem is that a small wording change may trigger auto-fill to reformat a whole paragraph, and that doesn't play well with version controlling, i.e., git.

I can't track my small changes anymore, because the whole paragraph is changed.

I was wondering if anyone has a suggestion on how to deal with this problem.
Is there a "visual-auto-fill", which doesn't take care of newlines but just visually displays text in a proper manner?

Since I plan to export files to LaTeX and HTML, I don't care if there are no newlines at all in the saved document.


texts: Define a main window and then close all others

texts:
With the way I work, I often just want one window (what's showing my code). Now several things (like opening help) open another window. That's fine, but when I'm finished I just want all windows closed and to return to the original.

Often Q will get me out of something, But not every time. I want a consistent shortcut to 'close all but the main window'

delete-other-windows is close to what I'm looking for, but I've obnoxiously been focusing the wrong window when utilizing it.

Is there a way to tag a window (say on startup of a frame, tag the first window), and then close all other windows besides that one? I don't want to think about where I'm currently focused.


texts: Searching for org-tags programmatically (without regexp)?

texts:
The function org-tags-view allows you to build up semi-complex searches for tags using regexp:

(org-tags-view t "+PROP1={value}&+PROP2={[1-2]}")

However, regexp is very limited. Is there a way to search using some sort of matcher function that can, i.e., inspect an org header's properties, do some computations on them, and returns t or nil depending upon whether the computation matches in the way I specify?


texts: Setting the major mode of a new buffer interactively

texts:
When creating a new buffer via:

C-x b
NonExistentBufferName RET RET

I would like Emacs to prompt me for the major mode this buffer is going to use upon opening.
Moreover, I want Emacs to infer the major mode in some cases based on the buffer's name:

C-x b
test.org(no such buffer/file so far) RET RET
=> org-mode is used without asking me anything.

Could anybody advice on how I can achieve this? Package or, probably, just pure elisp with its hooks and advice?

P.S.
I'm using ido if it matters.


texts: making specific regions of a buffer read-only

texts:
I know it's possible to make a "portion" of a buffer read-only. As an effect, the whole line becomes uneditable.
What I would like it to make a specific region uneditable, for exemple a rectangle region :

- item n°1 (uneditable) : "editable part 1"
- item n°2 (uneditable) : "editable part 2"
- and so on.

I'm pretty sure it's something customizable but I'm not well acquainted with elisp yet. Thanks for your insights.


texts: Evil-mode remap universal-argument to C-f in normal-mode, without weird C-u behavior

texts:
This .emacs file is sufficient to reproduce the problem.

(package-initialize)
(setq evil-want-C-u-scroll t)
(require 'evil)
(define-key evil-normal-state-map (kbd "C-f") #'universal-argument)
(evil-mode +1)

However, when I am applying multiple consecutive universal arguments while in normal mode, C-u is being treated as universal-argument (which is inappropriate). I can stack both C-u and C-f and get C-f C-f C-u C-f C-f in my modeline. The semantics appear to be the same 4^[number of universal argument things], but I'd like to disable this unwanted behavior and use just C-f for universal argument in normal mode.

EDIT:

So it turns out what is actually happening is that after C-f the universal-argument-map is invoked and in that map the C-u key is bound to universal-argument. It looks like the purpose of this map and the related transient mode universal-argument--mode is to enable digits and - to modify the universal argument after C-u has been pressed.

It seems like any solution to this problem would involve defining a function similar to universal-argument and binding C-f to that.

EDIT:

wasamasa's suggestion works great, but this is what I've settled on so as to avoid modifying the behavior of evil-emacs-state (or when evil-mode is deactivated)

(defvar normal-mode-universal-argument-map universal-argument-map
  "swap C-f and C-u in universal-argument-map")
(define-key normal-mode-universal-argument-map (kbd "C-u") nil)
(define-key normal-mode-universal-argument-map
  (kbd "C-f") #'universal-argument-more)

(defun normal-mode-universal-argument ()
  "universal-argument with C-f and C-u swapped"
  (let ((universal-argument-map normal-mode-universal-argument-map))
    (universal-argument)))


texts: What does dependency mean in the Status field of a package shown in list-packages

texts:
The command list-packages shows the list of available packages.
A Status column appears with several possible values:

available
installed
dependency
built-in
incompat

And the packages seem to be listed by those Status values alphabetically.
I think I understand what available, installed, built-in and incompat mean.

But, what does dependency means?


texts: hl-line-mode hide background, how to avoid this?

texts:
With:

(when window-system
  (set-face-background 'hl-line "light yellow")
  (global-hl-line-mode 1))

current line highlighted by yellow background, but if text has background properties it also overwritten (like diff-mode, rainbow-mode).

Is it possible to set background only for parts that have no appropriate properties?

UPDATE I start experimenting, seems that stipple isn't conflicting with background:

(set-face-stipple 'hl-line '(4 4 "\x01\x00\x00\x00"))
(set-face-attribute 'hl-line nil :inherit nil)

But stipple unfortunately damage text appearance...


texts: move focus between sub-windows (or buffers?) with ctrl-tab?

texts:
Currently using GNU Emacs 23.1.1.

I've used xemacs since the late 90s and am only now switching to proper emacs.

If I had my xemacs window split into a top buffer and bottom buffer, I could move the keyboard focus between them with ctrl-tab.  (I cannot remember if that's something I wrote myself 20+ years ago, or was a standard mapping, but checking my config files I don't think I wrote it myself.)

There are similar questions about rotating between buffers, but, I think, keeping the focus in the same sub-window.  That's not my question, but just to be clear, the following is something I find very useful but isn't what this current question is asking.  I probably have the wrong terminology, but the following code changes the buffer within the current sub-window.  Instead I want to leave all the sub-windows looking at their current buffers, and instead move focus to the next sub-wind.

  (defun switch-to-next-buffer ()   (interactive)   (switch-to-buffer
  (other-buffer)))


texts: How to fix "Symbol's function definition is void: org-babel-get-header"

texts:
How do you trouble shoot this? (trying to run a sh block async)

#+BEGIN_SRC sh
/tmp/7.sh
#+END_SRC

Then I do

C-c C-c

I get

Symbol's function definition is void: org-babel-get-header

My setup

prelude emacs25 org installed

;; my ~/prelude/personal/personal.el
(prelude-require-package 'ob-async)
(require 'ob-async)
(setq org-confirm-babel-evaluate nil)

(org-babel-do-load-languages
 'org-babel-load-languages
 '(
   (sh . t)
   (ruby . t)
   ))


texts: How to make Dragon Naturally Speaking work with multiple MS Windows users?

texts:
I'm attempting to use Dragon Naturally Speaking (15.3) to dictate into Emacs (version 26.3). I have two accounts using Windows 10 on the same laptop. From one account, Dragon inserts text into Emacs with no problems. However, on the other account Dragon only accepts commands.
I have tried:

using dictation box and unselecting "Use dictation box with unsupported applications." under options>misc.

creating a new user profile from scratch from the account that can't use dragon with emacs

Opening Emacs with emacs -q or emacs -Q has no effect. It still works from the account it works from and doesn't work from the other.
The problem appears deeper than emacs. Here's a summary:
Account B: no problems
Account A works with: Google chrome including Google docs, notepad, entering commands with Emacs.
Doesn't work with: editing text in Emacs, libreoffice writer, the Windows command line.


texts: How can I increase the identation in org-mode lists?

texts:
I would like to use more than two spaces for list indentation. I've had a look at the documentation, but I couldn't find a variable for that. Instead of this:

 - First
   - First
   - Second
 - Second
   - First

… I would prefer this indentation for better legibility of the indentation levels:

 - First
     - First
     - Second
 - Second
     - First


texts: org-preview-latex-fragment in higher resolution

texts: On a high res display, these latex fragments created by C-c C-x C-l are noticeably blurry compared to the text. I gather that they are processed with imagemagick--how can I tweak it to output higher res images?


texts: Editing odf - libreoffice/word documents in emacs

texts:
Does emacs support editing odf.odt, that is open document format files? There are some odf2org convertors available like python odt2org.py. On running the command python odt2org.py xyz.odf.odt, it crashes like,

File "/home/sk/src/odt2org/odt2org.py", line 105, in <module>
    _list, _extra = _odtfile.gen_list()
  File "/home/sk/src/odt2org/odtfile.py", line 266, in gen_list
    _list = self.process_tables(_list)
  File "/home/sk/src/odt2org/odtfile.py", line 441, in process_tables
    _txt += _m['text'] + ' '
KeyError: 'text'

so, odf to org mode is the way to go (or) emacs has any plugins for directly loading odt type documents


texts: Do I still need GNU ELPA if I have MELPA?

texts:
This has always confused me, since people are saying that MELPA does have newer versions of packages, but it's not really clear, if GNU ELPA is just a subset of MELPA, or if I do need both?

The reason why I'm asking is that I'm experimenting with my packages a lot, and package-list-packages takes quite a while. I'm aware of package-list-packages-no-fetch, but more often than not I'd like to get the most recent package list.

So the question is, can I just use MELPA and get the same (and possibly newer versions) packages as if I used both MELPA and GNU ELPA?


texts:
How do I append two lists together, and delete duplicates?

For example:

(setq list1 ("a" "b" "c"))
(setq list2 ("b" "c" "d"))

(setq list3 (a b c))
(setq list4 (c d e))

;; use case
(append-list-to-list list1 list2) ; ("a" "b" "c" "d")
(append-list-to-list list3 list4) ; (a b c d e)

UPDATE after the cl-union answer: I need to preserve the order of the resulting list.

And when there is a nested list, how do I append and make element is unique in list.

For example:

(a (b c) d) or ((a b) c d) etc
add list (x y z) to list ((a b) c d) to become ((a b x y z) c d)

Then how to append a new list to upper nested list?


texts: How to search for files from a root directory and get the results as a dired buffer?

texts:
I have a directory which contains directories with many music albums, and I'm doing a selection of songs according a list I found on the Internet. What I'm doing is splitting windows with the destination directory on the left, and the root directory of my music collection on the right. Sadly, I have to manually search for the song among many directories and subdirectories.

So, I was wondering if there was a way to do a recursive search by term and have the results in a dired buffer, enabling me to operate over them as I would normally do in dired.

Any idea on how to achieve this?


texts:
I've read the org-capture template documentation and searched for "Dynamic org-capture templates" but cannot seem to find out how to create the following:

C-c c
"a"
Activity: math              (<--need completion here)
Topic: multiplication       (<--need completion here)
Date: 2017-09-11            (<--need default to todays date)
Start time: 07:00 AM        (<--need to define AM/PM easily)
Duration: 20                (<--easier way to capture time?)
Unit: mins

Whereas if another Activity was chosen, the Options would be different:

C-c c
"a"
Activity: physical education
Type: Yoga
Class: Level 2 flow
Date: 2017-09-11
Start time: 07:00 AM
Duration: 90
Unit: mins

Where in an org-capture-template can I specify the Activity to Option mapping?

How can I use completion to make capturing the data quicker?


texts: Emacs report a process which does not exist

texts:
When start Emacs from the terminal as

 me@mbp: ~$ emacs --deamon

It prompts that

However, there does not exist  such a pocesses

me@mbp~$ ps 8559
  PID TTY      STAT   TIME COMMAND
me@mbp:~$ ps -el |grep 8559

Why could pop such a prompt

There is a file

 -rw-r--r--   1 me me     4 Jan 16 14:44  .emacs.desktop.lock

should I delete it ?


texts: Electric indent: Inserting blank lines with no whitespace while keeping cursor indented?

texts:
I do a lot of python coding and am trying to determine if electric indent can be customized to help me with the following scenario:

Let's say my cursor (point) is at the end of the following excerpt, at the 'X':

if (some_condition):
    do_something()
    and_do_something_else()X
return

If I hit RET, the cursor is moved to the next line immediately below the 'a'. Great. BUT... if all I want to do is insert a blank line, I will quickly move point somewhere else, and then some unwanted whitespace is left in the empty line:

if (some_condition):
    do_something()
    and_do_something_else()X
.... # <-- unwanted whitespace left here
return

Binding RET to electric-indent-just-newline does not give me what I want, because that causes the cursor, in this scenario, to go to column 0.

I guess what I'm looking for is a clean way to:

Automatically move the cursor to the same level of indentation as the previous line if I hit RET, BUT
If the subsequent line just needs to be a newline / blank line, don't
poop it up with whitespace.

Or do I need to resort to calling the function that deletes trailing whitespace?

Please let me know if I need to clarify the problem I'm trying to solve.


texts: How can I get the tag value associated with a current custom variable?

texts:
I've got a custom variable defined:
(defcustom monorail-search-mode :issues-open
  "Current search mode for queries (controls whether we're searching all issues,
open issues, new issues, etc)"
  :type  '(choice
           (const :tag "All Issues"             :issues-all)
           (const :tag "Open Issues"            :issues-open)
           (const :tag "Open & Owned by Me"     :issues-open-owned)
           (const :tag "Open & Reported by Me"  :issues-open-reported)
           (const :tag "Open & Starred by Me"   :issues-open-starred)
           (const :tag "Open & Commented by Me" :issues-open-commented)
           (const :tag "New Issues"             :issues-new)
           (const :tag "Issues to Verify"       :issues-to-verify))
  :group 'monorail)

I'd like to be able to get the :tag value for the currently set value of monorail-search-mode for display purposes, but don't see any easy way to do it.  Is there one?


texts: Can magit pull hunks from another commit into my branch?

texts: I have a big commit on another git branch. I'd like to "cherry-pick" some hunks from that commit into my current branch. I bet magit can do that, but I'm not sure how. Anyone? (I've seen ways to cherry-pick whole commits, but I want to do it hunk by hunk.)


texts:
I have in my startup init file a setting:

(setq tags-table-list (list "~/linux/TAGS"))

After using emacs and TAGS tables, I now want to change that to:

(setq tags-table-list (list "~/trunk/TAGS"))

However, the old linux TAGS are still being used in addition to the new trunk.

How can I expunge the old TAGS table?  I tried also deleting the buffer, but it just gets reloaded.


texts: How to pass a parameter together with function

texts:
This code opens 1-st & 2-nd bookmarks when 1 & 2 keys are pressed on bookmarks page:

(defun jump-to-n-th-bookmark (n)
  (let ((bookmarks (sort (bookmark-all-names) 'string<)))
    (bookmark-jump (nth n bookmarks))
    )
  )

(defun jump-to-1th-bookmark ()
  (interactive)
  (jump-to-n-th-bookmark 0))

(defun jump-to-2nd-bookmark ()
  (interactive)
  (jump-to-n-th-bookmark 1))

(defun my-bookmark-mode ()
  (define-key bookmark-bmenu-mode-map (kbd "1") 'jump-to-1th-bookmark)
  (define-key bookmark-bmenu-mode-map (kbd "2") 'jump-to-2nd-bookmark))

(add-hook 'bookmark-bmenu-mode-hook 'my-bookmark-mode)

Can we get rid of jump-to-1th-bookmark and jump-to-2nd-bookmark functions and have something like this:

(defun my-bookmark-mode ()
  ;pass a parameter together with function
  (define-key bookmark-bmenu-mode-map (kbd "1") 'jump-to-n-th-bookmark 0)
  (define-key bookmark-bmenu-mode-map (kbd "2") 'jump-to-n-th-bookmark 1))


texts: Org-ref: citation link cannot be completed when default org-ref bibliography

texts:
I use org-mode to write journal papers, cite with org-ref, and export to latex. I used to specify individual bibliography in every org document in the bibliography: section, then use C-c C-e l o to export to latex pdf, and it worked all fine.

Now I want to use a default bibliography that is not specified in the bibliography:". But when I export the file, there is not inline citation or reference list in the pdf.

Specifically, this is how I configured in the init.el file (almost the same as in the manual...):

  (setq org-latex-pdf-process
'("pdflatex -interaction nonstopmode -output-directory %o %f"
  "bibtex %b"
  "pdflatex -interaction nonstopmode -output-directory %o %f"
  "pdflatex -interaction nonstopmode -output-directory %o %f"))

 ;; ;; set default library
(setq reftex-default-bibliography '("~/Dropbox/bibliography/papers3.bib")
org-ref-default-bibliography '("~/Dropbox/EntResearch/bibliography/papers3.bib"))

I did use the code from https://stackoverflow.com/questions/2266905/emacs-is-ignoring-my-path-when-it-runs-a-compile-command/2566945#2566945 to solve the issue when the error about not finding pdflatex was thrown out. I'm not sure if it has anything to do with my current issue.

  (defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
(replace-regexp-in-string "[[:space:]\n]*$" ""
  (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
  (setenv "PATH" path-from-shell)
  (setq exec-path (split-string path-from-shell path-separator))))
      (when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))

In my document body, there is no "bibliography:" line, but the bibliographystyle is specified and works fine. In fact, if I use C-c ], I can locate and cite any reference in the default bibliography file. The problem is that they all disappear when exported to pdf.
So is it always required to indicate the path of default bibliography in the text, or is there something I missed?


texts: Problems with org-ctrl-c-ctrl-c and Org 9.0

texts:
I recently installed Org 9.0 and ‘org-ctrl-c-ctrl-c’ often complains about
user-error: ‘C-c C-c’ can do nothing useful here. However when I use it repeatedly it works suddenly, although I didn't change anything ?


texts:
When I try to use auto-completion with lsp + rust-analyzer, all functions inserted like that:
shared_state.clone_from(${1:source})$0

I cannot find any way to disable this "arguments". I don't even understand what package is inserting this (I use prelude bundle + company). Replacing rust-analyzer with rls as language server helps, at least it looks like:
shared_state.clone_from

when I hit "Enter", which is better, cuz I don't need to remove anything.
Any advise or help would be much appreciated, thx.
Update 1
Okay, I looked at lsp log, and seems like this (${1:source})$0 is raw response from rust-analyzer. So now I need to think a way to convert this representation to something, what, I suppose company, will be able to use.


texts: Where should I put a custom theme in Aquamacs?

texts:
I found a vivid chalk color scheme here that I want to use with Aquamacs.  After poking around, I discovered that Aquamacs stores its custom color schemes here:

/Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/
color-theme-library.el

That file contains the color schemes that I see when I do:

M-x custom-schemes

I don't really feel like messing around with that file.  The Aquamacs Preferences.el file is in the directory:

 ~/Library/Preferences/Aquamacs Emacs$

Can I store third party custom themes in that directory somehow?


texts: Semantic way to export Org subtrees inside arbitrary LaTeX environments

texts:
I would like to begin taking math class notes in Org mode -- I have thus far used plain LaTeX, but I have found Org has the potential to be much faster for real-time scribing. I already made a custom export class that links to my scribe document class.

I would like to be able to use an Org object (e.g. property, tag) to indicate an environment within which a subtree should be exported. As I show below, this is quite useful for theorem-like environments.

Having to use source blocks or literal LaTeX environments within my Org document annuls much of Org's value for fast, reviewable math notes. I think it would be much better to write this subtree:

* Cosets
** Lagrange's Theorem :theorem:
If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
*** :proof:
Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...

And get this LaTeX out:

\section{Cosets}
\begin{theorem}[Lagrange's Theorem]
  If $G$ is a finite group and $H$ is a subgroup of $G$, then $|H|\mid|G|$.
\end{theorem}
\begin{proof}
  Let $a_1H, a_2H, \cdots, a_rH$ denote the left cosets of $H$ in $G$...
\end{proof}

There are some caveats here, most notably that we must know whether the entire subtree should be wrapped in the environment, or just the content accompanying the subtree's root headline. Minimally, I would like to identify an environment by a headline tag of the same name and set the title passed into the environment to the headline text (where applicable).

Note that I am taking the idea beyond that given in org-mode special blocks latex attribute. The solutions found in Org-mode latex environment in drawer still feel hacky, although the custom link approach is almost there. I want this environmenting to feel as native and Org-semantic as possible.

I don't see any high-level Org functions for wrapping subtrees as I have described. From what I can see, ATTR_LATEX doesn't fit the bill. Thus, I would derive an export backend with a transcoder that does the subtree wrapping, as well as define some other options (like course and professor) that will be exported. I would have a list of valid environment tags that would be active only in a notes Org file -- maybe a minor mode to encapsulate that.

I'm not asking for coding help, but I would like to know if I am I going about this the right way. I've been at Org for two months or so, and it seems to this newbie that if functionality as clearly useful as semantic environmenting hasn't been implemented, it's probably for a good reason.

I have specific questions:

Is there some Org mode functionality that I have overlooked that would make this or a similar idea very easy?
Are tags the best way to indicate an environment for a subtree as I have described?

Of course, I could just use outline-minor-mode or latex-extras and be largely done with it within LaTeX, but it would be neat to abstract environments into Org in this manner.


texts: What is the purpose of calendar diary block entries?

texts:
What are calendar diary block entries about?  I've been looking around the web and I can't figure out why I would use that particular format, or how to use it, aside from assigning a starting and ending date.  I've looked at the doc's but they don't explain the purpose for using the format.

(Just to be clear, I'm talking about the basic calendar diary.  This has nothing to do with org-mode.)


texts: Don't understand the keybinding for auto-yasnippet

texts:
I am looking to use auto-yasnippet but I don't understand the keybindings they are suggesting such as H-w and H-y. I haven't seen any keybinding that starts with H so I am not sure what that is. I tried looking at the official documentation for emacs keybinding and didn't see any that started with H so I figured I would ask here.
https://github.com/abo-abo/auto-yasnippet


texts: Unable to change keyboard layout in EXWM/Emacs27.1

texts:
I recently installed Emacs 27 on Arch Linux, and I'm using EXWM as my display manager. Emacs seems to have defaulted to the "standard" keyboard layout, which is shown in the command (quail-show-keyboard-layout). I wanted to use the "pc105-uk" keyboard layout, so I tried to use the command (quail-set-keyboard-layout "pc105-uk") to change it. I placed it in my .emacs file, and the customize menu indicates that the keyboard layout should be set to pc105-uk. However, when I use the keyboard, it still enters characters according to the standard layout.
The problem does not occur if I use emacs inside of XFCE, where the keyboard is configured by XFCE to the standard 105/uk layout. I've looked through documentation/forum posts and I can't find any reason why this should be so. Any advice would be appreciated.


texts: Abbreviate "/home/user/file" to "~/file" in formatted fields (frame-title-format, etc.)

texts:
I have Emacs display the full path of the file in my window title:
(setq-default frame-title-format '("%f [%m] - Emacs"))

And in my mode-line:
(setq-default mode-line-buffer-identification
              (list 'buffer-file-name
                    (propertized-buffer-identification "%12f")
                    (propertized-buffer-identification "%12b")))

But I would prefer it to not show my actual user name, how can I get this abbreviate standard unix path?


texts: Update the org-agenda-daily-view automatically on background

texts:
The org-agenda-daily-view is fancily helpful as a review,
Additionally, I want to append a real-time now line as time elapsed.

This could be achieved by a work around solution, repeatedly kill and open the daily agenda buffer .

Is it possible to make it update automatically say every five minutes?


texts:
I'm upgrading Emacs and moving from macOS to Windows after quite a few years getting by with a very old setup (eg, custom scripts for Anything). I've installed Helm. I'm interested in a simple way to:

Specify a "project" directory without writing anything to disk or requiring any sort of
project file to be in place already (unlike Projectile, as far as I
can tell)
See a list of fuzzy-matched candidates for files to jump to within that project, at any level
Jump from the list to a selected file

In other words, I would like to recreate the experience of loading up an arbitrary directory in Atom and jumping to any file within that directory. Helm seems like a natural candidate for this, but does not seem to come with the desired functionality.

Thanks!


texts:
I am trying to configure RefTeX/AUCTeX so that the smart label-creation, invoked with C-c ( has the following sets of behaviors:

for \section-type labels, i.e., for \section, \subsection, etc. generate a label of the form: \label{sec:[[derived-from-section-name]]} where what follows the colon is derived from the section name.
for \items in an enumerate environment, generate a label of the form: \label{item:[[number]]}, where the number is automatically incremented from what has gone before. i.e., the first enumerate item I generate a label for gets \label{item:1}, the next one \label{item:2}, and so on.

This was standard behavior of my reftex implementation when I was using aquamacs, but I haven't been able to duplicate this in standard emacs.

Any help would be appreciated.


texts: Key strokes doesn't work for frames created from terminal on Mac OS

texts:
Compiled emacs25.1 from source on MacOS. Emacs works fine when opened by click the icon.

But when open it from terminal by emacs or emacsclient -a. All the key stokes is responded in terminal instead of the Emacs frame.

Does anyone known solutions for this issue?


texts: How to override projectile keybind for custom one?

texts:
I am currently using emacs out of prelude and with helm-projectile enabled in my setup.

Recently I added helm-ls-git to my stack too and noticed that the function helm-browse-project is more interesting for me than the one I've been using previously helm-projectile-find-file (from helm-projectile) bound to C-c p f.

Under my config/personal.el I've added the following line and thought it should do the trick:

(global-set-key (kbd "C-c p f") 'helm-browse-project)

This is not working, but if I switch to another unused key binding such as C-c p 0 for instance, it works perfectly fine.

So, why can't I override it and what should I do in order to make that happen?


texts:
I tried updating a repository about 30 minutes ago with only 3 lines being different and it has yet to show up as a commit on Github. Is it typically this slow? It shows that it went through and everything is up to date on Magit but not on Github. I have just the basic from Melpa and looked at this link Magit commit is slow even for tiny changes but it isn't quite what I'm looking for. So any help is greatly appreciated.

BTW I am using Ubuntu 18.04 with Emacs 25.2.2 and the most recent version of Magit, just installed it an hour ago.

Edit: It has been about an hour and it still hasn't gone through to Github.


texts: olivetti misbehaving on save, in org buffers

texts:
I'm getting this very strange behavior while using olivetti: when calling save-buffer the display goes back to the left margin, as if olivetti has stopped working. If I call olivetti-mode, it shows that it's still enabled, and it stays to the left until I zoom in or out (ctrl-+ on doom).
I only get this behavior in org buffers..
Is it possible that there's an after-save-hook that only runs in org mode? how can I check that?
Thanks!


texts: How can I modify a macro I call frequently?

texts:
I use use-package to organize my init.el. I noticed that all my declarations use :ensure t. An example declaration is:

(use-package auto-complete
  :ensure t
  :diminish auto-complete-mode
  :init (global-auto-complete-mode t))

Since all my use-package declarations use :ensure t, is there a way to modify use-package to implicitly include :ensure t without modifying use-package.el directly? Ideally I'd like not to use a differently-named function.

I'm a little bit familiar with advice-add, but my impression is that this is used to add a hook or environment to a function, not to modify the function or macro itself.


texts:
As I understand, Emacs doesn't really support multi-threading. Because of
this I've chosen to run some operation (it can take a while) with compile
function. This is asynchronous and all in all it seemed like a good solution
at first.

Now I need to wait until compilation ends and perform other actions (again
they should not freeze Emacs, so they will be probably new compile calls)
once it's finished.

So, it would be good if there were after-compilation-hook or something
like that, because compilation-exit-message-function doesn't work, as it's
called when compilation is not formally finished.

Is there some way I can perform actions after compilation process (I'm
referring to process created by compile)? Please note that I cannot
concatenate all commands into one big command and feed it to compile at
once because the commands are not known in advance.


texts: sh-mode: Scan error: "Containing expression ends prematurely",

texts:
Generate a file with this:

(echo '#!/bin/bash'
echo 'myfunc() {'
echo "cat <<'z'"
seq 135
echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
echo z
echo '}') >out

Open it in Emacs. When pressing C-M-f I get the error:

Scan error: "Containing expression ends prematurely", 515, 515

Then I press M-> to get to end of file, C-x C-x to move back to where I came from, and now I can press C-M-f and move to the next sexp.

It is as if emacs does not really index the full file before I have been to the end of the file.

How can I fix this?


texts:
I've got auto-complete package working for functions for *.R files, but now I'm struggling with auto-complete for file paths.

I've bound the "TAB" key to:

(global-set-key (kbd "TAB") 'ac-complete-filename)

And it does work after "/" symbol as suggested here. However it works only on new line. As in:

/

And it does not work from within a function such as:

read.table("/...")

Placing pointer after "/" when anything precedes it does not do anything.
Any suggestions?

Update:

Changing binding to ess-mode instead of global fixed it. Why? No idea...

(define-key ess-mode-map (kbd "TAB") 'ac-complete-filename)


texts: Why are the company-mode's drop downs ragged?

texts:
Here is how my company-mode's drop-downs look,

As you can tell, they are uneven, ugly and somehow a different font than what my Emacs is using (Iosevka). I found this question, but did not quite understand the answer. It was also asked back in 2015 so maybe there is a better answer now?
My emacs is GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2019-09-16 and company-mode is at 20200324.2145. I am using doom-theme atom one.
I want the drop downs to look like they do in the screenshots present on the company-mode's website.
Is there a way to achieve this? I looked for configs pertaining to the company's drop downs but could not find anything. Is this a font issue? If so, could I just use a different font for company's drop downs (something that is not uneven), which font? Any recommendations? Maybe set it using use-package's custom face attribute?
Is there anything else I am missing or is there an easier solution?


texts:
I have set up a mount point using the s3fs FUSE filesystem and autofs to talk to an Amazon S3 bucket, but it is excruciatingly slow to edit a file in the bucket in emacs - it is basically unusable due to the delays after every keypress, which cause emacs to hang completely until it finishes its I/O.

What can I do to avoid this problem?


texts:
Whenever I enable flyspell-mode on any file, I immediately get the below error:
Error in post-command-hook (flyspell-post-command-hook): (wrong-type-argument keymapp nil)

And after that flyspell stops working. Has anyone else encountered this issue? I was able to reproduce the error on emacs -Q. If I enable toggle-debug-on-error, I'm not getting any backtraces.
emacs version:
Emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3)
 of 2020-08-18, built using commit fc9b68636b1aec69295726d2b3be2b520911f40b.

./configure options:
  --with-modules --with-rsvg --with-dbus --with-imagemagick --without-pop --with-xft --with-xml2 --with-libotf --with-mailutils --without-toolkit-scroll-bars --without-xaw3d -with-nativecomp 'CFLAGS=-O3 -mtune=native -march=native -fomit-frame-pointer'

Features:
  XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ LIBOTF ZLIB GTK3 X11 XDBE XIM MODULES NATIVE_COMP THREADS LIBSYSTEMD JSON PDUMPER LCMS2

Here is my emacs config: https://github.com/CSRaghunandan/.emacs.d/blob/master/setup-files/setup-spell.el.
I tried with both hunspell and aspell and both are giving the same error.
If I enable flyspell-lazy-mode and enabe toggle-debug-on-error, I get the below error backtrace:
Debugger entered--Lisp error: (wrong-type-argument keymapp nil)
  make-flyspell-overlay(1313 1317 flyspell-duplicate highlight)
  flyspell-highlight-incorrect-region(1313 1317 doublon)
  flyspell-word()
  flyspell-check-region-doublons(1289 1350)
  flyspell-large-region(1289 1350)
  flyspell-region(1289 1350)
  apply(flyspell-region (1289 1350))
  flyspell-lazy-check-pending()
  apply(flyspell-lazy-check-pending nil)
  timer-event-handler([t 0 1 0 t flyspell-lazy-check-pending nil idle 0])


texts: How do I expand the region-beginning and region-end?

texts:
Solution:

With the help of @Drew, I figure out a solution. I am not good at elisp. The code may not be a good design but at least is working. I use this code to add 4 white space so I can copy a highlighted code and paste to web like stackoverflow and remove 4 white space afterward easily.

(defun shift-region (distance)
  (let ((beg (save-excursion (goto-char (region-beginning))(line-beginning-position)))
        (end (save-excursion (goto-char (region-end))(line-end-position))))
    (goto-char beg)
    (set-mark end)
    (indent-rigidly beg end distance)
    (setq deactivate-mark nil)))

(defun shift-right ()
  (interactive)
  (shift-region 4))

(defun shift-left ()
  (interactive)
  (shift-region -4))

(global-set-key (kbd "C-<tab>") 'shift-right)
(global-set-key (kbd "<backtab>") 'shift-left)

Question:

I have this code

(defun shift-region (distance)
  (let ((mark (mark)))
    (save-excursion
      (indent-rigidly (region-beginning) (region-end) distance)
      (push-mark mark t t)
      (setq deactivate-mark nil))))

I want to expand the region-beginning to the beginning of that line
while the region-end to the end of that line.

Visual representation
(I use [ ] to represent the region mark)

abcde
abcde [ fghi
abcdefghi
abc ] defg
abcde

will become

abcde
[ abcdefghi
abcdefghi
abcdefg ]
abcde


texts: Function that deletes redundant leading whitespaces of a region while maintaining indentation

texts:
Is there a Elisp function that deletes "redundant" leading whitespace of the region while maintaining relative indentation.

This behavior is like textwrap.dedent in python.
https://docs.python.org/2/library/textwrap.html#textwrap.dedent


texts: What does the `/l` mean in the mode `C++/l` mean?

texts:
Just a simple question with more than likely a simple answer:

What does the /l mean in the mode C++/l mean?


texts: How to add a new .c file to Emacs source code

texts:
I've added my own .c file to Emacs /src directory as well as the following lines

emacs.o: ... file.c file.h
file.o: file.c

in deps.mk

I get file.o generated, but it is not linked when generating Emacs executable (at least that's what I see when I check presence of my function). Why?

In general, what actions should I undertake to add my .c file to Emacs executable?


texts: Turn a non prog-mode derived major-mode into a prog-mode derived major-mode

texts:
erlang-mode is not a derived prog-mode.

Is there any way to make it part of the prog-mode-hook ?


texts: Can I use ido-mode for org-clock-select-task?

texts: Is there a way to use ido to select tasks from the org-clock-select-task list? Having to read through the list to find the right task and then look at the number makes me lose my flow :)


texts: How to invoke another function only if there is some error with a given function?

texts:
Assume that I have two functions, say function1 and function2. I would like to execute function2 only if there is some error during the execution of function1. So far, I have tried the below code
(ignore-errors (function1) (function2))

This executes function2 if there is some error with function1, but it executes function2 if there is no error with function1 as well.
How to correct the code?


texts: I have a beautiful hardcopy of the Emacs Manual printed by the FSF. I was wondering if anyone knew how this document was created in Emacs and what mode was used for its creation? I would also be interested to know how the effect of the different fonts was achieved? I am assuming it was typed up in Emacs and that Richard Stallman was the person to have typed it. There does not appear to be specific information in the Manual itself on the process.


texts: How do I automatically truncate a growing buffer?

texts:
I want to run IPython in emacs for all the emacsy goodness I get, but I'm having a problem getting the buffer to automatically truncate (it gets slow quickly printing large dataframes and such).

It would also be nice to have my run on save test runners in emacs, but for that I would need the window to be automatically cropped at say 1000 lines. How do I do that?


texts:
Is there a way in org-mode to have variable blocks of text. That is, to select between different bodies of inline text and examples, on the basis of a variable defined earlier.

I'm trying to create a tutorial for carrying out a task using two similar programs, using a single document and varying small parts of the explanation and the examples according to which program I want to export for.

I would have used \ifthenelse{}{}{} in LaTeX in the past, but I can't find a clean way to do this with org-mode.


texts: Showing returned values in the same buffer

texts:
When I evaluate an expression with C-x C-e, I see the result returned by that expression in the minibuffer, for a while.
Can I have that returned value written in the same buffer where the evalued expression is?
How?


texts:
When type " in AucTeX, either `` or '' is typed. How do I do similar action with single quotes? Typing ' won't give me ` or '.

EDIT I'm not asking about the double quotes---I agree with what double quotes did and I just want to show that single quotes do not behave the same as double quotes, but I want single quotes to behave the same as double quotes.

My babel is English.


texts: How to load a new version of emacs module from a file?

texts:
I am trying to debug a c++ program using M-x gdb but I get nothing but a (gdb) prompt.

This question has a comment which suggests to load the latest version of gdb-mi.el.

  Can you try download latest version of gdb-mi.el from github.com/mirrors/emacs/blob/master/lisp/progmodes/gdb-mi.el an try to load it?

Question: how can I load that version of gdb-mi.el?


texts: Can I set a variable scoped to a perspective?

texts:
I have a large monorepo repository and open different parts of it in a persp-mode perspective. It would be nice if for all buffers owned by that perspective I could set for example projectile-project-root. Is this possible?

Side note (not part of the official question, maybe just add a comment?) Is there a good rundown on how exactly scope works in elisp other than the docs - they're helpful but pretty bare bones and not really enough for me to grok fully how this works especially when plugins are in the equation.


texts: Skip specific lines in re-search-forward

texts:
Consider something like:

(while (re-search-forward "Pattern" nil t)
(replace-match "replace"))

How can I skip all lines that contain "Skip" from this replace search? I.e. Pattern should only be replaced in such lines that doesn't contain "Skip".


texts:
When we refile, the refiled stuff goes to the end of the heading under which it is being refiled.
Can we get the refiled stuff to go to the top, instead?
This can be easily done while capturing. I can write a custom template and with :prepend t instruction, the captured stuff goes to the top of the heading under which it is getting captured.


texts:
I have installed nyan-mode and mode line looks like this.

I would like to move nyan cat to end of mode line and arrange all other items like column number, file name, modes to left side leaving empty space in middle.

How can i re arrange items in mode line?


texts: How to unconditionally toggle parent checkbox

texts:
In the following example Org mode buffer, I cannot check the Parent checkbox without first checking the Child checkbox:

- [ ] Parent
  - [ ] Child

Is there some way to loosen this restriction?  There is a user option called org-enforce-todo-dependencies that bypasses such dependency-checking for TODO entries, but I cannot find such an option for checkboxes.

I'm using version 9.1.14 of org.el.


texts: Interactively customize theme-tied faces

texts: M-x customize-face is great and custom-theme-set-faces is a great function. Can I have these two tied together easily so that I can interactively customize a face that will be tied to the currently chosen theme? We can assume there's only one theme enabled.


texts: Custom verbatim environments/macros in AucTeX

texts:
Here's my MWE:

\documentclass{article}

\newenvironment{tscode}{}{}
\def\tscode|#1|{}

\begin{document}
\tsinline|efwe|
\begin{tscode}
efihw$feiw$
\end{tscode}
\end{document}

% Local Variables:
% LaTeX-verbatim-environments-local: ("tscode")
% LaTeX-verbatim-macros-with-delims-local: ("tsinline")
% End:

I've verified the buffer is loading as LaTeX-mode and that the variables listed have the quoted values given as the file-local value, but fontlock is still incorrect after saving&reverting the buffer:

I've had this working before, but I'm not sure what changed in my configuration.  I'm assuming no incompatible changes with AucTeX have been introduced in the last three months or so.

Related:

https://tex.stackexchange.com/a/111316/17423
LaTeX Mode and Listings with $-signs?


texts: Exclude the habits from the global todo list

texts:
I set habits

** TODO Wake Up Early In the Morning
SCHEDULED: <2019-07-17 Wed 05:00 ++1d -0d>
:PROPERTIES:
:STYLE: habit
:LAST_REPEAT: <2019-07-15 Mon 04:30>

they display on agenda perfectly

Unfortunately, it additionally appear in the global todo list upon invoking C-a t

How could exclude  the habits from the global todo list?


texts: Executing a function when opening a file of certain type

texts:
I would like that when I open a file of certain type (say *.abc)
certain function (say my-function) automatically executes at the
opening.

Edit. The function is a buffer-dependent function and should run at the buffer containing the file
  *.abc, i.e., it should run after loading the file
  .abc not before.

The function I would like to execute is
  shr-render-buffer (but it may arise for other functions). It
  renders html codes. Note that the file may have an arbitrary suffix
  not just .html

After the hints in the answer of Mark an using the links in my comment
below it, I tried the following:

Attempt 1:

(require 'shr)
(add-hook 'find-file-hook 'my-function)
(defun my-function ()
  (when (and (stringp buffer-file-name)
             (string-match "\\.html\\'" buffer-file-name))
             '(shr-render-buffer)))

Attempt 2:

(require 'shr)
(add-to-list 'auto-mode-alist
             '("\\.abc\\'" . (lambda ()
                              '(shr-render-buffer))))

Attempt 3:

(require 'shr)
(add-hook 'find-file-hook 'my-function)
(defun my-function ()
  (when (string= (file-name-extension buffer-file-name) "abc")
    '(shr-render-buffer)
    ))

Then after the suggetion of Lidydancer, I tried to define a major mode for
.abc types. For simplicity I considered them as html-mode and I
used the following (already provided by one of the answers in the
below links):

Attempt 4:

(require 'shr)
(add-to-list 'auto-mode-alist '("\\.abc\\'" . html-mode))
(add-hook 'html-mode-hook 'shr-render-buffer)

All my attempts were unsuccessful.


texts: How to exclude double dot(..) and single dot(.) in find-file using `helm`?

texts:
I am using helm for find files. I have followed: https://stackoverflow.com/a/43632653/2402577

(helm-mode 1)
(global-set-key "\C-x\C-f"  'helm-find-files)

(add-hook 'dired-mode-hook 'dired-omit-mode)
(setq dired-omit-files
      (rx (or (seq bol (? ".") "#")
              (seq bol "." eol)
              (seq bol ".." eol)
              )))

During the search . and .. always shows up on the top of the search.

Find files or url: /home/user/folder/
Find Files (C-l: Go up one level)
/home/user/folder/.
/home/user/folder/..
...

[Q] Is it possible to not show them? or show them/hidden files on the bottom of the search?


texts: How to temporarily switch to another major mode in elisp (with-current-mode ?)

texts:
Is there reliable way to temporarily switch the current buffer to another major mode, perform some function, then switch back to the original mode?
Basically, I was looking for something similar to with-current-buffer below, but instead of temporarily switching to a different buffer, switch to a different major mode during an action.

Macro: with-current-buffer buffer body...
The with-current-buffer macro saves the identity of the current
buffer, makes buffer current, evaluates the body forms, and finally
restores the buffer. The return value is the value of the last form in
body. The current buffer is restored even in case of an abnormal exit
via throw or error

I tried something here (for reasons also explained there) along the lines of:
  (let ((current-mode major-mode))
    (text-mode)
    ;(...)
    (funcall current-mode)
  )

to switch to the text-mode first, perform the action, and then switch back. This works as expected
only if the action is completed. However, if the action in the middle is canceled or there is an error,
the last step for restoring mode is skipped and the current buffer is stuck in the text-mode.
Is there a safe way to do, e.g.  (with-current-mode "text-mode" (...))?


texts:
When collaborating on a project, certain editing variables are set to
make sure everyone is producing a similar style of code.  In Emacs,
these are usually implemented as either file-local variables or
directory-local variables.

File-local variables are best when you want to keep the variable's
value attached to the file itself, but they get cumbersome when it is
the same variable over and over again for every file in the project.

Using a directory-local variable would be the obvious choice, but I'm
personally using this to set the email I use in the project (as
opposed to my work email, etc.) to make sure I'm never inconsistent
with my commit data.

Is there a way around this problem? Can I have two files holding
directory-local variables in the same directory (one personal file and
one version-controlled file)?

Refer: sx.el@3a5afcc


texts: Removing old name /tmp/docview1000 warning

texts:
When starting emacs I get the following warning:

Warning (initialization): an error occurred while loading '/home/jamesbond/.emacs':

File error: Removing old name, no such file or directory, /tmp/docview1000

Using --debug-init returns:

Debugger entered--Lisp error: (file-error "Removing old name" "no such file or directory" "/tmp/docview1000")
  delete-file("/tmp/docview1000" nil)
  dired-delete-file("/tmp/docview1000" always)
  doc-view-clear-cache()
  eval-buffer(#<buffer  *load*-811718> nil "/home/jamesbond/.emacs.d/settings/general-settings.el" nil t)  ; Reading at buffer position 5446
  load-with-code-conversion("/home/jamesbond/.emacs.d/settings/general-settings.el" "/home/jamesbond/.emacs.d/settings/general-settings.el" nil t)
  require(general-settings)
  eval-buffer(#<buffer  *load*> nil "/home/jamesbond/.emacs" nil t)  ; Reading at buffer position 346
  load-with-code-conversion("/home/jamesbond/.emacs" "/home/jamesbond/.emacs" t t)
  load("~/.emacs" t t)
  command-line()
  normal-top-level()

Emacs is also not behaving according to some of my settings anymore. Maybe they are not reached due to the error? How can I solve this issue?


texts: Buffer-name on separate "row" from toolbar icons?

texts:
Using macOS (11.3, M1 Mac mini) and an older Intel build of Emacs 27.1, when I load a file/buffer into Emacs, the path to the file/buffer shows up at the top of the window, above the toolbar:

But, using a newer "universal" build of Emacs 27.2, the file/buffer name shows up on the same row as the toolbar:

As you can see, the end of the file/buffer name can get cut off if the path is long and the window isn't wide enough.
How can I revert to the path-above-the-toolbar behavior shown in the 1st pic?


texts: How to highlight ivy candidates in the manner of hl-line?

texts:
Coming from helm, I am giving swiper and ivy-mode a shot.

I'm looking for a way to highlight candidates in the way hl-line-mode does: full width background.


texts:
I see sharp quotes being used in other people's eLisp code, and I use them myself, but I'm not completely clear on when they are appropriate and when not.

Could anyone clarify on exactly when it's appropriate to use sharp quotes and when ordinary single quotes should be used instead?


texts: disable line numbers in helm buffers , emacs 26

texts:
I have emacs 26 installed and helm.

I would like to disable line numbers in helm buffers ( and other buffers that has no use of line numbers)

is there anyway to disable the native line number in those buffers or even better disable it in everything except buffers that has code ( buffers with filenames ) ?


texts:
I've looked on google, stack exchange, GNU emacs manual, xterm manual, etc. and still haven't found an answer that satisfies my problem(s).

Problem:

Using Systems: Ubuntu 16.04, xterm, emacs-nox

I want to bind the keys Ctrl+i Ctrl+m Ctrl+[ and Meta+Shift+o to any command I want.

But the problem seems to be that all of said key sequences are bound to:

Tab, Return, Escape, and Control Code ESC 0 respectively becuase that's just the way terminals work.

So how do I keep the functionality of the Tab, Return, and Escape whilst having said keybinds at my disposal?

Do I have to remap the keys in the terminal somehow? If so, how?

I will do anything to make this work.


texts: How to set a default password for wildcard host in tramp?

texts:
I have a list of hosts 192...* with a default user and password, I've tried to set wild-card in .authinfo.gpg but it still requests password when I try to login.

There are no problems when it set per host IP.


texts: How do I jump from a diff hunk to the relevant commit(s)?

texts:
I am reading a diff between two revisions, say A..B, possibly limited to a single file.

Once in a while, I stumble on a hunk that I’d like to investigate in detail. I want to press a key or two and see the commit(s) that introduce the change I’m currently looking at.

Since that is kind of vague, let’s say I want the equivalent of l =L file RET start,+lines RET l range RET, where file, start and lines are taken from the current hunk and range is the current diff’s range. The log should not be limited to the file, even if the diff was.

I can do this manually but I want to automate it.


texts: Spacemacs gg=G replacing tabs with spaces in org-babel makefile block

texts:
I'm using Spacemacs, and my org-mode file contains an org-babel block of Makefile code, which I want to "tangle" so it becomes part of the source code while remaining in sync with the documentation. All of this is working, except when I auto-indent the org-mode file, the tabs inside my makefile source code block get replaced with spaces.
Spaces aren't valid indentation in makefiles, but I may accidentally use gg=G at some point, so I would like to tell emacs to not replace those tab characters.
This behavior persists when I set org-src-preserve-indentation to t in the file, so I don't know what else to do.
I already found this but my question is about auto-indenting the org-mode file itself, not exporting to another format.
# -*- org-src-preserve-indentation: t -*-
* some header
** another header

   #+begin_src makefile :tangle src/Makefile :mkdirp yes :exports code
all: people

main.o: main.c
    gcc -g -c -o main.o main.c

linked_list.o: linked_list.c
    gcc -g -c -o linked_list.o linked_list.c

clean:
    rm -f people *.o

people: main.o linked_list.o
    gcc -g -o people linked_list.o main.o

test: people
    ./people
   #+end_src


texts: [[D:/dev::line][code]] stores the link to my code directory. How can i used dired to open it in emacs. Currently with this code explorer opens the directory. I'm using Windows 7.


texts: cider-jack-in: Symbol's function definition is void: clojure-project-dir with closure-mode installed

texts:
M-x (cider-jack-in)

  cider-jack-in: Symbol's function definition is void: clojure-project-dir

lein run

  "Hello World!"

cat ~/.lein/profiles.clj

  {:user {:plugins [[cider/cider-nrepl "0.14.0"]]}}

clojure-mode is installed. I forked and used Brave Clojure's .emacs.d as the starting point. I am not familiar enough with emacs to know what makes his .emacs.d configuration different. I went through his install and upgrade procedures which I quote from the link above:

WARNING

This project uses an outdated version of
CIDER, the package that
provides much of the functionality for Clojure development. If you run
into issues, try upgrading (instructions below).

Why not just update this package to use the latest CIDER, you ask?
This project uses CIDER 0.8.1 so that
Clojure for the Brave and True
readers are less likely to get confused as they use Emacs for the
first time.

Installing

Close Emacs.
Delete ~/.emacs or ~/.emacs.d if they exist. (Windows users, your
emacs files will probably live in
C:\Users\your_user_name\AppData\Roaming\. So, for example, you
would delete C:\Users\jason\AppData\Roaming\.emacs.d.) This is
where Emacs looks for configuration files, and deleting these files
and directories will ensure that you start with a clean slate.
Download the Emacs
configuration zip file
and unzip it. Its contents should be a folder,
emacs-for-clojure-book1. Run mv path/to/emacs-for-clojure-book1
~/.emacs.d.
Create the file ~/.lein/profiles.clj (Windows users, this is
probably C:\Users\your_user_name\.lein\profiles.clj) and add this
line to it:

{:user {:plugins [[cider/cider-nrepl "0.8.1"]]}}

Then open Emacs.

Upgrading

Before upgrading, ensure that your .emacs.d directory is under
version control so that you can always revert to a known good state.

To upgrade:

Edit .emacs.d/init.el, adding these lines after line 12:

(add-to-list 'package-archives
    '("melpa-stable" . "http://stable.melpa.org/packages/") t
(add-to-list 'package-pinned-packages '(cider . "melpa-stable") t)

Close Emacs.
Run rm -Rf .emacs.d/elpa/cider-*
Open Emacs. You'll probably see some errors and your theme won't
load. That's ok.
In Emacs, run M-x package-refresh contents.
In Emacs, run M-x package-install cider.
Close and re-open Emacs.
Open .lein/profiles.clj and remove [cider/cider-nrepl "0.8.1"] from it.

That should install the latest version. Enjoy!


texts: How to debug startup problem, if `--debug-init' has no effect

texts:
When I launch Emacs24 (in an Ubuntu machine) I get an error message in the init procedure.

Warning (initialization): An error occurred while loading `/home/nivaca/.emacs':

But when I launch it with emacs --debug-init the debugger is not entered. How can I debug this problem?


texts: replace splash screen with list of recentf

texts: The splash screen is useful in the beginning, but now I want something more useful: I want to have list of recently opened files presented when starting emacs if there is no predefined file to open. Even better, if it can be the helm-recentf window (I use helm package)


texts: hash filenames for html publishing in org-mode

texts:
Background:
I use org-mode publish a website for a class I teach.  I want to keep all my old notes on the hosting server.  I want to keep using very predictable filenames (e.g. "hw1.pdf", "hw2.pdf", etc.) in my source directory, but I don't want users to be able to access certain files until I have linked to them on the website--needless to say, I don't publish a site-map.  I also want old files to be removed from the public directory automatically so students cannot accidentally obtain an old version of a homework (in case I need to make a correction/adition to an assignment).
Here was my idea: I'll just make filenames in the published directory the hash of the corresponding file.  Implementing this has been a bit difficult.  Here is what I plan to do:

add-org-link-type for pointing to pdfs in my source directory.
Write a function my/org-publish-attachment which copies files to the appropriate directory with renaming and removes files not linked to on the site.

I think org-mode already hashes the files when running org-publish-attachment (so it can check for updates to the file in the public directory), but I don't know where (or if) those hashes are stored.

Questions:

Am I right that org-mode hashes files when running org-publish-attachment?  If so, are these hashes stored somewhere I can access?
How can I make the html links "dynamic"?  If hashes are stored, I could just modify the publishing function for that org-link-type.  If they aren't, what are my options?
What other variables and functions are relevant here?

PS. I'm relatively new to org-mode, and there is a LOT out there; this has made it difficult to get started.  If I've missed some obvious reference that solves my problem, please let me know.  Thanks in advance for your help!


texts: company-lsp invokes completion on numbers

texts:
This is quite annoying, when I'm typing a number company invokes completion after I type a . or when the number of digits exceeds company-minimum-prefix-length.

This will trigger other company-backends like company-dabbrev-code or company-yasnippet (if you've it enabled) or company-keyword.

Is there anyway I can get company to avoid completion on numbers for all major-modes?


texts: I cannot make it show syntax in the org-mode ledger block. It is just shown with plain text. But if I bring it to the edit buffer, it displays the syntax properly. Can anyone help me to trace this problem?


texts: Orgmode: is it possible to set tags at a file level?

texts:
Having a file for a particular project, I would like all the nodes in that file to have a tag identifying the project, so that I can later use it to create agenda views for that project only. So far all I've found is #+TAGS: foo bar spam which specifies a hard list of tags offered in tag autocompletion for that file.

Does anyone know of a #+XXX-like instruction to achieve this?


texts: How to make emacs not crash when converting binary file to UTF-8

texts:
When I run revert-buffer-with-coding-system [RET] UTF-8 Emacs crashes.

This is the file I'm trying to revert.

\0

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂăĄąĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıĲĳĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňŉŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃǄǅǆǇǈǉǊǋǌǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰǱǲǳǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁ˂˃˄˅ˆˇˈˉˊˋˌˍˎˏːˑ˒˓˔˕˖˗˘˙˚˛˜˝˞˟ˠˡˢˣˤ˥˦˧˨˩˪˫ˬ˭ˮ˯˰˱˲˳˴˵˶˷˸˹˺˻˼˽˾˿̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎͓͔͕͖͙͚̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮͯ̕̚͘͜͟͢͝͞͠͡ͅͰͱͲͳʹ͵Ͷͷ͸͹ͺͻͼͽ;Ϳ΀΁΂΃΄΅Ά·ΈΉΊ΋Ό΍ΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ΢ΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϏϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭϮϯϰϱϲϳϴϵ϶ϷϸϹϺϻϼϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁ҂҃҄҅҆҇҈҉ҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӏӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱӲӳӴӵӶӷӸӹӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧԨԩԪԫԬԭԮԯ԰ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖ՗՘ՙ՚՛՜՝՞՟ՠաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆևֈ։֊֋֌֍֎֏֐ְֱֲֳִֵֶַָֹֺֻּֽ֑֖֛֢֣֤֥֦֧֪֚֭֮֒֓֔֕֗֘֙֜֝֞֟֠֡֨֩֫֬֯־ֿ׀ׁׂ׃ׅׄ׆ׇ׈׉׊׋׌׍׎׏אבגדהוזחטיךכלםמןנסעףפץצקרשת׫׬׭׮ׯװױײ׳״׵׶׷׸׹׺׻׼׽׾׿؀؁؂؃؄؅؆؇؈؉؊؋،؍؎؏ؘؙؚؐؑؒؓؔؕؖؗ؛؝؞؟ؠءآأؤإئابةتثجحخدذرزسشصضطظعغػؼؽؾؿـفقكلمنهوىيًٌٍَُِّْٕٖٜٟٓٔٗ٘ٙٚٛٝٞ٠١٢٣٤٥٦٧٨٩٪٫٬٭ٮٯٰٱٲٳٴٵٶٷٸٹٺٻټٽپٿڀځڂڃڄڅچڇڈډڊڋڌڍڎڏڐڑڒړڔڕږڗژڙښڛڜڝڞڟڠڡڢڣڤڥڦڧڨکڪګڬڭڮگڰڱڲڳڴڵڶڷڸڹںڻڼڽھڿۀہۂۃۄۅۆۇۈۉۊۋیۍێۏېۑےۓ۔ەۖۗۘۙۚۛۜ۝۞ۣ۟۠ۡۢۤۥۦۧۨ۩۪ۭ۫۬ۮۯ۰۱۲۳۴۵۶۷۸۹ۺۻۼ۽۾ۿ܀܁܂܃܄܅܆܇܈܉܊܋܌܍܎܏ܐܑܒܓܔܕܖܗܘܙܚܛܜܝܞܟܠܡܢܣܤܥܦܧܨܩܪܫܬܭܮܯܱܴܷܸܹܻܼܾ݂݄݆݈ܰܲܳܵܶܺܽܿ݀݁݃݅݇݉݊݋݌ݍݎݏݐݑݒݓݔݕݖݗݘݙݚݛݜݝݞݟݠݡݢݣݤݥݦݧݨݩݪݫݬݭݮݯݰݱݲݳݴݵݶݷݸݹݺݻݼݽݾݿހށނރބޅކއވމފދތލގޏސޑޒޓޔޕޖޗޘޙޚޛޜޝޞޟޠޡޢޣޤޥަާިީުޫެޭޮޯްޱ޲޳޴޵޶޷޸޹޺޻޼޽޾޿

I would like to know how to accomplish this operation without Emacs abruptly exiting. I'm working with GNU Emacs 26.1.


texts: elisp - regex to replace substring with multiple conditions

texts:
I want to replace below example

line1 ![img](170319_first.png "test")
line2 ![img](170319_second.png)
line3 ![img](/assets/170319_second.png)

to:

line1 ![img](/assets/170319_first.png "test")
line2 ![img](/assets/170319_second.png)
line3 ![img](/assets/170319_second.png)

which means:

Do not replace line3 case (file name start with "/assets" already)
Add "/assets/" to file name for line1 case (end with a space)
Add "/assets/" to file name for line2 case also (end with a ')').

I try to use below code but it doesn't work.

(setq str "
line1 ![img](170319_first.png \"test\")
line2 ![img](170319_second.png)
line3 ![img](/assets/170319_second.png)
")
(with-temp-buffer
  (insert str)
  (goto-char (point-min))
  (setq regex1 "\\!\\[img\\](\\([^/]*?\\)\\([ \\|)]\\)")
  (while (re-search-forward regex1 nil t)
    (setq regex2 (format "![img](/assets/%s" (match-string 1)))
    (replace-match regex2 nil t))
  (print (buffer-string))
  )

But the result not correct:

line1 ![img](/assets/170319_first.png\"test\")
line2 ![img](/assets/170319_second.png
line3 ![img](/assets/170319_second.png)

Obviously, the ' ' and ')' has been replaced also. but I didn't include it in the match group.


texts: How to sort in Dired by size and extension and have directories listed first and full date/time details

texts:
I'm using the excelent dired-fixups.el by Dino Chiesa for sorting in Dired by size and extension (see here).

The only gotcha is that I'd like to combine it with a fuller date/time description. Also, I'd like to keep directories on top of any Dired buffer, so they don't mix with files. That is, I'd like to combine dired-fixups.el with something like this:

(setq ls-lisp-format-time-list  '("%d.%m.%Y %H:%M:%S" "%d.%m.%Y %H:%M:%S")
      ls-lisp-use-localized-time-format t)

(defun ls-lisp-format-time (file-attr time-index now)
    "%d.%m.%Y %H:%M:%S" "%d.%m.%Y %H:%M:%S")

  (if (eq system-type 'gnu/linux)
      (setq dired-listing-switches "-alDh --group-directories-first --time-style \"+%d-%m-%Y %H:%M:%S\""))

  (defun ensure-buffer-name-ends-in-slash ()
    "change buffer name to end with slash"
    (let ((name (buffer-name)))
      (if (not (string-match "/$" name))
          (rename-buffer (concat name "/") t))))

  (add-hook 'dired-mode-hook 'ensure-buffer-name-ends-in-slash)

  (add-hook 'dired-mode-hook
            (lambda()
              (setq truncate-lines 1)))

However, I'm not a programmer. I've been tweaking with the code in dired-fixups.el to no avail. Probably it is not too difficult... Does anybody know how to get an outcome like the following snapshot, but where I can use all the sorting options in dired-fixups.el?

  /home/dgm/.emacs.d/src:
  total used in directory 364K available 15413252
  drwxr-xr-x 21 dgm dgm  12K 29-03-2020 23:27:42 ..
  drwxr-xr-x 14 dgm dgm 4.0K 29-03-2020 09:05:19 .
  drwxr-xr-x  2 dgm dgm 4.0K 05-09-2019 23:58:20 org-recipes
  drwxr-xr-x  2 dgm dgm 4.0K 09-08-2019 12:52:48 ambrevar
  drwxr-xr-x  8 dgm dgm 4.0K 21-04-2019 16:10:22 ado-mode-1.15.1.4
  drwxr-xr-x  2 dgm dgm 4.0K 07-12-2018 15:57:55 ob-stata
  drwxr-xr-x  7 dgm dgm 4.0K 06-12-2018 11:26:01 dvc
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 minimal
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 org-bullets
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 smooth-scrolling
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 stripe-buffer
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 wc
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 word-count
  drwxr-xr-x  2 dgm dgm 4.0K 06-12-2018 11:26:01 bookmarkplus
  -rw-r--r--  1 dgm dgm 4.9K 29-03-2020 09:05:19 dired-fixups.el
  -rw-r--r--  1 dgm dgm  36K 28-03-2020 22:12:11 dired-sort-menu.el
  -rw-r--r--  1 dgm dgm  17K 28-03-2020 22:10:05 dired-sort-menu+.el
  -rw-r--r--  1 dgm dgm 4.6K 27-01-2020 19:47:40 org-graph-view.el
  -rw-r--r--  1 dgm dgm  38K 27-01-2020 19:47:23 graph.el
  -rw-r--r--  1 dgm dgm 6.0K 02-01-2020 16:08:56 window-highlight.el


texts: macOS not-terminal: why "S-" is translated away from S-RET?

texts:
I am trying to bind S-RET to something, but it's getting ignored. If I do  C-h k S-RET, I see RET (translated from <S-return>) runs... - which seems to suggest that Emacs sees the S- in S-RET just fine, but then decides to drop the S- part for some reason. How do I find that reason and, preferably, remove it?

This is a macOS GUI build from https://emacsformacosx.com. Googling finds multiple instances of similar issue of Emacs on terminals, but in this case it is not a terminal. I have also tried looking at the translation keymap variables, I don't fully understand their contents, but at least they don't grep for anything starting with S-R... or S-r....


texts: Reach to the extreme of font size in one step

texts:
Usually to view the org or code in a bird view, I will decrease the font size to the extreme of minimal with M-x decrease, C-x z, z, z, z until reach the extreme.

Is it possible to reach the extremes of minimal or max in one step?


texts: Trying to copy everything between double quotes, and then make a list of everything that was copied

texts:
So I have a defun that I made that is supposed to copy every thing that is between double quotes and then make a list of everything that was copied. I don't know what the problem is, but it doesn't seem to work with every list of quoted text.

There is a change log that would be something like this format.

"Type1" changed ~such and such data.

"Type2" changed ~such and such data.

And then I would like my defun to simply copy the text between the double quotes and then spit them out into a summary change log that would go something like this.

Changes were made to the following types.

Type1

Type2

etc.

The purpose of this is to write a change log. Everything that has changed is supposed to be between quotation marks. The defun is supposed to print out Changes were made to the following types then a separate new line and then the list of everything that was quoted. It is possible that there could be dozens of "types" within hundreds of lines of text that need to be recorded in a change log. It is imperative that this change log list is accurate at the end.

I am not sure if the problem is in my copy-region-as-kill loop, or in my "yank" loop. I made it copy the quoted text three times and then delete the duplicate lines in an attempt to get this to work. That got it to work with one specific list, but it does not work with all of them. Here is my defun.

(defun change-log()
  "I created this to automatically copy all \"Types\" during categorization maintenance. It will also automatically create the change log for you at the end of the text file."
  (interactive)
  (setq x 1)
  (while (search-forward "\"" nil t)
    (setq pos (point))
    (set-mark-command nil)
    (search-forward "\"" nil t)
    (backward-char)
    (setq pos2 (point))
    (kill-ring-save (region-beginning) (region-end))
     (kill-ring-save pos pos2)
     (kill-ring-save pos pos2)
    (forward-char)
    (setq x (1+ x)))
  (setq x (1+ x))
  (setq x (* x 3))
  (setq y (1+ x))
  (end-of-buffer)
  (insert "\n")
  (insert "\n")
  (insert "Changes were made to the following types.")
  (insert "\n")
  (insert "\n")
  (setq pos (point))
  (yank x)
  (insert "\n")
  (while (> x 0)
    (yank x)
    (insert "\n")
    (setq x (1- x)))
  (yank y)
  (insert "\n")
  (yank x)
   (setq pos2 (point))
   (delete-duplicate-lines pos pos2)
   (backward-paragraph)
   (while (search-forward-regexp "\\.$" nil t)
     (replace-match "" nil))
   (auto-whitespace-remove)
   (forward-paragraph)
   (set-mark-command nil)
   (backward-paragraph))


texts: How to get Emacs use the Ubuntu login password for tramp

texts:
Ubuntu 16.04 Emacs 26.1 Emacs needs to open the file with root privileges. Here is my code:

    (secrets-delete-item "session" "Login")
(secrets-create-item "session" "Login" "myParol" :method "sudo" :host "iemuser" :user "iemuser")
;(secrets-show-secrets)
; session
; `-[-] Login
;    |-  password:   myParol
;    |-  host:       iemuser
;    |-  user:       iemuser
;    |-  method:     sudo
;    `-  xdg:schema: org.freedesktop.Secret.Generic
(setq auth-sources '("secrets:session"))
(find-file "/sudo::/usr/share/emacs/24.5/lisp/gnus/auth-source.el.gz")

and again Emacs persistently requires a password: Password for /sudo:root@iemuser: How to get Emacs to take the password from my Ubuntu login.

Addition details from the comments:

iemuser@iemuser is not a mistake:

The localhost is named iemuser
I am logged in to that host (and running Emacs on that host) as a user with that same name, iemuser

In emacs I wish to programmatically open a root-owned file on this localhost for editing. i.e.: /sudo::/path/to/file

My goal is to not be prompted for a sudo password when this happens -- rather, I want emacs to handle the authentication
I am trying to use auth-sources and secrets to achieve this


texts: edit via tramp/ssh fails on Solaris host

texts:
I recently upgraded my Emacs to 25.2.1 via dnf package manager (Fedora 25) and the edition of remote files via tramp and ssh is failing on Solaris 10 hosts (The same kind of editing is working on a Linux). Before the upgrade, I had no problem with Solaris.

I have got some details by increasing tramp-verbose to 4:

  13:52:52.259282 tramp-barf-unless-okay (1) # File error: ‘tramp-histfile-override’ uses invalid file ‘~/.tramp_history’

tramp-histfile-override seems to be a new thing introduced with Emacs 25.2.

By trial and error, I have found that the following make it work:

(setq tramp-histfile-override ".tramp_history")

Simply replacing ~ by $HOME do not work neither. So it seems to miss some variable expansion.

May I consider that it is a bug? If so, I did not report problems to the EMacs devs for a very long time, can you tell how to do nowadays?
If it is not a bug, would it be possible to keep the default value ~/.tramp_history for some hosts while using another value for Solaris hosts?

EDIT:
It took time to get a log of failure because the remote editing unexpectedly became functionnal as before. Today after a system reboot, it is failing again. (WTF?!)

I had suspected the mail indicator ("you have [new] mail") at login to brake the prompt detection, but it seems not to be the guilty.

I have put the log in a pastebin as it is too big for the question edit box.


texts: Is there a way to search/replace with regexps interactively using rx syntax?

texts:
I really like rx but I can't use it interactively.

Has someone already tried to extend isearch to support rx syntax?


texts: Default syntax highlighting as in "emacs -Q"

texts:
I want to use the syntax highlighting that you get when running emacs -Q.  If I run emacs -q, or run Emacs with no ~/.emacs file existent, or not load any custom theme, I get a dark-backgrounded color theme.  I also tried altering my init file, but to no avail. Disabling a custom theme also leads to the dark theme aforementioned.

How can I get the font-lock colors default in emacs -Q?


texts: How to get correct indentation for the closing parenthesis in cperl-mode?

texts:
I have problems with correct alignment of the closing parenthesis in cperl-mode. For example consider the following Perl code:

my $a = func1(
    Module::test()
  );

my $b = func2(
    test()
);

my $c = func3(
    Module::test(),
);

We see that the closing parenthesis is not correctly indented for func1, but for func2 and func3 it is correct.

In cperl-mode-hook I have

(setq cperl-indent-level 4)
(setq cperl-indent-parens-as-block t)
(setq cperl-close-paren-offset -4)

What is the reason for this behavior, and how can I get correct indentation for the closing parenthesis also for func1?


texts:
This morning, my Emacs changed its indentation rules, and now it indents by 2 spaces, specifically in JS and HTML. It even re-indents code on which I work to 2 spaces, which is unacceptable.

Please help. I need 4 spaces indentation. Please help.

What I have in my init file (none work, obviously)

(setq c-basic-offset 4)
(setq-default indent-tabs-mode nil)

(custom-set-variables

 '(tab-stop-list (quote (4 8 12)))
 '(tab-width 4))


texts: Emacs+Python+Pygame segmentation fault (core dumped)

texts:
I am using Emacs 24.5.1 for writing something in pygame in python 2.7.11. Very often (precisely speaking every second time!) when I try to evaluate the buffer (the whole file) with C-c C-c everything crashes and in the shell I get this message:

Process Python[/path/to/the/file.py] segmentation fault (core dumped)

Why is this happening and what is the way to get rid of it?

I should also mention that this only happens when I try things in Emacs, if I run the program in terminal or other editors like geany every thing works fine. But I would like to work in Emacs on my python projects. I am using Ubuntu 16.04 LTS.


texts: Preview stored register locations in a dedicated buffer

texts:
Is it possible save a bunch of point locations into registers and then navigate through them with a preview buffer?
I have tried getting along with helm-all-mark-rings and evil-jumper, but neither really provide what I am looking for. Currently I just set a bunch of registers to points of interest and fumble my way through jumping back through all of them after I forget which register holds what.


texts: Parsing parentheses: smie vs syntax table

texts:
I am maintaining a mode for a programming language with... let's say
"annoying" syntax constructs.

For example, the angle brackets (no idea if it is the correct word)
< and > are parentheses. However, the word -> is also a valid
token, does not count as a closing parenthesis, and to top it all,
should only occur inside a pair of < and >.

If I understand correctly, there is no way to get emacs to recognise
this using only syntax tables, is that correct?

Hence the question: the mode is using smie for what cannot be done
with syntax tables, and smie is also the
canonical answer to define multi-character parens. So I guess that I will have to get smie to replace the syntax table for this pair of parentheses.

The question is: what does need to be set up in smie, in order to
replace syntax table features for a particular paren pair?

The question is motivated by the manual: it is advised to let syntax tables do their job whenever
possible. Hence, I'm afraid that with a naive set-up, I will run into
problems later, or worse, that it will cause problems behind the
scenes.

What I can think of (aka the "naive set-up" mentioned above):

removing the paren category for characters < and > in the
syntax table;
adding ("<" whatever ">") in the BNF grammar;
making the lexer recognize the token < (resp >) as "<"
(resp. ">") instead of "".

Is it enough?

And, in case it would actually be, bonus question: is there any good reason to leave the handling
of sexps to the syntax table instead of smie?


texts:
almost everytime, I cope e.g. snippets from the web and paste it with M-w in a python buffer the indentation is all wrong. Sometimes slanted to the left, sometimes to the right. Often all of the copied text, sometimes only parts of it. I have this in my config

(global-set-key (kbd "C->") 'indent-rigidly-right-to-tab-stop)
(global-set-key (kbd "C-<") 'indent-rigidly-left-to-tab-stop)

but neither that nor multiple cursors are sufficient in these situations. So I searched for snippets online and included this long piece here

; indent pasted stuff correctly
(dolist (command '(yank yank-pop))
   (eval `(defadvice ,command (after indent-region activate)
            (and (not current-prefix-arg)
                 (member major-mode '(emacs-lisp-mode lisp-mode
                                                      clojure-mode    scheme-mode
                                                      haskell-mode    ruby-mode
                                                      rspec-mode      python-mode
                                                      c-mode          c++-mode
                                                      objc-mode       latex-mode
                                                      plain-tex-mode))
                 (let ((mark-even-if-inactive transient-mark-mode))
                   (indent-region (region-beginning) (region-end) nil))))))

still no luck. My python config reads

(use-package python
 :mode ("\\.py\\'" . python-mode)
 :interpreter ("python" . python-mode)
 :config
 (progn (setq python-shell-interpreter "python")
        (setq python-indent-offset 4)
        (setq python-shell-completion-native-disabled-interpreters '("python"))))

So how can I achieve to just paste in code and it is indented and aligned correctly?


texts: Was wondering if anyone knew of a way to go into the .emacs file and add an attribute to change the color of a specific string in all files it appears.  The specific example I wish to use this for would be for any given file, if the string "TODO" exists, make the color of that text red.  I want that string to stand out in my java, python, c++, etc. files so I can pick them out when easily looking around.


texts:
I've read this http://ensime.org/build_tools/gradle/ but the instructions here are wrong: ensime-gradle simply doesn't exist in jcenter repository.  There is a different version of ensime-gradle in https://plugins.gradle.org/m2/ but ensime-mode complains that this plugin is no longer supported:

You are using a .ensime file format that is no longer supported.
You must upgrade your build tool or downgrade to ensime stable.
See http://ensime.org/editors/emacs/install

Unfortunately, I have to use Gradle for this project.  So, I cannot replace it by sbt.  Does anyone know where I can find the ensime-gradle plugin of the version that does work with the resent ensime-mode?

Further examination showed that .ensime file doesn't have any values for :ensime-server-jars and :ensime-server-version. I'm trying to understand why aren't they being generated...


texts: Omitting headlines when exporting from org mode to LaTeX

texts:
Org mode headlines are turned into section{...},
subsection{...}, &c. when exported to LaTeX.  How can I ignore
them instead, making the org structure invisible in the exported
document? (preferably allowing normal behaviour only when a
certain tag (:head:) is present, but I would rather disable
automatic sectioning altogether than keep the default behaviour.)


texts: Perform calculations in orgtbl with the LaTeX syntax?

texts:
This is an orgtbl table

#+begin_src emacs-lisp :results none
(setq calc-language 'latex)
(calc-radians-mode)
#+end_src

#+attr_latex: :mode math
|----------+-----+----------|
| Fonction | var | Dérivée  |
|----------+-----+----------|
| cos(x)   | x   | -\sin(x) |
| \cos(x)  | x   | #ERROR   |
|----------+-----+----------|
#+TBLFM: $3=deriv($1,$2);RL

I would like orgmode to display \cos(x) on the @2 line when I Input cos(x).
If I input \cos(x) on the @3 line, the formula deriv($1,$2) gives an error.
How can I obtain the correct LaTeX syntax for the input and the output ?


texts: What does it mean in ebib when a field of an entry is preceeded with an asterisk '*'?

texts:
When viewing entries in a database in ebib, some fields of some entries are marked with an asterisk (*). In my case, these are usually year or month field. I don't see a rhyme or reason to the types of entries, nor can I see any common error or mistake distinguishing these marked fields from other similar ones in either the same or other entries.

I know that the manual says + is used for multi-line entries, and these are certainly not those.

What does this asterisk mean?


texts: emacs command to remove spaces until next parens

texts:
I'm looking for a command that deletes automatically deletes spaces up to the next parens:

from:

(do |
            (do-something)
    true)

to:

(do |(do-something)
    true)


texts: What is the significance of Emacs buffers having names with *earmuffs*?

texts:
There are a number of Emacs buffers where their names have "earmuffs", i.e. they have names like

*scratch*
*R*
*ESS*
*helm-mode-circe*

What is the significance of the earmuffs, and is there a reason for users creating buffers to use them?


texts: How to show diffs of merge commits in magit?

texts:
When viewing a merge commit it only shows the number of lines changed but no diff.

I know that it is possible with git show --first-parent. Is there a way to add an argument to magit-show-commit?

I'm aware that I can just diff from the commit view but I thought there may be a way to do it directly when viewing the commit.


texts:
I have an org file where I include a yaml source file:
#+INCLUDE: ".myfile.yaml" src yaml
This is good when I want to export to pdf or html to be as verbatim code. But is there a simple way to format the yaml in either the exported pdf or html? So that it renders in a nice way to read not as verbatim code?


texts:
A lot of emacs configurations shared publicly have this format:
;; 01-something.el
(provide 'something)

;; init.el
(require 'something)

Suppose I'm writing a defun named "s-join" inside 01-something.el
Suppose somewhere during init.el initialization, magit.el loads
up s.el - the popular string utility package, which also has a defun
named "s-join"
So now, in any given context, how do I know what gets executed when I do
(s-join)

?


texts: fontify autoref and nameref in latex-mode buffers

texts:
When I'm in a .tex file, press M-: and run
(font-latex-add-keywords '(("autoref" "*{") ("Autoref" "{") ("nameref" "*{"))
                         'reference)

the buffer fontifies occurrences of \nameref and \autoref appropriately (and my custom-defined \Autoref. However, if I put this same code in my .emacs file (say under the :config section of (use-package auctex ... or in the latex-mode-hook), then those macros are no longer fontified as references in .tex buffers. How do I fix this?
This is a related question, but I am looking for a simpler solution that, ideally, simply incorporates the one-liner above.


texts:
I'd like to export an org file to LaTeX from the command line. I have created a file export.el with the following contents (simplified to reproduce the problem):

(require 'org)

(when (not (assoc "scrreprt" org-latex-classes))
  (push '("scrreprt"
          (assoc "report" org-latex-classes))
        org-latex-classes))

 (with-current-buffer (find-file-noselect "contents.org")
   (org-latex-export-to-latex nil nil nil t)))

And then I tried to run it from the shell:

$ emacs -Q --batch -l export.el
Symbol's value as variable is void: org-latex-classes

It seems that I am missing some org functionality. How do I find out what else I have to require in order to get org-latex-classes defined?

(Omitting the -Q option does not help either, but even if it helped my question about finding the right require would stand).


texts: In an org file, is it possible to customize the task sequence by category? For instance, if I have a meeting, I would like to have it evolving through the states TODO and DONE, while if I'm tracking my progress on a MOOC, I may want to have TODO, STARTED, SUSPENDED, COMPLETE. Any hint?


texts:
Right now the font in the menu bar is way too big, so I would like to add a line to my .emacs file that regulates that font size.  I already have a line that takes care of the buffer font size, but it doesn't affect the menu.

Context: I am sshing into a unix machine from my Mac, and launching emacs from the terminal there.


texts: Prevent * from bolding text when creating a headline

texts:
When I start typing several stars to create a new headline, like ***, emacs starts bolding some of them, making the first and the last invisible. This makes it hard to know what headline level I am at, because it bolds and unbolds them as I keep adding more *.

This did not use to happen before. Has anything changed?

How can I make *** at the beginning of a line just behave like a literal ***, but only for headlines?


texts: Sending an s-expression to another buffer

texts:
I'm currently working in Clojure with Arcadia, which is requiring me to use a REPL that doesn't have support with Cider. This has been giving me some trouble given how I usually code, so I'd like to know how I can take a given s-expression and send it to a buffer named *inferior-lisp* with a return on it so that it will automatically evaluate. Preferably with a way to also return the printed result back into the file at the end of the line in a comment.

I've looked over the documentation for Emacs and I'm having difficulty getting a handle on exactly how I would do this with an interactive function, so any help would be appreciated!


texts: Force one window when opening multiple files

texts:
Any time I open multiple files I'd like emacs to only show me one buffer. I do not want any split windows. This would save me a keystroke every time.
I learned I could do away with the buffer list from this post with (setq-default inhibit-startup-buffer-menu t). But, now another buffer just replaces what would have been the buffer list. Any way to force only one window when opening multiple files?


texts:
I try to compile gccemacs (emacs feature/native-comp branch) on windows 10, thanks to msys2/mingw64 and the libgccjit package recently available.
Here is the error :
../../src/comp.c: In function 'Fcomp_el_to_eln_filename':
../../src/comp.c:4110:36: error: expected ')' before 'PATH_REL_LOADSEARCH'
 4110 |    Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/")));
      |                                    ^~~~~~~~~~~~~~~~~~~~
      |                                    )

Gcc version is 10.2.0.
It is strange because PATH_REL_LOADSEARCH is not defined anywhere in the build directory. It does not appear either in nt/epaths.nt
What is happening ?


texts: Change modeline background when in normal evil mode?

texts:
how do I change the background of current line when in (evil) normal mode?

I used it in Vim to be able to tell when I am in normal mode or not.

(I am using the terminal app and I prefer to keep the cursor a rectangle so I need a different visual aid.)


texts: The release notes for magit 2.1.0 state "Branch descriptions can now be displayed in the refs or status buffer". However, I can't find these features documented in the info pages. I am using magit 20150701.1326.


texts: What is the difference between these two lists?

texts:
I'm reading An Introduction to Programming in Emacs Lisp by Robert J. Chassell.
When the book is introducing setcar, it points out that when we use this function to a list, the list should be initialized in this way:
(setq list1 (list 'a 'b 'c))

instead of
(setq list2 '(a b c))

And then
(setcar list1 'A)

But if I evaluate list1 and list2, Emacs gives me the same list (a b c).
I don't see any difference here. As a matter of fact, (setcar list2 'A) is also evaluated successfully.

Page 76
...Because we intend to use setcar to change the list, this setq should not use the quoted form '(antolope giraffe lion tiger), as that would yield a list that is part of the program and bad things could happen if we tried to change part of the program while running it.
Generally speaking an Emacs Lisp program's components should be constant (or unchanged) while the program is running. So we instead construct an animal list by using the list function, as follows:
setq animals (list 'antelope 'giraffe 'lion 'tiger))


texts: How to manual set the specified paragraph to compare in ediff

texts:
For example, the following case.
It seems the system mistakenly compare wrong paragraph.

What I want to compare, for example, is the public static... with public static....
How can I do that? Thank you.


texts: Yasnippet: How to create multiple snippet key bindings

texts:
I have a yasnippet with # binding: TAB f o o in the header.  This is processed by the yasnippet library as 9 102 111 111.  With respect to a keymap of a major-mode, both \C-i and (kbd "TAB") are converted to the number 9 when said keymap is set up.  However, both [(tab)] and (kbd "<tab>") are converted to tab when the the major-mode keymap is set up.

A yasnippet with a key binding in the header consisting of TAB f o o will not trump/supersede a major-mode keybinding of [(tab)] or (kbd "<tab>").

Q:   How can I set up two (2) different yasnippet header keybindings to cover both situations that may exist in a particular major-mode; i.e., a major-mode key binding that uses a number 9 and also a key binding that uses a tab?

Here is a link to a related thread, which is interesting, but does not go as far as I would like in order to be able to answer this question:  What is the difference between TAB and <tab>?