texts: I cannot type left open bracket into buffer

texts:
I have a very weird problem, I cannot type left open bracket character ([) into any buffer. Bracket itself is recognized when I:

type anywhere outside emacs
type in minibuffer
use it as part of command ([[ in evil normal state or C-c [ in reftex work as expected)
launch emacs -Q, then it works in buffers

After typing [ it looks like this:

When I try to describe [ with C-h k, it's treated as prefix, not as all the other chars (which do self-insert-command).

I can't manually bind inserting [ to [, it's not recognized. My current workaround is like this:

(global-set-key (kbd "M-[") (kbd "C-x 8 RET L S B R RET"))

This interactively selects "LEFT SQUARE BRACKET" in C-x 8 RET (insert char) command in my ivy-flx, but it's slower and annoying.

I'm not on macbook, as they seem to have related problems (https://stackoverflow.com/questions/3376863/unable-to-type-braces-and-square-braces-in-emacs), I'm on Arch Linux, with emacs 25.2.1.

After turning evil-mode off the problem persists, so I guess that's not that.

My config is here: https://pastebin.com/8FLSkbAA.

Any feedback really appreciated!


texts:
I've installed calfw to have a better calendar view in org mode

https://github.com/kiwanami/emacs-calfw

Following instructions I arrived to:

the command `cfw:open-calendar-buffer', switch to the calendar buffer.

My question is very basic/newbie: how to do such cfw:command thing?


texts:
I've seen this sort of thing a few times:

(mapconcat 'identity '("" "home" "alex " "elisp" "erc") "/")
   => "/home/alex /elisp/erc"

which means mapconcatwants a function in the second position, hence just shove it the "identity" function if you don't want anything done to your input list first. But this

(defun shk-yas/helm-prompt (prompt choices &optional display-fn)
  "Use helm to select a snippet. Put this into `yas/prompt-functions.'"
  (interactive)
  (setq display-fn (or display-fn 'identity))

has me confused. Likewise this

(org-element-map (org-element-parse-buffer) 'headline #'identity)

I assume it has something to do with the code calling a function, but we don't want to give it one -- other than something reflexive like an identity. Again, the first example is clear, but not so much the next two.


texts: How to pass an optional agrument to kill-emacs?

texts:
I would like a way to make emacs to return a non-zero exit code when exiting.
This page https://www.gnu.org/software/emacs/manual/html_node/elisp/Killing-Emacs.html lists the command
kill-emacs &optional exit-data
as a mechanism for making emacs return with non-zero return code, stating "If exit-data is an integer, that is used as the exit status of the Emacs process".
How do I add this optional exit-data?
I have tried:

Interactively using M-x kill-emacs but cannot type a space after that.
Setting up a binding in my init.el using (global-set-key (kbd "C-x C-M-c") 'kill-emacs), but do not know the syntax well enough to pass an argument.

I see this is related to How to set the exit status for emacsclient and How to make emacs or emacsclient exit with nonzero return code? , but I cannot get the answer I want from those questions/answers.
Please can someone explain how to quit emacs with a non-zero return code and/or provide the syntax to setup a keyboard binding.


texts: Why is (point-min) much more popular than 1?

texts:
I searched accross all Emacs Lisp files in Emacs Git repo, and found (goto-char (point-min)) occurs 3621 times and (goto-char 1) occurs 31 times. Personally, I see lots of (point-min) but none 1, even in many cases, it's 100% sure that the region is not narrowed. So here is my question: is (point-min) still preferred than 1 even in un-narrowed buffer?

I guess 1 is faster than (point-min), no mater how slight it is, because 1 is constant while (point-min) is a function call. Besides, 1 is much shorter than (point-min), 1 character v.s. 11 characters.


texts:
I use helm a lot. I have a problem setting colors. In my init.el I have
(require 'helm)
(require 'helm-config)

;; change active line color
(set-face-attribute 'helm-selection nil
                   :background "red"
                   :foreground "white")

Supose I have the situation in the picture below where I search for XXX. In C the helm-occur buffer uses red/white colors for the selected line. But in the parent buffer in point B I still have green and purple for the pattern match. I'd like to change the colors in B so that they match what happens in C. I suppose I should do something like the code above, but I don't understand what controls the colors in B


texts: Perp-mode - open new blank tab without prompts?

texts:
I'm trying to replicate vims :tabnew functionality, which just creates a new empty tab (perspective). All the commands I've looked at prompts for confirmations and names etc. They clone the current tab and do not automatically switch.

Is there a command that will create a new (empty) tab, give it a default name (I'll name it later if I want) and switch to it?


texts: Different color theme for scratch buffer

texts: I'd like my *scratch* buffer to have it's own color theme, different to the one I use elsewhere, so that I know when I'm working there. How can I do this?


texts: Running flyspell on Latex files in batch-mode

texts: I'd like to run flyspell on several Latex-files in the same directory and output all the words which are misspelled.


texts:
Is it possible to have linum-relative disregard folding?  The default works poorly with evil <count>j/k-jumping and ex-commands such as -13t. in org mode.

(To comments: I said 'screen lines' but that's not what I meant. Sorry.)


texts: auto complete "on fly" and select fast any command

texts:
windows 10, emacs 26.1,

M-x occur

And if want to execute, e.g. command "occur-mode" I need to

Press -
Press TAB
Input mode

OK, it's work. But it not very conveniently. Is it possible to run command occur-mode faster? Maybe has some package for this?

P.S. I know about helm package. But I don't like it.


texts: general function to concat token at point with function and send to *R*

texts:
I'm moving my R setup over to emacs and ess -- and am struggling with the emacs / LISP customisation process.

In an answer to another question, I learnt how to create a function that concats a function name with the token at point and sends it to *R*.

This was great as a once off -- but now my .emacs is filling up with boilerplate code (see the code block at the bottom).

What i'd really like is a way to declare mappings in a single line:

(define-key ess-mode-map (kbd "C-c s") _concat_summary_token_)
(define-key ess-mode-map (kbd "C-c p") _concat_print_token_)

The below code-block is an example of what i have at the moment -- two is okay, but i have ten already and plans to add more  ... so i'm going to get lost in boilerplate!

(defun r-summary-at-point ()
  (interactive)
  (let ((sym (ess-symbol-at-point)))
    (if sym
        (ess-send-string (get-buffer-process "*R*")
                         (concat "summary(" (symbol-name sym) ")\n") t)
      (message "No valid R symbol at point"))))
(define-key ess-mode-map (kbd "C-c s") 'r-summary-at-point)

(defun r-print-at-point ()
  (interactive)
  (let ((sym (ess-symbol-at-point)))
    (if sym
        (ess-send-string (get-buffer-process "*R*")
                         (concat "print(" (symbol-name sym) ")\n") t)
      (message "No valid R symbol at point"))))
(define-key ess-mode-map (kbd "C-c p") 'r-print-at-point)


texts: Defining variables in org mode using tables

texts:
I often want to define a whole bunch of variables at the top of an org file. In some cases I think it would be really nice to define all the variables in a table. So far, the best solution I've come up with is this:
#+NAME: variables
| Variable | Value      | Description |
|----------+------------+-------------|
| user1    | alice      | Manager     |
| user2    | bob        | Developer   |

#+NAME: lookup
#+begin_src emacs-lisp :var data=variables var="a var name"
  (nth 1 (assoc var data))
#+end_src

#+begin_src sh :var user=lookup(var="user1")
 echo $user
#+end_src

#+RESULTS:
: alice

That works, but the syntax :var user=lookup(var="user1") is verbose, and it gets tiresome to call lookup in every :var header argument. I'm wondering if there is a way to register each variable and value in the table as though they were defined like this:
#+NAME: user1
: alice

#+NAME: user2
: bob

That way, you could write source blocks with simple and familiar
:var header arguments, like:
#+begin_src sh :var user=user1
  echo $user
#+end_src

#+RESULTS:
: alice

So I guess my question is: is there a way to "register" the variables/values in the variables table in such a way that would let me use them like :var user=user1?
Or even just an alternative way to do something similar that you find works for you?
EDIT: I perused the org source code a bit; I don't see any super easy way to do this. Maybe the best idea would be to introduce a new header argument, like #+begin_src :tblvar user=user1, which resolves variables defined in a table.


texts: How can I abort key sequence with the escape key in Evil?

texts: When I enter C-x ESC I want the sequence to stop or cancel and I don't want Evil to wait for the next key or key chord in the sequence. Is there a way to achieve that?


texts: How to get a list of all the daemons running?

texts:
I use one daemon per project (so that when I open the client, they don't share buffers). I'd like to get a list of all the daemons that are running.

I tried using lsof -c emacs | grep "TYPE=STREAM" but that doesn't narrow it down sufficiently.

Is there a better way to go about it?


texts: Is it possible to get stack trace of currently running code? Or profile? Or how do you diagnose „hangs”

texts:
I look for ideas, how to diagnose reason of Emacs freezes (by which I mean taking 100% CPU and being irresponsive for some time). This question is not about any specific case¹ but about approach…
Is it possible to ask Emacs „show me/dump somewhere current stack trace(s) of all currently running Lisp thread(s)”? Or maybe „dump stack trace very 10 seconds somewhere”? Sth I could do to check what's going on once I see my emacs frozen…
Or, is it possible to enable some kind of global profiling (with output put to some disk file at regular intervals) so I could look there for likely culprit?
Or, is there any other trick? What would you do if you saw misbehaving Emacs and bisecting all libraries would not seem promising²?

¹ Currently I experience two problems:

from time to time, Ctrl-Y takes 10-30 seconds (and Emacs takes 100% some CPU core during this time),

from time to time Emacs turns sluggish (albeit works more or less properly), and it turns out one of Emacs processes takes 100% of CPU

Both surely are related to some rogue lisp code (I load plenty of melpa modules) or caused by unexpected relationship of some modules, and it is fairly likely that it is my very specific configuration what makes them appear.
² My current problem appeared after I made major package-update which installed many updated versions of various packages and to which I also added a couple of new modules. Bisecting that doesn't seem promising as sometimes it takes a day or two before the problem appears, reverting to old versions for good also is not sth I would like…


texts: ess: transform a text selection into an R vector

texts:
Is there any ess function that does the following? Assume you have the line in Emacs like this
1 2 3 4

then once selected (e.g., using the mouse), it is transformed into
c(1,2,3,4)

It would be a wonderful tool. I copy and paste stuff that I transform into vectors quite often. Also, it would be great to have a function that if you select
A B C D E

it produces
"A", "B", "C", "D", "E"


texts: Is it possible to have the entire org-table use math environment?

texts: I have an org-mode table that needs to have some math text in each cell. Wrapping every cell with $ both looks ugly and takes much more space than it deserves. Is there any way to somehow put the whole table in math (LaTeX) environment so that all text inside the table would be interpreted as formulas?


texts: Why can't TRAMP assume current host for `sudo::`?

texts:
Are there any technical reasons or use cases for why sudo:: in TRAMP cannot use the rightmost host to the left of it, instead of localhost?
When I do /ssh:myname@my-remote-hostname.example.com|sudo::/tmp/file, I would expect the sudo:: to implicitly use root@my-remote-hostname.example.com.
More generally, when multiple SSH hops are chained together, such as in/ssh:jumpbox.example.com|ssh:remote.example.com|sudo::/tmp/file, I would expect the sudo:: to always use the rightmost host to the left of the sudo::.
I expect this because from a user interface and experience perspective, to me this seems like the obviously more intuitive and most convenient behavior for it to do.
But this does not happen. Instead, sudo:: seems to always implicitly use root @ the local host.
I understand that this is how it is. What I don't understand is why? Are there technical reasons for why implementing this would be difficult, or common use cases I am not imagining that would be broken if this was implemented?


texts: Forcing lexical-scope in the middle of dynamic-scope

texts:
Today I ran head first into lexical vs dynamic scope in Emacs Lisp. Gist of it is I have a macro defined in lexical scope that expands into a `defun'. Let's say something simple like this:

;; -*- lexical-binding: t; -*-
(defmacro bazmacro (a)
   `(defun baz ()
      (princ ,a)))

By chance I forgot to enable lexical scope in my tests file and bafflement followed:

;; no lexical scope here
(let ((b 42))
   (bazmacro b)
   (baz))
;; => 42
(baz)
;; => Error symbol variable is void b, duh

This of course expands into:

(let ((b 42))
   (defun baz ()
     (princ b))
   (baz))
(baz)

and after sufficient amount of head scratching and experimentation you figure fml the above defun doesn't create a closure! Wat! Wait, have I forgotten to enable lexical scope?

In a language like Elisp where dynamic and lexical scope co-exist like they do that raises some interesting questions. Strong case can be made that the above is by design, and I for one concur. But I know for a fact as that library designer that wasn't my intention at all. Of course, the end user must know what they're doing and all that. Leaving questions of right or wrong, good idea or bad idea aside, I had the following thought.

Could I hijack the scope at the call-site just for the extent of my macro body? This led me to the following snippets:

(lexical-let ((b 42))
   (defun baz ()
     (princ b)))
(baz)
;; => 42

;; but then
(let ((c 24))
  (lexical-let ((b 42))
    (defun baz ()
      (princ (vector b c)))))
(baz)
;; => Error, obviously, since `lexical-let' forces us to be explicit about our env

;; How about that
(let ((a 24))
  (eval
   '(let ((b 42))
      (defun bazz ()
        (princ (vector a b))))
   'lexical))
(bazz)
;; => Error, well that's disappointing

In lexical scope I could create a temporary closure with lambda, extract its environment and pass it to the above eval, so that bazz gets to share said environment (feels almost like being in Racket with its syntax objects that carry their lexical env). Having read relevant INFO sections, the way dynamic scope works is by setting symbol's value cells and maintaining a simple stack discipline. So, the closure trick would only work in lexical scope, sadly.

Question: is there a way to get at whatever stands for the current environment while in dynamic scope, convert it into an lexical env alist to be used in eval? Or is there a better tried and tested way?


texts: What does "less-than" key "greater-than" mean in terms of keybindings?

texts:
I'm trying to define a prefix keymap for a minor mode, but I'm getting a result I've not seen yet:

`link-grammar-mode' Minor Mode Bindings:
key             binding
---             -------

<C-.>           link-grammar-prefix-map

<C-.> <p>       link-grammar-parse-paragraph
<C-.> <r>       link-grammar-parse-region
<C-.> <s>       link-grammar-parse-sentence

Here's how I've defined it:

(define-prefix-command 'link-grammar-prefix-map)

(define-key link-grammar-prefix-map [s] 'link-grammar-parse-sentence)
(define-key link-grammar-prefix-map [p] 'link-grammar-parse-paragraph)
(define-key link-grammar-prefix-map [r] 'link-grammar-parse-region)

(define-minor-mode link-grammar-mode
  "Enables display of the parse of the natural language text
produced by link-grammar parser library"
  :initial-value nil
  :lighter " LG"
  :keymap '(([C-.] . link-grammar-prefix-map))
  :group 'link-grammar
  (run-hooks link-grammar-hooks)
  (message "link-grammar minor mode activated"))

Could please anyone explain what happened? I can see the map added to minor-mode-map-alist, but the keys aren't "activated".


texts: How to add matlab integration-spacemacs?

texts:
I already installed matlab-mode from the package list. However, not sure
 where to add the path in  ~/.spacemacs. Its a huge file, and the code structure look different from the path file:

(autoload 'matlab-mode "matlab" "Matlab Editing Mode" t)
(add-to-list
'auto-mode-alist
'("\\.m$" . matlab-mode))
(setq matlab-indent-function t)
(setq matlab-shell-command "matlab")


texts: Using a variable as the REGEXP in `query-replace-regexp`

texts:
I know, Emacs allows calling ELisp while replacing a text with a regex, aka C-M-%, which is bound to query-replace-regexp. I'm trying to make use of that to store an unwieldy regexp as a variable, so instead of writing it out every time, I could just extract it from a variable.
For the sake of simplification, in the testcase here I'm using just a text, so no backslashes are involved:
(setq foo "text")

Text is:
text text

Here's what I tried as the REGEXP in query-replace-regexp:

\,foo
\,'foo
\,(eval 'foo)
\,(eval foo)

None of those work for me. How can I make it work?


texts: Report time at whole hours by prompting mini-buffer

texts:
Reference to 31.10.6 Appointments of Emacs Manual

It provides a handy solution to report hour and remind appointments:

  For example, suppose the diary file contains these lines:
  =M-x appt-add= adds entries to the appointment list without affecting your diary file. You delete entries from the appointment list with =M-x
  appt-delete=.

Then if set the minutes to warning as 0 minutes to remind whole hours, it becomes a alarm to report whole hour to prompt a mini-buffer.

For example, M-x appt-add a whole hour "9:00pm" and set the warning as 0 minute. When it comes to 9:00pm, a mini-buffer would be prompt to report the current time.
At this moment, appointment transforms itself as an alarm to report whole hours.

Unfortunately, the appointment is one-off and it's cumbersome to set alarms manually every day.

How could have an alarm to report whole hours using appointments or any alternative solutions?


texts: How can I get the list of recentf files from bash / cli?

texts:
How can I retrieve the list of recent files in bash?

I'd like to get this set of files so I can use it with rofi.

I could manually parse the data file that looks something like:

;;; Automatically generated by ‘recentf’ on Sat Apr 20 13:21:26 2019.

(setq recentf-list
      '(
        "/home/chris/dotfiles/Human-Friendly-Commands/modules/misc.sh"
        "/home/chris/dotfiles/Human-Friendly-Commands/commands.sh"
        "/etc/nixos/chris.nix"
        "/home/chris/fromLaptopt/usbflash/Haskell/HeliumGrape/src/DiscreteOscillators.hs"
        "/home/chris/fromLaptopt/usbflash/Haskell/HeliumGrape/src/MyDebug.hs"
        "/home/chris/Haskell/HeliumGrape/src/Main.hs"
...

But if there is a more idiomatic way that would be ideal.


texts: Multihop tramp adds extra carriage returns and gets confused by the output

texts:
I am trying to use Tramp to log into a Docker container running on a VM.

My Docker-related setup looks like this:

(add-to-list 'tramp-methods
             '("docker-exec"
               (tramp-login-program "docker")
               (tramp-login-args
                (("exec" "-ti") ("%h") ("/bin/sh")))
               (tramp-remote-shell "/bin/sh")
               (tramp-remote-shell-args ("-i") ("-c"))))

I can use this on my machine to access directories inside container, but when I try to "hop" to remote machine like this: C-x C-f/ssh:root@vm|docker-exec:ed703f92ae19:/ Tramp will at first get confused about ls command because it would add a ^M characters at the end of the line and thus tramp-find-executable will return something like /usr/bin/ls^M, which would generate invalid command.

I was able to overcome this with:

(defun my/tramp-find-executable
    (func vec progname dirlist &optional ignore-tilde ignore-path)
  (org-trim (funcall func vec progname dirlist ignore-tilde ignore-path)))

(advice-add 'tramp-find-executable
            :around 'my/tramp-find-executable)

But now I get this error:

byte-code: Wrong type argument: number-or-marker-p, //DIRED-OPTIONS//

And the log looks like this:

//DIRED-OPTIONS// --quoting-style=literal
///c92423c4fd16f4857a1b9d765f804f3e#$
17:32:16.175776 tramp-get-connection-property (7) # check-remote-echo nil
17:32:16.175817 tramp-get-connection-property (7) # check-remote-echo nil
17:32:16.175869 tramp-wait-for-regexp (6) #
  total 292
  drwxr-xr-x  18 root root   4096 Feb 24 09:08 .
  drwxr-xr-x  18 root root   4096 Feb 24 09:08 ..
  -rwxr-xr-x   1 root root      0 Feb 24 09:08 .dockerenv
  -rwxr-xr-x   1 root root      0 Feb 24 09:08 .dockerinit
  lrwxrwxrwx   1 root root      7 Mar 30  2015 bin -> usr/bin
<<< skipped >>>
  drwxrwxrwt   2 root root   4096 Feb 24 15:29 tmp
  drwxr-xr-x  13 root root   4096 Mar 30  2015 usr
  drwxr-xr-x  18 root root   4096 Mar 30  2015 var
//DIRED// 59 60 108 110 158 168 216 227 275 278 337 340 388 391 439 443 491 494 553 558 619 629 677 682 730 733 781 784 832 836 884 888 936 939 987 991 1051 1058 1106 1109 1157 1160 1208 1217 1265 1268 1316 1319 1367 1370
//DIRED-OPTIONS// --quoting-style=literal
///c92423c4fd16f4857a1b9d765f804f3e#$

I don't know what Tramp was trying to do, when it received this error, so I cannot think of a way to fix it.  But, maybe this is a known bug? Or, maybe I need some extra settings for Tramp so that it would not add ^Ms? (I doubt they are in the original output since both machines run Linux, both CentOS.


texts:
I'm trying to add support for imenu in a major mode I currently writing.
Reading documentation I've found that its API looks simple and all I want to do is to write a function and bind it to imenu-create-index-function.

Documentation for imenu--index-alist also declares something called nested sub-alist:

  A nested sub-alist element looks like (INDEX-NAME . SUB-ALIST).
  The function ‘imenu--subalist-p’ tests an element and returns t
  if it is a sub-alist.

Does it mean that one could make imenu have nested structure like?

- index 1
  - sub-index
    - ...
- index 2

I've tried to return following from funciton bound to imenu-create-index-function:

'(("item 1" . '(("sub-item" . 1))) ("item 2" . 1))

And error says that it violates integer-or-marker-p at '(("sub-item" . 1)).

If nested structures are possible, how to form them?


texts: I was curious if there was a way to get highlighting/indentation for any JavaScript that's inside of HTML5  tags? I don't frequently use JavaScript but for a class I'm in we're working with it. I assume it would be a matter of creating a JavaScript minor-mode and then hooking that into the HTML5 mode?


texts: Fold and select the definition of a function in python?

texts:
In python mode (the one that Emacs uses to open python script by default), can I fold the definition of a function?

How can I quickly select the entire definition of a function? (so that I can copy and paste)

If not, which python package/IDE shall I install in emacs? Thanks.


texts: How to find the window under the mouse pointer

texts: Is there a function that finds which Emacs window within a frame the mouse pointer is over without clicking or moving the mouse?  I know that (mouse-position) includes the frame the mouse is over, but I can't find a function that gives the window.  Searching the web, stackexchange, etc, hasn't brought up any possibilities, either.


texts: "Fix Continuation Lines" message in modeline for every line in a mu4e email

texts:
Whenever I do M-x mu4e-compose-new and select a context, then type up an email, and then do M-x message-send-and-exit, my cursor jumps to the first line in my email (after "--text follows this line--") and a message appears in my modeline that says "Fix continuation lines? y/n". If I do y ENTER , a space is added to the front of the line, the cursor jumps to the next line, and I get the same question in my modeline. When the cursor reaches the end of the email, I get a confirmation to send, and then my email sends. However, the email is received as blank, with a subject only, by the recipient.
If I do n ENTER instead, the cursor jumps to the next line, and I'm presented with the message again. I repeat until the end of the email, I get the message, Send anyway? y/n. I do y ENTER, the email sends, and it is received normally by recipient.
My emacs version is GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-09-19
My mu / mu4e version is 1.4 (though I recall this happening on 1.3 as well).
How can I have my messages send normally, instead of blank, without needing to press n ENTER for every line in my email?
I checked this stackoverflow question and didn't find it to be relevant, I have no function named t and furthermore it appears my headers are correct:
Here is a picture of me partway through doing y ENTER for every line of an email. The email will be received as blank.
EDIT:
According to this old mail list post, this can happen if I don't have a newline after the --text follows this line-- message. While I try to put a newline there, when I then do M-x message-send-and-exit, I'm presented with a more plaintext looking buffer that doesn't seem to have the --text follows this line message. I wonder if that's related?


texts:
How would one make sure that the .emacs (init file) automatically initializes when you open Emacs?

I am currently running on Windows, if it's relevant. Thus far I have to locate and evaluate the .emacs file every time I open Emacs, despite having package-initialize which is reported to do this automatically.

There are certain packages and customizations that are almost necessary to the "proper" functioning of Emacs, and so it is not hyperbolic to describe this as critical beyond the significant inconvenience it poses.


texts: How to automatically select apropos buffer when it is displayed

texts:
It is possible to automatically select *Help* buffers when they are displayed by doing (setq help-window-select t) (relevant question: How to close help buffer without moving to it?).
Is there a similar setting for *Apropos* buffers? When I use apropos using C-h a, the resulting apropos buffer is not automatically selected. I have to switch to it using C-x o. Is there a way to switch to the apropos buffer automatically?


texts: I'm working with large, extra wide data files I probably should just be viewing in Excel... but I'd rather stay in Emacs. Is there an elisp function to search (and fontify) just on the current line?


texts:
I have 5 tasks from two org files - test and test2. I want to sort all tasks by only priority in the org agenda (To Do list, C-c a t). By default, I understand that they are ordered by (org-file name and within that descending order of priority). So I changed, (org-agenda-sortingstrategy to priority-desc). However, the ordering of tasks is somehow not happening by just priority-desc.

I am not even able to understand what is the logic being applied to sort this. Any help in this matter will be really helpful.


texts:
I am working on implementing my own feature request -- http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31601 -- to give wdired the ability to handle a dired- buffer that contains an arbitrary list of absolute paths to directories and files; e.g.,

(dired (directory-files-recursively "/path/to/directory" "" 'include-directories))

However, the files and directories may not necessarily be recursive -- i.e., dired-mode can handle creating a buffer containing an arbitrary list of files and directories.

I have added draft code to wdired that places read-only text properties on the file-name-directory.  That way, a user cannot edit those portions of the path while in wdired-mode.

The next step is to process the renaming of files/directories, which requires they be done in a hierarchical order.  For example, a user may have renamed a directory and a file:

OLD NAME:   /path/to/directory

NEW NAME:   /path/to/the_directory

OLD NAME:   /path/to/directory/file

NEW NAME:   /path/to/directory/the_file

OLD NAME:   /path/to/different_directory

NEW NAME:   /path/to/the_different_directory

OLD NAME:   /path/to/different_directory/different_file

NEW NAME:   /path/to/different_directory/the_different_file

If we first rename the directory from /path/to/directory to /path/to/the_directory, then rename-file will be unable to rename /path/to/directory/file because the directory no longer exists; i.e., the directory was changed to the_directory.

Therefore, it makes sense to sort all of the files and directories into a hierarchical order such that the deepest file or directory is processed fist in time when renaming the files/directories.  For example, if we have a set of files that are 5 directories deep, then those should be processed before processing directories or files that are less than 5 deep.

Q:  How to sort a list of files/directories by hierarchical depth?

WORKING LIST:

'("/path/to/different_directory/different_file"
  "/path/to/directory/file"
  "/X/Y"
  "/a/b/c/d/e/f"
  "/1/2/3/4"
  "/A/B/C/D/e"
  "/x/y/Z"
  "/Z"
  "/path/to/different_directory"
  "/path/to/directory")

RESULT DESIRED:

'("/a/b/c/d/e/f"
  "/A/B/C/D/e"
  "/path/to/different_directory/different_file"
  "/1/2/3/4"
  "/path/to/directory/file"
  "/x/y/Z"
  "/path/to/different_directory"
  "/path/to/directory"
  "/X/Y"
  "/Z")


texts: Can you have org-mode headings with checkboxes?

texts:
I'd like to have this sort of functionality:

* TODO master task
** [ ] my subtask 1   << checkbox in heading :-D
** [X] my completed subtask

With the C-c C-c combo checking/unchecking such checkmarks.

The reason is that I use sub-tasks extensivley but I don't want them to appear on my agenda.

Is this possible somehow?


texts:
I have multiple short videos in a directory and I have to play all of them in a queue.

By using a file manager(Nautilus), I can select videos and then right click, select vlc and all videos will be played in a queue.

In dired, i can place point on a video and press enter which plays that video.

I tried selecting/marking multiple videos and press enter but i cant get  all videos to play. How to do achieve that in emacs?


texts: How do I run (async-)shell-command (but no other shell-mode buffers) in view-mode?


texts:
My emacs frames have an unwanted border, even if maximized:

The blue thing at the bottom is the border drawn by the openbox. The dark gray/black interior is Zenburn's background. But what is this light gray thing between them, and how do I disable it? It is there even if the window is maximized :(

EDIT: To clarify, I am asking not about the fringe which is only on the left side of the picture, but about the lighter grey border which is both at the bottom and at the left side. It seems to be window manager specific: I see it with openbox and xfwm, but it is absent if I use xterm session.


texts: Always open new files in the same window

texts:
When I open a file externally - through the terminal or the file manager GUI, it opens in a new window.

How can I always open a file in a new buffer of an existing emacs session?


texts: company-mode doesn't work on latex environment

texts:
I've installed the company package in order to get an auto-completion functionality. It works well in my ESS environment, but no in latex. In fact, no completions are showed in latex buffers when I activate M-x company-mode. What could be the problem?

Here it is my .emacs config for latex

(setq TeX-parse-self t)
(setq-default TeX-master nil)

;;
;;ispell config
;;
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "es_ES") ;; Change dictionaries here!
(setq ispell-local-dictionary-alist
      '(("es_ES" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil nil nil utf-8)))

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)

(setq TeX-output-view-style
    (quote
     (("^pdf$" "." "evince -f %o")
      ("^html?$" "." "iceweasel %o"))))

UPDATE:

Removing auto complete configuration for other environments from the init file and adding the following line solves the problem.

;;
;; COMPANY
;;

(use-package company
  :ensure t
  :config
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 2)

  (global-company-mode t)
  )


texts: Emacs doesn't recognize Ctrl+2 in a terminal

texts:
Emacs version is 24.5.1, terminal is Mintty 1.1.3.

When I press C-2 in Emacs it produces M-[ 5 0 ; 5 u key which is very strange because C-1 behaves as expected.


texts: set key for 'comment-or-uncomment-region in python-mode

texts:
i want a shortcut for the nice little function comment-or-uncomment-region.
The thing is, it works fine for me in every mode using M-x comment-or-uncomment-region. And espacially it works differently (# for python and // for C++) so everything is fine here.
 But as i said i want a shortcut for this.
So i wrote the following in my init.el file:

(global-set-key (kbd "C-;") 'comment-or-uncomment-region)

This now works for all my .cpp files, where I'm in c++-mode, but in python-mode it says, this function is not on a key.
But i think its global-set, so what am I doing wrong? Or are some other functions able to unset the key (maybe in the initialization) ?


texts: Why can't I bind my function to a key or call it with M-x?

texts:
I wrote a function, and I want to call it via M-x, and bind it to a key. This is my function:

(defun my-function ()
    (message "This is a great function"))

If I try to call it with M-x my-function, I get the error: [no match] in the mini-buffer.

If I try to bind it to a key (or mouse click):

(global-set-key (kbd "C-c a") 'my-function)

It appears to work, but when I try to call it with C-c a, I get the error

  Wrong type argument: commandp, my-function

Why can't I use my function?


texts: Change org-log-done setting only for a subtree

texts:
In my configuration, I have:
(setq org-log-done 'time)

However, for one particular subtree, I want to suppress this behavior. So, closing any items here will not record a time.
Can this be done by setting some property for the heading? Or any other method?


texts: Best practice for long string literals in emacs lis?

texts:
What are best practices for handling long string literals in Emacs Lisp?
E.g.
(... stuff that causes indentation ...
                         (error "`my-config-alist' mapped command `%s' to `%S' instead of a major-mode"
                                command mode))
        10        20        30        40        50        60        70        80

I know several workarounds, all of which are awkward and worse for readability than the long line, e.g.
                         (error (concat "`my-config-alist' mapped command `%s' "
                                        "to `%S' instead of a major-mode")
                                command mode))
                         (error "%s%s%s%S%s"
                                "`my-config-alist' mapped command `" command
                                "' to `" mode "' instead of a major-mode"))
        10        20        30        40        50        60        70        80

Such situations happen frequently. If this were python, I could use implied string concatenation, such as
blocks that cause indentation:
                                assert mode, f"`config' object mapped command " \
                                             f"{command!r} to {mode!r} instead " \
                                             f"of a major-mode"
        10        20        30        40        50        60        70        80

Is there any accepted best-practice to do this in Emacs-Lisp or other lisps?


texts: Ispell + Hunspell recognizes everything after the apostrophe a different word

texts: I'm using flyspell-mode with ispell and hunspell - as the dictionary backend, the problem is: if I type a word, for example you've or you're it recognizes ve and re as individual words. I want to fix that so it recognizes apostrophes as part of words.


texts:
I have seen a lot of times that Emacs perform auto-save and I have some questions regarding it:

What are the reasons for that?
Where can I find the saved file?
What are the advantages of having it activated?
How can I deactivate it?


texts: get buffer scroll position and height (aka min and max on-screen buffer locations)

texts:
I'm interested in the region of a buffer that is visible on-screen.

How do you get the current scroll position of a buffer?  I.e. the line number of the topmost line in the viewable area?  (Given that I can use window-height to find the bottommost visible line of the buffer.)

(The point-min and point-max functions give the min and max buffer positions, but those might be offscreen.  I want to know the min and max on-screen buffer positions.)


texts: How do I specify how tags in headers are exported to HTML in org-mode?

texts:
I would like tags in headers (specifically) to export to html as links to a file of the same name, something like:
 * My first post is about dogs :DOGS:

where :DOGS: then exports as

    DOGS

instead of what it currently exports as which is

    DOGS

I assume another issue I'll have to work through is that I'd need to specify that some tags get exported (like ones in headers), while others don't (like ones in bodies).


texts: Ignore byte-compiled files without source file

texts:
I recently refactored my Emacs config, part of which involved deleting some old files which had been byte-compiled.

My new configuration (ab)uses the load-dir package to load all my customisation files in a specific directory.  The issue arises when I update my config on a different machine, those old *.elc files are still there and loaded by load-dir, causing confusion as various settings are being overridden by *.elc files.

Is there any way to tell Emacs to only consider loading a .elc file if a corresponding .el file exists?


texts:
Is there a better way to write the below code with less redundancy?

(cond
((firstFunction str1) (secondFunction str1))
((firstFunction str2) (secondFunction str2))
((firstFunction str3) (secondFunction str3))
((firstFunction str4) (secondFunction str4))
((firstFunction str5) (secondFunction str5))
)


texts: Instruct Emacs never to open files of a certain type or size

texts: In Emacs by default there is a large file warning threshold. I would prefer to instruct Emacs never to open files of a certain type or size. These are files I would prefer always to open in an external application. I now have it set up that I can use the shortcut key C-RET to open a file in an external application. Sometimes however I accidentally press RET and Emacs prompts me as to whether I would like to open the file. My preferred response would be for Emacs to do nothing, not even to prompt me. Otherwise, I would prefer to always open the type in the default external app.


texts:
I'm currently using Xemacs on Windows 10 in compatibility mode and running in VHDL-mode.

When I attempt to open the Speedbar Xemacs returns with An error occurred while opening speedbar.

I'm trying to use Xemacs speedbar to discover the VHDL code hierarchy.

I appear to have the speedbar.el etc in the lisp/speedbar directory so I'm just plain confused. What am I missing?

How can I "install" Speedbar correctly?


texts:
I'm using magit 20160517.838, Emacs 25.0.50.2

I just upgraded magit from 20160320 to 20160517 and when I try to stash I now get this issue;

magit-stash-create: Cannot save the current index state

I can still manually stash on the command line with

git stash

Update

I've put the debug into my init.el file

(setq magit-git-debug t)

Then I restarted emacs and tried stashing again but no debug console is displayed. I get the following error in my *magit-process file.

128 git … commit-tree --no-gpg-sign -m index on master: 917b40b Revert "electric-pair-mode failed with python files." -p HEAD 8e2cbf3020c9c4d509f98a1924f3d43ba0ed4f12
fatal: Not a valid object name --no-gpg-sign

I think I require updating my git as I'm running an old version '1.9.1'


texts: I have created two diary entries, I can't see them in the week agenda. Why is that? Also I would have expected 11/15 to be highlighted, or something like that, to indicate an event was planned that day.


texts: How do I tell how many lines of a specific face fit in a window?

texts:
I'm making a presentation mode where I want to vertically center some text in the window, which is the only window in the frame. I'm using a custom face so I can control how large the font is.

To horizontally center the text, I can use window-max-chars-per-line with the face argument, so I can get the number of characters put in a line.

But I also want to know how many lines are in the window. There's window-body-height, but that doesn't let me specify a face.

How can I tell how tall a window is in lines of a specific face?


texts:
Is there a way I can collapse/expand regexp matches within a line?

e.g. let's say I have this list and want to hide some parts of it temporarily:

* apple: fruit; red
* butter: dairy; yellow

when I set the regexp to ":.*$" and fold the matches, it should become something like this:

* apple...
* butter...

when I set the regexp to ":.*;" instead, and fold the matches, it should become something like this:

* apple... red
* butter... yellow

And when I expand the list, it should get back to the original view:

* apple: fruit; red
* butter: dairy; yellow

However, none of the methods I found so far doesn't seem to work this way.

I tried folding mode, but it only worked for blocks of text, and it didn't work for string within a line.

i.e. it doesn't work when I set it to hide things between ":" and ";" below. It doesn't do anything in that case. It only kind of works (but not really appropriately for my purpose) when I set it to hide things between ":" and ":" since they are placed across the lines.

When I try to hide things between ":", this

* apple: fruit; red
* butter: dairy; yellow

becomes this:

* apple: fruit; red...
: dairy; yellow

(It might be not exactly like this: I tried this yesterday and I don't remember exactly except that it didn't work fine.)

I also tried hs-hide-all with text like "{this should be hidden}" in both org mode and emacs lisp mode, but it didn't do anything. Is this function known to be tricky or something? I'm not even sure if this function is supposed to work for hiding text within a line not across lines, or I'm misusing it.


texts: org alters output of bash code blocks when run with :session

texts:
I am running a short bash command from an org mode code block, using the program fold to wrap it at 60 characters. If I run the code without a session argument, the results display as expected. However, when I set the session argument (which I have to do in the context of the long literate analysis I'm doing), some of the output characters don't appear.

Steps to reproduce:

emacs -Q

Open the following file and execute each code block in turn:

#+BEGIN_SRC elisp setup
(org-babel-do-load-languages
 'org-babel-load-languages
 '((shell . t)))
#+END_SRC

#+RESULTS:

#+BEGIN_SRC bash no session :results replace verbatim
 echo 'CCCC8,,CEFGDF,,,CC,CF:,,C8CFGFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGCFGGGG@GGGGGGGGGGGGGGGGGGGGGGGGGGGGG+FF:B3CDFGGGFGGCFDGGGFCF:,FF9>FEC,F<FEG*?FFFFFGGG*CFEEECGGGGC+>FDGGDGFDFFEEFGEGC5>5?C*CGGF+3:*<7*2>+*<9CGCD::C=*@DCFCFFGG<C9<)7*9.5<@BA*7' | fold -w 60
#+END_SRC

#+RESULTS:
: CCCC8,,CEFGDF,,,CC,CF:,,C8CFGFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
: GGGGGGCFGGGG@GGGGGGGGGGGGGGGGGGGGGGGGGGGGG+FF:B3CDFGGGFGGCFD
: GGGFCF:,FF9>FEC,F<FEG*?FFFFFGGG*CFEEECGGGGC+>FDGGDGFDFFEEFGE
: GC5>5?C*CGGF+3:*<7*2>+*<9CGCD::C=*@DCFCFFGG<C9<)7*9.5<@BA*7

#+BEGIN_SRC bash session :results replace verbatim :session my-session
 echo 'CCCC8,,CEFGDF,,,CC,CF:,,C8CFGFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGCFGGGG@GGGGGGGGGGGGGGGGGGGGGGGGGGGGG+FF:B3CDFGGGFGGCFDGGGFCF:,FF9>FEC,F<FEG*?FFFFFGGG*CFEEECGGGGC+>FDGGDGFDFFEEFGEGC5>5?C*CGGF+3:*<7*2>+*<9CGCD::C=*@DCFCFFGG<C9<)7*9.5<@BA*7' | fold -w 60
#+END_SRC

#+RESULTS:
: CCCC8,,CEFGDF,,,CC,CF:,,C8CFGFGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
: GGGGGGCFGGGG@GGGGGGGGGGGGGGGGGGGGGGGGGGGGG+FF:B3CDFGGGFGGCFD
: FEC,F<FEG*?FFFFFGGG*CFEEECGGGGC+>FDGGDGFDFFEEFGE
: 5?C*CGGF+3:*<7*2>+*<9CGCD::C=*@DCFCFFGG<C9<)7*9.5<@BA*7

Notice the difference between the two bash results blocks. In the first, the input string is folded at column 60, without any other changes. In the second, a string of characters has been deleted:

GGGFCF:,FF9> from the beginning of the third line
GC5> from the beginning of the fourth line

The fact that the deleted strings both start at the beginning of a line and end with a > suggests that the session thinks they should be redirected somehow, and in the process is dropping them completely. However, when I look at the session buffer, the output appears as expected, with no missing characters.

How do I force the babel session to leave the output alone, and print it verbatim into the org file?

GNU Emacs 26.0.90
Org mode version 9.1.4


texts: Create orgmode agenda from remote directory recursively over ssh

texts:
I've set up a vserver with my directory containing various .txt files used as Org files and other files.
Now I am trying to get my local Emacs build an agenda gathering all data from the remote files scattered in different subfolders of my remote directory nexus.
So I found this
(setq org-agenda-files
(mapcar 'abbreviate-file-name
(split-string
(shell-command-to-string "find ~/org -name \"*.org\"")
"\n")))

I customized it to
(setq org-agenda-files
(mapcar 'abbreviate-file-name
(split-string
(shell-command-to-string "ssh foo@11.111.11.11 \"find ~/nexus -name \"*.txt\"\"")
"\n")))

to filter .txt files for agenda items (.txt files work for my agenda locally - I've managed to do that). But it still won't work.
My guess: I did not write the shell query correctly.
Also, I am wondering if this would be a suited approach to check my agenda remotely from different devices. For example, it is planned to setup orgzly and termux later to also access those files.
Additional info:
The size of the nexus is about a few thousand different files and a few hundred text files with org content stretching for 500 to 5000 lines.


texts:
I am trying to establish an ox-hugo workflow using the Auto-saving feature described in the official website. However, when trying to enable it using the following snippet:

(("content-org/"
  . ((org-mode . ((eval . (org-hugo-auto-export-mode)))))))

I receive the following error:

  Debugger entered--Lisp error: (invalid-function ("content-org/" (org-mode (eval org-hugo-auto-export-mode))))
    (("content-org/" (org-mode (eval org-hugo-auto-export-mode))))

Any ideas why the official doc instructions would not be valid?


texts: I'm working on an agenda file to organize my teaching each semester. I'd like to be able to view my agenda by semester. For example, my fall semester in 2017 will begin during week #2 and will end on week #18. Thus, I'd like to view my agenda starting from Monday 9 January 2017 to Sunday 7 May 2017. Is this possible?


texts:
I'd like to use a captured columnview block as a variable for another source block. The Block of which looks like this:

#+Name: Room-Table
#+BEGIN: columnview :skip-empty-rows t
|Big ol table|
#+END:

I checked that the table properly exports, which it does. However if I try to use the data in that table like so:

#+BEGIN_SRC python :var t=Room-Table
t
#+END_SRC

I get an error that reads:

Reference not found

This is a different error than if you try to use a variable that doesn't appear in the buffer.

I've tried a few things, like tangling the block out, which doesn't work or calling it the the #+CALL: header which doesn't seem to do anything either.

Finally I looked online, however the only documentation on Dynamic blocks is very sparse, and lacking anything besides setting them up.


texts:
I'm writing a screen-shot making function, something like org-screenshot.el link but with my own percs.

I'm looking for a way to hide emacs while the screenshot is taking place and show it up again after. It is done in org-sceenshot.el in the link, but I can't figure out which command does it.

Any ideas?


texts: emacsclient -nw and strikethrough text in org mode

texts:
https://orgmode.org/worg/org-tutorials/org4beginners.html
  You can make words *bold*, /italic/, _underlined_, =code= and ~verbatim~, and, if you must, +strike-through+.

How to strikethrough a word, when writing something
in org mode

my env: emacs latest, -nw mode, terminal.app, macOS


texts:
I have very annoying problem, after I run M-x compile time to time
cursor jump from middle of buffer to the first line.

I want to find out culprit (I found mode who responsible for this,
but I want to know what exactly function is causing this).

At first I just replace goto-char with my-goto-char, but it didn't show culprit - nobody calls (goto-char 1),
after that I set hook on scrolling:

(defun my-bad()
  (message "something bad happens")
  )

(defun debug--on-window-scroll (wnd new-start)
  (if wnd
      (progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd)))
       (when (and (string= (buffer-name (window-buffer wnd)) "parsing.rs")  (= new-start 1))
         (my-bad)))))
(add-hook 'window-scroll-functions 'debug--on-window-scroll)

my-bad was called, but debuger show only:

Debugger entered--entering a function:
* my-bad()
  (progn (my-bad))
  (if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad)))
  (progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd))) (if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad))))
  (if wnd (progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd))) (if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad)))))
  debug--on-window-scroll(#<window 3 on parsing.rs> 1)
  redisplay_internal\ \(C\ function\)()

so I still have no idea who scroll buffer to the first line,
any idea how to find culprit who responsible for scrolling to the first line of specific buffer?


texts: Emacs outline-mode custom heading and space between headers

texts:
I'm trying to define a structure for outline-minor-mode so I can organize my init.el conf without relying in org.
So far I could not get to work with two levels of heading, I would like to have ;;; and ;;;; as possible levels, so I could organize a little further.
My code so far:
;;; Outline-mode
;; Local Variables:
;; outline-regexp: ";\\{3,4\\} "
;; outline-heading-alist: ((";;; " . 1) (";;;; " . 2))
;; eval: (outline-minor-mode 1)
;; eval: (while (re-search-forward outline-regexp nil t) (outline-hide-subtree))
;; End:

I'm not very good at regex yet, so I'm not sure how to make it to work.
The problem is that without two levels of heading when I "hide all" the levels they got without any space or further organization like in the left image. I can try to break some lines like in the right image, but when I show/hide again the folding ignore the lines again.
I'm trying to avoid outshine and org, but I might migrate if I can't manage to accomplish the following:


texts: Start Emacs, create new file and execute functions

texts:
I would like to automate the following when emacs start:

open a new buffer
launch a foo function (create-name) that writes something
on the buffer and copy to clipboard a name YYY for the buffer
save the buffer with name YYY

Thanks for suggestions!


texts: prettify-symbols-mode and multi-character replacements?

texts:
With prettify-symbols-mode it is possible to replace strings by a character, or a character composition, e.g.

;; \lambda → λ
(push '("\\lambda" . ?λ) prettify-symbols-alist)

Optionally, it allows combining multiple characters, which will be put on top of each other, e.g. in order to create an underline bold character,

(push '("\\mathbf x" . "xx_") prettify-symbols-alist)

But does Emacs also have a feature, that allows multi-character replacements, e.g. allowing a prettification

\section{Hello World}  → ###{Hello World} ?


texts:
I was trying to figure out how Emacs renders so fast in the terminal, especially since I think it might have to redraw a large portion (or all the terminal) most of the time.  But I haven't yet dug into the code, but I did compile v25 from source.  If there's something specific to look for in the code I'd appreciate the pointer.

Does emacs use ncurses to render in the terminal? (If not, what does it use?)


texts:
Is there a way to make my document title dynamic, for instance like this :
#+Title: Annual report for year  src_emacs-lisp{(- (string-to-number (format-time-string "%Y")) 1)}

Should render as :
Annual report for year 2020


texts: What minor mode prints opening paren in the echo area?

texts: This is a really nice feature, but it only displays when inserting a paren, not when changing to a cursor position. Is there an interactive command that I can call to display this? Can I configure it to show up on cursor move?


texts: Why does sql-mode think -* starts a block comment?

texts:
While typing in a SQL mode buffer, I noticed that -* starts a block comment. Why?

It happens whenever I type an asterisk/star character (ASCII 42) directly after a simple dash/hyphen/minus character (ASCII 45).

I thought it might be due to -*- something -*- buffer hints, but it does not happen in other modes like C++ mode, so it seems to be something else. It does not depend on the SQL dialect I choose.

I tried searching in code but gave up as -* gave way too many hits (match zero or more dashes) and -\* gave none.

Maybe it's because - is the first (and second) character of a comment-start sequence (--) and * is the second character of a comment-start sequence (/*). I used M-x describe-char to find this. Following this rationale *- should work as a comment-end sequence, but it does not.

I only tested GNU Emacs version 26.2 (on Windows).

Is there any way to fix this behavior?


texts: Does a key-chord that looks to the first character, exists?

texts:
My setup

GNU Emacs GUI (version 24.4.51.1 (x86_64-w64-mingw32)
                       compiled from Harroogan Emacs.)

Package key-chord.el

Package Evil-mode

Situation

I use the Evil mode. I tried to solve my issue with the maintainer (Frank Fischer is a hero, for maintaining an awesome package) in the past: https://bitbucket.org/lyro/evil/issues/505/proper-error-handling-in-case-of-custom

So basically, I don't like the idea behind the package key-chord, because you need to press your keys simultaneously, instead rolling or typing. It will hurt your fingers in the long term, and it's not comfortable (with typing, you're rolling with your fingers). I tried to solve it with

(setq key-chord-two-keys-delay 0.4)

Ok, when typing fast, it would be workable. But if I want to jump to awindow with keys on the home-row of the keyboard, I could configure it with

(key-chord-define-global "fj" 'evil-window-down)

So, when you want to go to another window down, you're just typing fj, and you * jumps * into another window. Okay. But when you want to find the charachter j? Just press f, then wait 600 miliseconds, then press j. Simple.

Problem

This is where the problem arises. When you want to go down one line, the j key in Evil becomes terribly slow (because of the key-delay). So I'm wondering if there a package exists, that does  looks only to the first character, instead all the characters in the key-binding? Any suggestion?


texts: Is it possible to use different checkers with different flycheck-check-syntax-automatically?

texts:
I have two checkers fast-checker and slow-checker. So I want to use fast-checker with flycheck-check-syntax-automatically '(idle-change) and slow-checker with flycheck-check-syntax-automatically '(save).

Is it possible?

Or at least can I use flycheck-buffer with specific checker?
So I could do something like this

(add-hook 'after-save-hook (lambda () (flycheck-buffer `slow-checker)))


texts:
Is there a way to embed/include/reference (I don't know the proper word in emacs-speek :)) to headings so that their contents show in a different place?

The idea is to reduce duplications and bookkeeping while maintaining different "views" into e.g. project tasks, potentially using shared files

Example

I write a journal entry in diary.org about a meeting and come up with TODO headings and task lists:

* Diary ...
** 2019-07-24 Meeting recap
I learned a lot of cool things. Bob was really nice. Alice nailed all the details. Wow. Such productivity. But we got new stuff to do!
*** TODO Project X
**** TODO Subtask Y
- [ ] Task A
- [ ] Task B

I can configure my agenda to see them.

In addition to showing the stuff in my agenda, I want to include the contents in my project list, e.g. work.org:

* Current client
** Current Milestone
(Here comes not a copy, but a reference of the stuff from above:)
*** TODO Project X
**** TODO Subtask Y
- [ ] Task A
- [ ] Task B

I intend this to be a reference of the heading, so that changes in any of the two org files are reflected in the other.

(Of course I wouldn't want to leave tasks in the journal. The example is contrived. But what about sharing tasks with others in an org file in e.g. Dropbox, and having changes reflected in my own files?)

Is there a method that I fail to find, maybe because I use the wrong search terms? Or would I have to write a sync function myself?


texts:
I'm trying to search for the last line in a string (lines separated by \n) using string match but I cannot make it work as intended. The code below evaluates to 0 while I would have expected 4. I guess my regex is wrong (it was supposed to be a newline (\n) followed by anything but a newline (.*) until the end of the string ($).
(string-match "\n.*$" "\n \n \n ")


texts: How can I fix if: Invalid search bound (wrong side of point) in mu4e?

texts:
mu4e works quite well here, but I have one big problem: When I try to reply to an email, I get this error:

  re-search-forward("^#![ ]?\\([a-zA-Z_./]+\\)" 50 t)
  (if (re-search-forward "^#![ ]?\\([a-zA-Z_./]+\\)" 50 t) (let ((interpreter (buffer-substring (match-beginning 1) (match-end 1)))) (if (or (not (= (string-match "/" interpreter) 0)) (not (and (file-exists-p interpreter) (file-executable-p interpreter)))) (message "%sWarning: `%s' is not a valid interpreter."))))
  (save-excursion (goto-char 1) (if (re-search-forward "^#![ ]?\\([a-zA-Z_./]+\\)" 50 t) (let ((interpreter (buffer-substring (match-beginning 1) (match-end 1)))) (if (or (not (= (string-match "/" interpreter) 0)) (not (and (file-exists-p interpreter) (file-executable-p interpreter)))) (message "%sWarning: `%s' is not a valid interpreter.")))))
  shebang-check-interpreter()
  run-hooks(after-save-hook)
  basic-save-buffer(nil)
  save-buffer()
  (closure (mu4e-compose-mode-abbrev-table mu4e-compose-mode-syntax-table t) nil (if (eq mu4e-compose-type 'reply) (progn (mu4e~remove-refs-maybe))) (if use-hard-newlines (progn (mu4e-send-harden-newlines))) (set-buffer-modified-p t) (save-buffer) (mu4e~compose-setup-fcc-maybe) (widen))()
  run-hooks(message-send-hook)
  message-send(nil)
  message-send-and-exit(nil)
  funcall-interactively(message-send-and-exit nil)
  call-interactively(message-send-and-exit nil nil)
  command-execute(message-send-and-exit)

The normal mail headers, when replying, look like this:

From: Markus Grunwald <markus@the-grue.de>
To: Markus Grunwald <markus@the-grue.de>
Subject: Re: Attachment Signatur?
Date: Wed, 13 May 2020 14:52:15 +0200
In-reply-to: <87d078qazs.fsf@bob.galaxy.home>
--text follows this line--

When I delete the In-reply-to: header, the mail is sent...


texts: How to unhighlight after searching in evil mode?

texts:
I have a text file opened in Spacemacs with evil mode on. When I search for a term by means of /term [Enter] then found "term"s are highlighed.

How do I remove that highlighting? I tried / [Enter] - that didn't work. The highlighting will stick around even after switching to insert mode.


texts: term face font initially works but then falls back to default

texts:
I have defined my faces for the term group that way:
 '(term ((t (:inherit default :family "Courier"))))

and all other colours pretty similarly.
(I have also tried defining it without using inheritance – I've stated all colour values etc explicitly but it didn't change the behaviour)
so my intention was that it would be the same face as the default one but with a different font. For some reason it doesn't work how it should...
When I turn on the ansi-term the first opening lines are indeed written in the courier font but then when I just hit enter it goes away and falls back to the default. You can see it in the picture:

I've started the ani-term in my .emacs.d directory. The information about zsh and the first prompt are in the courier font but as soon as I've entered enter it turned off. The weird thing you can see in the listing is that the courier font holds with the bold blue text (eg the word "themes") but for the black text (eg "tramp") – not anymore.
When I inspected this with C-u C-x = on the first prompt the result was
mac-ct:-*-Courier-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1 (#x4A)
font-lock-face       term

but when I tested it just one line after the first one it was
mac-ct:-*-Menlo-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1 (#x44)
font-lock-face       (:foreground "black" :background "#e3dfca" :inverse-video nil)

so initially my settings work but then they somehow don't.
I've found a similar issue about which someone has already asked before but they didn't receive any helpful answers.
I'd be happy if someone could help me resolve this issue.
Here's full customisation for the record (here term being just the font family but it doesn't change anything) – all other faces from there work apart from the term one
(custom-set-faces
 '(term ((t (:family "Courier"))))
 '(term-bold ((t (:weight bold :family "Courier"))))
 '(term-color-black ((t (:background "black" :foreground "black" :family "Courier"))))
 '(term-color-blue ((t (:background "medium blue" :foreground "medium blue" :family "Courier"))))
 '(term-color-cyan ((t (:background "cyan3" :foreground "cyan3" :family "Courier"))))
 '(term-color-green ((t (:background "green4" :foreground "green4" :family "Courier"))))
 '(term-color-magenta ((t (:background "magenta3" :foreground "magenta3" :family "Courier"))))
 '(term-color-red ((t (:background "red3" :foreground "#b12512" :family "Courier"))))
 '(term-color-white ((t (:background "white" :foreground "white" :family "Courier"))))
 '(term-color-yellow ((t (:background "yellow4" :foreground "yellow4" :family "Courier"))))
 '(term-underline ((t (:underline t :family "Courier")))))


texts: Cache symmetric encryption passphrase for a session or some amount of time

texts: I use symmetric encryption in emacs 24 and somewhere along the line the variable named epa-file-cache-passphrase-for-symmetric-encryption seems to have disappeared from emacs.  I am going crazy entering the passphrase twice each time I try to save or open a file. I must have missed some big change but google does not seem to be helping much figure out what I need to do to get some sort of caching of the passphrase during a session.


texts: Byte-compiling a file against a package that may or may not be here

texts:
I am trying to include support for smartparens in a major-mode package. I want that if a user is using smartparens, then he will get additional pair definitions, and if he isn't, he will not notice anything different.

For that, I am using instructions of the form:

(declare-function sp-with-modes "ext:smartparens.el" t t)
(declare-function sp-local-pair "ext:smartparens.el" t t)

(eval-after-load 'smartparens
  '(sp-with-modes '(test-mode)
     (sp-local-pair "<" ">"
                    :actions '(insert wrap autoskip))))

This works fine if the file is not byte-compiled, or if it is byte-compiled by an emacs with smartparens loaded, or with emacs 24.3. However, with 24.5 (and probably with 24.4, though I cannot easily test it at the moment), and if it is compiled in a vanilla emacs (for example with cask build), it gives an error, stating that the argument (insert wrap autoskip) is not one of the keywords admissible by sp-local-pair (:actions...).

If I remove the call to sp-with-modes, and I replace the definition with

(sp-local-pair 'test-mode "<" ">"
               :actions '(insert wrap autoskip))

then it works fine. The macro sp-with-modes is supposed to loop over its argument (a list), inserting each element as first argument to everything in the body, I suspect that it confuses the byte-compiler at some point.

Is there a way to include this kind of "maybe evaluation" in a byte-compiled file, without confusing the byte-compiler? For example, is it possible to tell the compiler "do not compile this form"?

Or what would be the idiomatic way of achieving this kind of third-party support in a package?

Please note that the question involves smartparens because that's where I noticed the problem, but I suspect that it may happen with a lot of other packages.

The rest of the question is a MWE. I assumes that your regular emacs configuration has smartparens installed.

File ~/.emacs.d/tests/test.el

(declare-function sp-with-modes "ext:smartparens.el" t t)
(declare-function sp-local-pair "ext:smartparens.el" t t)

(eval-after-load 'smartparens
  '(sp-with-modes '(test-mode)
     (sp-local-pair "<" ">"
                    :actions '(insert wrap autoskip))))

(define-derived-mode test-mode
  fundamental-mode "Test" "Test mode")

(provide 'test)

File ~/.emacs.d/tests/init.el:

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))

(package-initialize)

(add-to-list 'load-path "~/.emacs.d/tests/")
(require 'test)

(require 'smartparens)
(smartparens-global-mode t)

Run emacs -Q and evaluate

(byte-compile-file "~/.emacs.d/tests/test.el")

then run emacs -Q --load "~/.emacs.d/tests/init.el".


texts: How to remove certain text-properties from a list of properties

texts:
text-properties-at returns a list of various text properties.

I want to remove:  display (image :type xpm :file /Users/HOME/.0.data/.0.emacs/.0.images/ezimage/box-plus.xpm :scale 1.1070588235294117 :ascent center).  The image may change, so I'd like a general approach that targets the display property and any value that may exist in relation thereto.

I thought I was dealing with a plist and I read about remprop, but it strips everything in the entire list -- i.e., it makes the whole list nil.

      (let ((props (text-properties-at 0 OBJECT)))
      (setq props (remprop 'props 'display)))


texts:
Context. I frequently use

org-mode timers
The org-mode clock (which just displays the clock in the org-mode mode-line)
A custom "target time" clock, which shows a point in time (either a few minutes or a few hours from now) that I'm trying to get something done by

Here's the way it looks now as an example:

12:40PM 0.57 is the current time, <0:00:42> is the active timer, and 12:48PM is the "target time" I'm trying to get my current task done by.
Problem. This mode-line disappears or gets mangled all of the time (particularly, I think, when I switch buffers around?). I would like it to be displayed universally no matter which emacs buffer I'm in. I've tried setting
(setq global-mode-string '("" display-time-string org-mode-line-string org-timer-mode-line-string " " est-target))

where est-target is my "target time" (as described in (3)), but it doesn't always work (even when I bind it to key and press it on the current buffer).
Does anyone know how to lock this mode-line in place?


texts: Links open firefox with starting page, instead of link content (linux)

texts:
Problem:

For some mysterious reason, when I open a link in firefox, a new firefox instance opens. Also note instead of the content of the link, my home-page shows up.

Instead I would like a new tab to open in my running instance and actually show the content of the link.

but I would like to make it work for firefox?

I am running Fedora Linux 21, with emacs 24.4.1.

Troubleshooting:

1) If I set my browser to chrome/eww, then it works:

(setq browse-url-browser-function 'browse-url-generic
      browse-url-generic-program "google-chrome")

2) I tried loading my emacs with emacs -q and dissabling all firefox plugins, but the result was the same.

EDIT: Solution:

As per post below, I rebuild emacs from sources and that solved the problem.

In case anyone reads this, I wrote a blog entry on how to rebuild emacs on fedora:
https://coffeeorientedprogramming.wordpress.com/2015/03/11/how-to-compilebuild-emacs-from-scratch-on-fedora/

For Ubuntu:
http://ergoemacs.org/emacs/building_emacs_on_linux.html


texts: order agenda so all-day and multi-day duration items appear on top

texts:
My problem is with two of my main use-cases for time-stamped items (essentially events). Consider these two org-mode items:
 * Clojure Dojo at uSwitch <2016-11-14 Mon 19:00>
 * Trip to Jamaica <2016-12-14 Wed>-<2017-01-02 Mon>

For the first item, simple date+time stamped events appear in the agenda on the top in the time-scale view of the day.
I use multi-day duration events for the purpose to remind me major contexts (like being abroad, on holiday, etc.), based on which I might have to adjust my priorities for those days.
My question is, how can I sort the agenda items, so that all-day events (including multi-day duration) are on top of the agenda?
Whether the all-day/multi-day items should appear above the daily time-scale, or below, is not important. Actually, I would look forward to look at both if possible.
I was told to look into the org-agenda-sorting-strategy option, and write a user defined function for it. I would like to ask for an example elisp code to achieves the above.
Might worth noting that I am mostly using day view agenda. Not sure how such changes could affect the yearly, monthly, or other agenda views...


texts: How to configure flycheck (c/c++-clang) to ignore some files or directories?

texts:
My C++ code use third-party library, so I have to add the library path to flycheck-clang-include-path to avoid can't find header file error.

But I don't want flycheck to do the syntax check on that library.

Because it always report warning/error on any file which include header files from that library.


texts: Is there a more efficient alternative to search-forward when searching for a single character?

texts:
I need to split the contents of a buffer into a list of strings. The null character is used to separate the items.

It the items were separated by newline characters, then I could use the same approach as process-lines:

(let (lines)
  (while (not (eobp))
    (setq lines (cons (buffer-substring-no-properties
               (line-beginning-position)
               (line-end-position))
              lines))
    (forward-line 1))
  (nreverse lines))

I assume forward-line is efficient, but the use of line-beginning-position and line-end-position is a bit suspicious. But since the null character is used I cannot do that anyway.

One way of doing it would be:

(split-string (buffer-string) "\0")

I was also considering this variation:

(split-string (buffer-substring-no-properties (point-min)
                                              (point-max))
              "\0")

Is that actually more efficient? The text in the buffer is not propertized, but I would imagine that looking for the non-existent properties would still add an overhead.

Instead of reading the buffer into a string and then splitting the string I would like to instead work on the buffer directly - again assuming that that actually is more efficient.

(let ((beg (point))
      items)
  (while (search-forward "\0" nil t)
    (push (buffer-substring-no-properties beg (1- (point))) items)
    (setq beg (point)))
  (nreverse items))

Does something like search-forward-char exist and would that be more efficient than search-forward?

I suppose I could use:

(while (not (= (char-after) ?\0)) (forward-char))

But I would expect that to be available as a function if it were more efficient than search-forward.


texts:
In org mode, a file can be included for export using #+Include: filename.  Is there an easy way to open a file in an include statement?
I've tried C-c C-o, but emacs states "no link found".


texts: How to call lynx on URL inside a program

texts:
During my LaTeX typesetting I need to "visually" check if URLs point to reacheable pages. I'd like to do it with lynx in a separate emacs buffer so I wrote this function:

(defun urls-check-if-working-link ()
  (interactive)
  (save-excursion
    (let* ((a (copy-marker (point-min)))
       (case-fold-search nil)
       (enable-recursive-minibuffers t))

      (goto-char a)
      (while (search-forward-regexp "\\\\\\(?:href\\|url\\){\\([^}]+\\)}" nil t)
    (save-excursion
      (let ((URL (match-string 1)))

        (unless (or
             ;; 1 - Commented String
             (nth 4 (syntax-ppss))

             ;; 2 - It's a DOI
             (string-match-p "doi\\.org" URL))

          ;; (eww-browse-url URL)
          (shell-command (concat "lynx " URL))

          ;; taking time to do something:
          (read-string (concat URL ": TEST"))))))

      )))

Running it I get the error:

Your Terminal type is unknown!

I found I need to use ansi-term to make lynx work. The command:

(ansi-term "lynx" "*BUFFER-NAME*")

works, but I'm not able to make it open a given URL. I mean something like:

(ansi-term "lynx https://www.google.com" "*BUFFER-NAME*")

Where I'm doing wrong?
Do you suggest a different approach?


texts: Do not add TITLE as heading to body when exporting org file

texts:
This export option:

#+TITLE: My title

Does two things:

adds a meta tag on the document's head: <title>My title</title>
adds a heading at the start of the generated content div:
My title

I want 1 but do not want 2. Is it possible to configure this?


texts: Difference between `evil-search-forward` and `evil-ex-search-forward`

texts:
It's in the title:

What's the difference between evil-search-forward and evil-ex-search-forward?

When would I want to use one instead of the other?

  evil-search-forward
  Search forward for user-entered text.
  Searches for regular expression if evil-regexp-search is t.

  evil-ex-search-forward
  Starts a forward search.


texts:
I have the following skeleton pair setup to quickly insert LaTeX fragents into org-mode documents:

(setq skeleton-pair t)
(global-set-key (kbd "$") 'skeleton-pair-insert-maybe)

This works. But the trouble is that it works everywhere. How can I limit this behavior, so that it affects the body text of Emacs org documents (i.e., not applied to babel code-blocks)?


texts: Can tangling embed code in external files? instead of recreating files

texts:
I'm building a web application using the literate programming style.
At least trying to.

I wanted to "hit the ground running", so I decided "make a copy" of one of the many "starter apps"

https://github.com/RailsApps/rails-bootstrap

So before I have written a single line of code, I have a directory
structure for the application (app/ public/ tmp/ etc), and tons of boilerplate code.

The first piece of code I wrote in my org file is this

#+begin_src ruby
after_create :create_braintree_customer

def create_braintree_customer
  Braintree.api_key = "bk-54cfa45"
  self.id = Braintree::Customer.create.id
  self.save
end
#+end_src

Now when "tangling", this method should go here:

$ cat ~/project/app/models/user.rb
class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  <<<<<<<< my code block should come here >>>>>>>>>>>>

end

Is this possible with the literate programming tools available with emacs?

What I tried:
Read some examples at https://github.com/limist/literate-programming-examples
but the tangling there generates whole files. I want to "embed" my stuff in to "template generated" stuff of the MVC application.


texts:
I provide web-mode-column-show in web-mode.el to display a column that "connects" the start tag and the end tag.

This column may cross empty lines. In that case I use (move-to-column COL t) (see the t arg) to put the overlay at the right column. The problem is that, doing so, I modify the buffer content (I add spaces).

Is there a way to display an overlay at a specific line/column where no "content" exists ?


texts:
Is there any way to make dabbrev-expand work by lines, so that, for example, having typed
  This = That
  T

dabbrev-expand returns This as the first expansion, rather than That.
In general, I more often want to refer to the variable on the left hand side of an assignment than the one on the right.  (And I often use variables with common prefixes).
EDIT
As I understand it, dabbrev-expand searches backwards from point.  However, it would be more likely to find the match I'm looking for if it searched forward from the beginning of the line, stepping backwards to the previous line if no match is found.  Is there any way of achieving this?


texts: Magit: How reset-soft to specific commit?

texts:
List of my branches:

develop
features/magi
master

Current branch is features/magi.

I want to reset from current commit (commit 3) to previous commit (commit 1). So I use command:

magit-reset-soft

But Magit offers me to reset to one of the branches. Why?

Here screenshot:


texts: Debugger breaks with Args out of range: "", 0

texts: When forge is installed on a system with no compiler, I sometimes get this error which breaks magit. I'd like to figure out the traceback for this error so I can add some proper error handling, however, when I call (toggle-debug-on-error) every time this error is suppose to happen the debugger doesn't show but instead shows Args out of range: "", 0. The debugger seems to trigger successfully on other errors. I'm using GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)


texts:
Lets say I'm already in emacs and I need to open some obscure file (long complicated path) that I rarely ever edit (so its not in my recent files list) - what is the correct way to do this using spacemacs shortcuts?

Currently I have to use helm and manually type the path to the file. Id rather have some sort of browser where I could look at directory structures and select folders to "cd" into

Secondly, lets say I need to create a brand new file in some obscure directory. Again, what is the correct spacemacs way to create this new file?

I'm pretty new to emacs so the way that I'm currently doing this things (manually typing paths in helm) feels very slow and I'm mostly wondering whether this is common or whether theres another way to do these things that I'm not aware of


texts: Adding a method to ‘make-instance’ fails every time I try

texts:
So, I’ve learned enough about generic functions, CLOS, and EIEIO to believe that this should work:

(defclass foo () nil)

(cl-defmethod make-instance ((x foo) &rest args)
  (with-temp-message "Is this thing on?"
    (sit-for 1))
  (cl-call-next-method))

(make-instance 'foo)

But, that just returns a new “foo” object, it doesn’t stop and display a message like I thought it would. Is there something I’m doing wrong here? (Bonus points if there’s a way I can investigate visually what’s going on—eieio-display-method-list doesn’t seem to work anymore, and I’ve tried to look into the internals of how methods are selected but I just get lost in a maze of structs and functions with names like cl--generic-generalizer-specializers-function.)

I’m using Emacs 26.2 on Ubuntu 18.04 LTS.


texts: What's the difference between `set-face-background` and `custom-set-faces`?

texts:
I get an error, Invalid face: helm-selection, using dotspacemacs/user-config:

(set-face-background 'helm-selection "#EEAD0E")

It runs fine if I manually enter it using helm-M-x.

However, I get no errors (during startup) for the following in dotspacemacs/user-config:

 (custom-set-faces
    '(helm-selection ((t (:background "#EEAD0E" :foreground "#222226"))))
  )

I've read the documentation on both face functions, but I still counldn't figure out the reason for the different behaviour.


texts: Proper approach to providing external programs along with packages?

texts:
I maintain a number of elisp packages (e.g. codesearch, emacs-ycmd, traad) that would benefit from being able to install the external programs that they use, saving time and effort for some users. For example, with codesearch.el it would be nice to be able to download, compile, and install the codesearch tools (written in go, not elisp) for users. This would remove at least one barrier for using the package.

Are there any "best practices" for doing this? For example, where should I put the external programs?

If if you don't have any direct advice, can you refer me to any packages that do something like this (and, ideally, that do it well)?


texts:
I installed package from M-x package-list-packages and want to disable this package without uninstalling.

UPDATE With (setq package-load-list '((company nil))) I have in *Packages* buffer:

company            0.9.3         disabled              Modular text completion framework

but completion dialog still appear.

I have

(defun my-company-prog-mode-setup ()
  (setq-local company-dabbrev-code-other-buffers 'code)
  (setq-local company-backends '((company-capf company-dabbrev-code company-files)))
  (company-mode 1))

(when (featurep 'company)
  (add-hook 'prog-mode-hook #'my-company-prog-mode-setup))


texts:
What is the difference between pop-to-buffer-same-window and switch-to-buffer?

switch-to-buffer-other-window is basically an alias for pop-to-buffer, so I'm surprised that pop-to-buffer-same-window is not basically an alias for switch-to-buffer.


texts: Move point inwards while counting number of nested parentheses without throwing an error

texts:
I would like to write a function that counts the number of nested parentheses while moving the cursor to the innermost bracket without throwing an error.

  (defun count-and-move ()
    (interactive)
    (setq c 0)
    (while t
      (down-list)
      (incf c)))

If we run this code, the cursor would eventually reach the innermost bracket.

  |「「「「」」」」 --> 「「「「|」」」」

After which it throws an error:

  down-list: Scan error: "Containing expression ends prematurely", 254, 255

What should the condition for while be so that the movement stops automatically when the cursor has reached the innermost point?

In human language, it would be something like:
"Keep running (down-list) and increase counter by 1 until the cursor is stuck." OR
"Break out of loop if (down-list) is going to throw an error!"


texts: kill-buffer with y-or-n-p instead of yes-or-no-p

texts:
Q:  How can I use y-or-n-p -- instead of yes-or-no-p -- when calling kill-buffer for just the duration of a particular function?

In other words, I want the behavior of (fset 'yes-or-no-p 'y-or-n-p) but only for the duration of a particular function without any lasting effect.

CAVEAT:  I would like to please avoid using (fset 'yes-or-no-p 'y-or-n-p) at the outset and (fset 'yes-or-no-p 'yes-or-no-p) at the tail end of the function, just in case I decide to exit out of the function with a 'quit signal such as C-g, in which case the effect would become long-lasting rather than merely temporary.

Here is a test snippet to start with:

  (let* (
    (filename "/private/tmp/foofile")
    (buf (get-buffer-create "*foo*")))
  (with-current-buffer buf
    (write-file filename)
    (insert "Every good boy deserves fudge."))
  (kill-buffer buf)
  (delete-file filename))


texts: How to set env values for eshell in emacs on macOS?

texts:
If use iTerm on macOS, we can set env values in its terminal. It also set path such as /usr/local/bin/ in ~/.bashrc.
But in emacs' terminal as eshell, run kubectl shown kubectl: No such file or directory.
It seems that it didn't find the command's path.
How to set path for emacs? For example, in spacemacs.
I found this exec-path-from-shell
M-x package-install exec-path-from-shell RET

Edit ~/.emacs.d/init.el to add
(when (memq window-system '(mac ns x))
  (exec-path-from-shell-initialize))

to the bottom.
Copy PATH from .bashrc to .profile.
$ cat ~/.profile
export PATH=/usr/local/bin:/usr/bin:/bin

Start GNU Emacs For Max OS X still can't find the command's path in eshell. The spacemacs alert:
Warning (initialization): An error occurred while loading ‘/Users/user/.emacs.d/init.el’:

Symbol's function definition is void: exec-path-from-shell-initialize

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.

The full file of ~/.emacs.d/init.el:
;;; init.el --- Spacemacs Initialization File -*- no-byte-compile: t -*-
;;
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)

;; Avoid garbage collection during startup.
;; see `SPC h . dotspacemacs-gc-cons' for more info
(defconst emacs-start-time (current-time))
(setq gc-cons-threshold 402653184 gc-cons-percentage 0.6)
(load (concat (file-name-directory load-file-name)
              "core/core-versions.el")
      nil (not init-file-debug))
(load (concat (file-name-directory load-file-name)
              "core/core-load-paths.el")
      nil (not init-file-debug))
(load (concat spacemacs-core-directory "core-dumper.el")
      nil (not init-file-debug))

;; Clean compiled files if they become stale or Emacs version has changed.
(load (concat spacemacs-core-directory "core-compilation.el")
      nil (not init-file-debug))
(load spacemacs--last-emacs-version-file t (not init-file-debug))
(let ((default-directory spacemacs-start-directory))
  (when (or (not (string= spacemacs--last-emacs-version emacs-version))
            (spacemacs//contains-newer-than-byte-compiled-p
             spacemacs--compiled-files))
    (spacemacs//remove-byte-compiled-files spacemacs--compiled-files)))
(when (not (string= spacemacs--last-emacs-version emacs-version))
  (spacemacs//update-last-emacs-version))

(if (not (version<= spacemacs-emacs-min-version emacs-version))
    (error (concat "Your version of Emacs (%s) is too old. "
                   "Spacemacs requires Emacs version %s or above.")
           emacs-version spacemacs-emacs-min-version)
  ;; Disable file-name-handlers for a speed boost during init
  (let ((file-name-handler-alist nil))
    (require 'core-spacemacs)
    (spacemacs/dump-restore-load-path)
    (configuration-layer/load-lock-file)
    (spacemacs/init)
    (configuration-layer/stable-elpa-init)
    (configuration-layer/load)
    (spacemacs-buffer/display-startup-note)
    (spacemacs/setup-startup-hook)
    (spacemacs/dump-eval-delayed-functions)
    (when (and dotspacemacs-enable-server (not (spacemacs-is-dumping-p)))
      (require 'server)
      (when dotspacemacs-server-socket-dir
        (setq server-socket-dir dotspacemacs-server-socket-dir))
      (unless (server-running-p)
        (message "Starting a server...")
        (server-start)))))

(when (memq window-system '(mac ns x))
  (exec-path-from-shell-initialize))


texts: I want to create a mode which in certain states converts all input to uppercase, regardless of the caps-lock status. But I'm at a loss as to how to go for this, and I'm not sure it could even be done. Any help would be appreciated.


texts:
I've just started with mu4e and was mainly following the manual. For that reason I wanted to change the :subject in the headers view to :thread-subject. I've linked gmail with offlineimap and as far as I understood the option :thread-subject shouldn't repeat subjects for conversations. However, somehow it isn't picked up in my case. I've changed the mue4-headers.el like:

(defcustom mu4e-headers-fields
  '( (:human-date       .   12)
     (:flags            .    6)
     (:mailing-list     .   10)
     (:from             .   22)
     (:thread-subject   .   nil))

however, I still get displayed all subjects within a thread.


texts:
I'm trying unbind  org-cycle-agenda-files which is set by default to  C-' and C-,.

My weapon of choice to do so is use-package package.

On  github.com/use-package/bind-key.el
 page I have found following lines:

;; To unbind a key within a keymap (for example, to stop your favorite major
;; mode from changing a binding that you don't want to override everywhere),
;; use `unbind-key':
;;
;;   (unbind-key "c-c x" some-other-mode-map)

This resulted in me unsuccessfully trying following variations:

(unbind-key "C-'" )
(unbind-key "C-," )
(unbind-key "C-'" (org-cycle-agenda-files))
(unbind-key "C-," (org-cycle-agenda-files))
(bind-keys :map org-mode-map
       :unbind "C-'")
(unbind-key "C-'" org-cycle-agenda-files)

After that fail I triyed some "traditional" solution to the problem.

Information found in gnu.org manual, and some emacs.stackexchange answers resulted in me producing following useless havoc:

(define-key (org-cycle-agenda-files) key nil)
(define-key (current-global-map) "C-'" nil)
(local-unset-key "C-'")
(global-unset-key "C-'")
(with-eval-after-load org-mode
  (unbind-key "C-'" org-mode-map)
  (unbind-key "C-," org-mode-map))
(global-set-key (kbd "C-'") 'nil)

Yep.... None these variations vorks. :D

I would love to find use-package based solution, since I'm already using some of it's awesome capabilities.

Any kind of suggestion is welcome.


texts:
Is there a way in emacs to open a file (or a dired directory) in a new buffer, even if there's a buffer with the same file (or directory)?

find-file and find-alternate-file always return the open buffer instead of creating a new one.

EDIT: The use case I have is that I am using dired-single to navigate through directories using a single buffer (so that new directories are opened in the same buffer using find-alternate-file).
However, if I have two separate buffers for two different directories (which I do when copying files from directory to another, for example) and I navigate in one buffer to the directory of the other, I end up with a single buffer and two frames. I would instead like to have two separate buffers showing the same directory. Much like what happens when I explore directories in my file explorer.


texts: Emacs keeps guessing wrong coding system on a file I edit both in Linux and Windows

texts:
I use Emacs on both Linux and Windows to edit the same files (that I keep in Dropbox, which I hope is irrelevant, but who knows). The files are encoded in utf-8 with Unix line endings. Occasionally, I will notice that when editing them on Windows accented characters display incorrectly which I can correct by telling M-x recode-region that the file was really in utf-8 but was interpreted as iso-latin-1.

Why is Emacs incorrectly guessing my file is in iso-latin-1? Why does it only do that on Windows?


texts: How can I create a new label using Magit forge?

texts: Using Magit Forge, I'd like to create a new label for a new issue.  I can edit the Labels field using command forge-edit-topic-labels, but that command accepts only labels that already exist.  How can I create a new label?


texts: cant' create file with the same name in different directory in dired

texts:
I'm trying to create the new empty file

Tried 'c'
Tried C-x C-f

when I type "mixins.py" Find file always suggest me to open the file in other directory with the same name, so I'm forced to create the file in shell and then reload dired with 'g'

this becomes very annoying. How to fix it? I still like the ability for emacs to suggest me the path based on file name, but I also want to create empty files when needed.


texts: How to specify the geometry of the *tex-shell* frame?

texts:
I'm using Emacs 24 in Ubuntu 14.04 and when first compiling a TeX file after start up, a frame called *tex-shell* is automatically opened and all further compilation processes run in this frame.

I usually move this frame to another workspace ("desktop"), so my editing appears in my main workspace and compilation in a secondary one.

It would be optimal if this new frame appeared directly in this secondary workspace, but I presume that this is kinda difficult. In any case,

  I would like to know if there is a way of choosing the geometry of the frame, in the sense that it has the same size and the same position in the screen every time.

Actually, it seems that the geometry is always the same, but when I changed from Emacs 23 to Emacs 24 this parameter changed.

Thank you for any help, and specially if you know something about automatically selecting workspaces.


texts:
I had to reinstall emacs and completely redo my config file, but for some reason, some of the custom keybindings that used to work with "move-dup" package from Melpa. Here is what i have:
#+begin_src emacs-lisp
(require 'move-dup)

(global-set-key (kbd "M-<up>") 'md-move-lines-up)
(global-set-key (kbd "M-<down>") 'md-move-lines-down)
(global-set-key (kbd "C-M-<up>") 'md-duplicate-up)
(global-set-key (kbd "C-M-<down>") 'md-duplicate-down)
#+end_src>

What would stop these from working?
EDIT: so this does work, if i enable move-dup-mode, however I can't seem to get it to be enabled on start up, I've tried adding the following but it still doesn't load on startup:
(move-dup-mode 1)

I've also tried:
(global-move-dup-mode 1)

and I've also tried replacing the '1' for a 't' in on each one too, but to no avail. How can I get this to load on startup please?


texts: Helm-mode-dired-do-rename change name of file to a prefix of itself

texts: Say I have a file named foo in directory bar. I also have helm-mode enabled and am trying to rename foo to fo through dired. Rename here ends up opening helm-mode-dired-do-rename and on typing fo, the only helm candidate is foo. How do I tell helm that the name I want to use is fo?


texts: A way to omit exporting comment headings in org-mode?

texts:
I'd like to be able to do the following:

* A story about airplanes
** Chapter one
*** # Introduce the main character
Billy was a nice boy etc ...
*** # Set the scene
One day Billy stumbled upon a paper airplane..

In other words, I want to be able to write prose and use headings with their expand/collapse capability to give hints to myself about what I'm trying to say in a given paragraph/section, but when exporting I don't want these to be treated as headings that should be part of the text.

Is this possible?

According to this page[1] lines starting with # are treated as comments. But when they are headings they are still exported.

[1] https://orgmode.org/manual/Comment-lines.html


texts: Editing a stored keyboard macro and storing the edited version

texts:
In my ~/.emacs, there are several keyboard macros stored. They appear as (fset 'dhteu-macro-name ... entries. BTW, dhteu is just a random alphabet combination prefixed to avoid collision with any existing commands.

I can C-x C-k e M-x supply a macro name and a buffer opens allowing me to edit the macro. I can edit it and save it with C-c C-c. Now if I C-x C-k e M-x same macro name, I see the modified version. I tried executing the modified macro on a buffer. The madified macro executes successfully.

After all this, I naturally, want to store the macro. So, I visit ~/.emacs and M-x insert-kbd-macro. I expect the name of the macro I just edited to be available at this prompt. It isn't.

Entering the entire name produces a no match error.

I tried C-x C-k n to give it another name. That produces a No keyboard macro defined error.

So, the question is: How do I edit a stored keyboard macro and save it again?


texts: How to avoid variable name collisions in my init file?

texts:
I noticed spacemacs puts things like autosave and backup files in ~/.emacs.d/.cache/ and I'd like to use that idea in my own setup.

From spacemacs/core/core-load-paths.el

(defconst spacemacs-cache-directory
  (expand-file-name (concat user-emacs-directory ".cache/"))

I considered adding this to my own init.el,

(defconst cache-directory
  (expand-file-name (concat user-emacs-directory ".cache/"))

but without the "spacemacs" prefix, "cache-directory" seems like a dangerously generic name, likely to collide with something at some point.

I'm still new to emacs, and I don't know enough about scoping in elisp to say whether this is a serious concern. Should I name it something silly like "ivan-cache-directory", or is there a best practice people stick to? Or is this not actually worth worrying about?


texts: ESS ignores R_LIBS_USER environment variable

texts:
I have the following in my .bashrc

export R_LIBS_USER="/home/wdkrnls/R/lib/3.2"

When I start R from the shell I see (even in Emacs M-x shell):

.libPaths()
[1] "/home/wdkrnls/R/lib/3.2"  "/usr/lib/R/library"

When I start an R process with M-x R, I see:

.libPaths()
[1] "/usr/lib/R/library"

How do I make ESS know about and use official R environment variables instead of ignoring them?